ExBitstamp v0.1.1 ExBitstamp View Source

Wraps Bitstamp HTTP API into functions respective of public and private API endpoints.

The currency_pair parameter in functions is expected to be an ExBitstamp.CurrencyPair struct. See module documentation for more info on all available convenience functions, but in short, supported currency pairs can be obtained by calling appropriately named functions:

alias ExBitstamp.CurrencyPair

ExBitstamp.ticker(CurrencyPair.btcusd())

API call functions return successful results as a {:ok, results} tuple or {:error, {error_type, reason} tuple in case of an error. See respective functions’ docs for examples of specific return values.

ExBitstamp module uses v2 Bitstamp API endpoints whenever possible.

Module functions which take an optional creds parameter hit Bitstamp’s private API which requires valid API credentials for signature generation. By default, if no credentials are provided as an argument ExBitstamp will try to fetch credentials from config. Config should be defined as:

config :ex_bitstamp,
  creds: %{
    customer_id: "customer_id",
    key: "key",
    secret: "key"
  }

Otherwise, if credentials are provided as an argument, ExBitstamp.Credentials struct should be used to pass the credentials to functions.

Link to this section Summary

Functions

Fetches account balance data for a currency pair

Fetches account balance data for all currencies

Retrieves bank withdrawal status

Places a limit buy order for a currency pair

Places a buy market order for a currency pair

Cancels all orders

Cancels bank withdrawal status

Retrieves bitcoin cash deposit address

Retrieves bitcoin deposit address

Retrieves ethereum deposit address

Retrieves litecoin deposit address

Retrieves ripple deposit address using v1 API

Retrieves xrp deposit address

Fetches EUR/USD conversion rate

Retireves transactions for liquidation address

Fetches open orders data for a currency pair

Fetches open orders data for all currencies

Fetches order book data for a currency pair

Fetches order status

Places a limit sell order for a currency pair

Places a sell market order for a currency pair

Fetches ticker data for a currency pair

Fetches hourly ticker data for a currency pair

Fetches trading pairs info

Fetches transactions data for a currency pair

Executes a transfer of funds from main account to sub account

Executes a transfer of funds from sub account to main account

Retrieves unconfirmed BTC data

Fetches user transaction data for a currency pair

Fetches user transaction data for all currencies

Executes bitcoin cash withdrawal

Executes ethereum withdrawal

Executes litecoin withdrawal

Fetches all withdrawal requests

Executes ripple withdrawal using v1 API

Link to this section Functions

Link to this function balance(currency_pair, creds \\ nil) View Source

Fetches account balance data for a currency pair.

Example successful response:

{:ok,
%{
 "btc_available" => "0.00000000",
 "btc_balance" => "0.00000000",
 "btc_reserved" => "0.00000000",
 "fee" => 0.25,
 "usd_available" => "0.00",
 "usd_balance" => "0.00",
 "usd_reserved" => "0.00"
}}
Link to this function balance_all(creds \\ nil) View Source
balance_all(ExBitstamp.Credentials.t() | nil) :: tuple()

Fetches account balance data for all currencies.

Example successful response:

{:ok,
%{
 "xrp_reserved" => "0.00000000",
 "bcheur_fee" => "0.12",
 "ltc_balance" => "0.00000000",
 "ltcbtc_fee" => "0.25",
 "btc_balance" => "0.00000000",
 "ltc_reserved" => "0.00000000",
 "eth_balance" => "0.39706665",
 "eur_available" => "0.00",
 "xrpbtc_fee" => "0.25",
 "bchusd_fee" => "0.12",
 "bch_available" => "0.00000000",
 "eurusd_fee" => "0.25",
 "ethusd_fee" => "0.25",
 "btc_available" => "0.00000000",
 "xrpeur_fee" => "0.25",
 "eur_balance" => "0.00",
 "btceur_fee" => "0.25",
 "usd_balance" => "0.00",
 "bch_balance" => "0.00000000",
 "xrpusd_fee" => "0.25",
 "ltcusd_fee" => "0.25",
 "eth_available" => "0.00000000",
 "bch_reserved" => "0.00000000",
 "ltceur_fee" => "0.25",
 "etheur_fee" => "0.25",
 "eur_reserved" => "0.00",
 "ethbtc_fee" => "0.25",
 "xrp_balance" => "0.00000000",
 "ltc_available" => "0.00000000",
 "bchbtc_fee" => "0.12",
 "eth_reserved" => "0.00000000",
 "btcusd_fee" => "0.25",
 "usd_available" => "0.00",
 "xrp_available" => "0.00000000",
 "usd_reserved" => "0.00",
 "btc_reserved" => "0.00000000"
}}
Link to this function bank_withdrawal_status(id, creds \\ nil) View Source
bank_withdrawal_status(String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves bank withdrawal status.

Link to this function buy(currency_pair, amount, price, opts \\ [], creds \\ nil) View Source

Places a limit buy order for a currency pair.

Accepts list of optional parameters as a keyword list. Allowed keys are: limit_price or daily_order. Only one of these can be present. See Bitstamp API docs for more info.

Link to this function buy_market(currency_pair, amount, creds \\ nil) View Source

Places a buy market order for a currency pair.

Link to this function cancel_all_orders(creds \\ nil) View Source
cancel_all_orders(ExBitstamp.Credentials.t() | nil) :: tuple()

Cancels all orders.

Example successful response:

{:ok, true}
Link to this function cancel_bank_withdrawal(id, creds \\ nil) View Source
cancel_bank_withdrawal(String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Cancels bank withdrawal status.

Link to this function cancel_order(id, creds \\ nil) View Source
cancel_order(String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Cancels an order.

Example successful response:

{:ok, %{"amount" => 0.1, "id" => 951827494, "price" => 750.0, "type" => 1}}
Link to this function deposit_address_bch(creds \\ nil) View Source
deposit_address_bch(ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves bitcoin cash deposit address.

Link to this function deposit_address_btc(creds \\ nil) View Source
deposit_address_btc(ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves bitcoin deposit address.

Link to this function deposit_address_eth(creds \\ nil) View Source
deposit_address_eth(ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves ethereum deposit address.

Link to this function deposit_address_ltc(creds \\ nil) View Source
deposit_address_ltc(ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves litecoin deposit address.

Link to this function deposit_address_ripple(creds \\ nil) View Source
deposit_address_ripple(ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves ripple deposit address using v1 API.

Link to this function deposit_address_xrp(creds \\ nil) View Source
deposit_address_xrp(ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves xrp deposit address.

Fetches EUR/USD conversion rate.

Example successful response:

{:ok, %{"buy" => "1.235", "sell" => "1.235"}}
Link to this function liquidation_address_info(address \\ nil, creds \\ nil) View Source
liquidation_address_info(String.t() | nil, ExBitstamp.Credentials.t() | nil) ::
  tuple()

Retireves transactions for liquidation address.

Link to this function new_liquidation_address(liquidation_currency, creds \\ nil) View Source
new_liquidation_address(String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Creates new liquidation address.

Link to this function open_bank_withdrawal(bank_withdrawal, creds \\ nil) View Source
open_bank_withdrawal(
  ExBitstamp.BankWithdrawal.t(),
  ExBitstamp.Credentials.t() | nil
) :: tuple()

Executes a bank withdrawal.

Link to this function open_orders(currency_pair, creds \\ nil) View Source

Fetches open orders data for a currency pair.

Example successful response:

{:ok,
[
 %{
   "amount" => "0.10000000",
   "datetime" => "2018-02-13 16:24:00",
   "id" => "951827494",
   "price" => "750.00",
   "type" => "1"
 }
]}
Link to this function open_orders_all(creds \\ nil) View Source
open_orders_all(ExBitstamp.Credentials.t() | nil) :: tuple()

Fetches open orders data for all currencies.

Example successful response:

{:ok,
[
 %{
   "amount" => "0.10000000",
   "currency_pair" => "ETH/EUR",
   "datetime" => "2018-02-13 16:24:00",
   "id" => "951827494",
   "price" => "750.00",
   "type" => "1"
 }
]}
Link to this function order_book(currency_pair) View Source
order_book(ExBitstamp.CurrencyPair.t()) :: tuple()

Fetches order book data for a currency pair.

Example successful response:

{:ok,
  %{
   "asks" => [
     ["7021.91", "1.11552422"],
     ["7021.92", "0.00216174"],
     ["7022.70", ...],
     [...],
     ...
   ],
   "bids" => [
     ["6867.88", "20.63509100"],
     ["6865.74", "2.94040800"],
     ["6861.31", ...],
     [...],
     ...
   ],
   "timestamp" => "1517927756"
  }}
Link to this function order_status(id, creds \\ nil) View Source
order_status(String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Fetches order status.

Example successful response:

{:ok, %{"status" => "Open", "transactions" => []}}
Link to this function sell(currency_pair, amount, price, opts \\ [], creds \\ nil) View Source
sell(
  ExBitstamp.CurrencyPair.t(),
  float(),
  float(),
  list() | nil,
  ExBitstamp.Credentials.t() | nil
) :: tuple()

Places a limit sell order for a currency pair.

Accepts list of optional parameters as a keyword list. Allowed keys are: limit_price or daily_order. Only one of these can be present. See Bitstamp API docs for more info.

Link to this function sell_market(currency_pair, amount, creds \\ nil) View Source

Places a sell market order for a currency pair.

Fetches ticker data for a currency pair.

Example successful response:

{:ok,
 %{
  "ask" => "7117.11",
  "bid" => "7100.00",
  "high" => "7499.00",
  "last" => "7100.00",
  "low" => "5920.72",
  "open" => "6878.65",
  "timestamp" => "1517927052",
  "volume" => "71876.22396439",
  "vwap" => "6707.61"
}}
Link to this function ticker_hour(currency_pair) View Source
ticker_hour(ExBitstamp.CurrencyPair.t()) :: tuple()

Fetches hourly ticker data for a currency pair.

Example successful response:

{:ok,
  %{
   "ask" => "6905.42",
   "bid" => "6900.51",
   "high" => "7281.80",
   "last" => "6900.60",
   "low" => "6784.18",
   "open" => "7165.04",
   "timestamp" => "1517927653",
   "volume" => "4102.91186873",
   "vwap" => "7076.36"
  }}
Link to this function trading_pairs_info() View Source
trading_pairs_info() :: tuple()

Fetches trading pairs info.

Example successful response:

{:ok,
[
 %{
   "base_decimals" => 8,
   "counter_decimals" => 2,
   "description" => "Litecoin / U.S. dollar",
   "minimum_order" => "5.0 USD",
   "name" => "LTC/USD",
   "trading" => "Enabled",
   "url_symbol" => "ltcusd"
 },
 %{
   "base_decimals" => 8,
   "counter_decimals" => 2,
   "description" => "Ether / U.S. dollar",
   "minimum_order" => "5.0 USD",
   "name" => "ETH/USD",
   "trading" => "Enabled",
   "url_symbol" => "ethusd"
 },
 ...
]}
Link to this function transactions(currency_pair, opts \\ []) View Source
transactions(ExBitstamp.CurrencyPair.t(), list()) :: tuple()

Fetches transactions data for a currency pair.

Accepts list of optional parameters as a keyword list. Allowed key is time with on of the following values: "minute", "hour" (default) or "day". See Bitstamp API docs for more info.

Example successful response:

{:ok,
[
 %{
   "amount" => "0.51879098",
   "date" => "1517928659",
   "price" => "7011.46",
   "tid" => "52902107",
   ...
 },
 %{
   "amount" => "0.23897801",
   "date" => "1517928659",
   "price" => "7011.45",
   ...
 },
 %{"amount" => "0.01480362", "date" => "1517928659", ...},
 %{"amount" => "0.04021837", ...},
 %{...},
 ...
]}
Link to this function transfer_from_main(amount, currency, sub_account_id, creds \\ nil) View Source

Executes a transfer of funds from main account to sub account.

Link to this function transfer_to_main(amount, currency, sub_account_id \\ nil, creds \\ nil) View Source
transfer_to_main(float(), String.t(), any(), ExBitstamp.Credentials.t() | nil) ::
  tuple()

Executes a transfer of funds from sub account to main account.

Link to this function unconfirmed_btc(creds \\ nil) View Source
unconfirmed_btc(ExBitstamp.Credentials.t() | nil) :: tuple()

Retrieves unconfirmed BTC data.

Link to this function user_transactions(currency_pair, creds \\ nil) View Source
user_transactions(ExBitstamp.CurrencyPair.t(), ExBitstamp.Credentials.t() | nil) ::
  tuple()

Fetches user transaction data for a currency pair.

Example successful response:

{:ok,
[
 %{
   "btc" => 0.0,
   "datetime" => "2018-02-02 13:08:20",
   "eth" => "0.41245141",
   "eth_eur" => 725.54,
   "eur" => "-299.25",
   "fee" => "0.75",
   "id" => 51366122,
   "order_id" => 880205621,
   "type" => "2",
   "usd" => 0.0
 },
 %{
   "btc" => 0.0,
   "btc_usd" => "0.00",
   "datetime" => "2018-02-02 13:00:29",
   "eur" => "300.00",
   "fee" => "0.00",
   "id" => 51351200,
   "type" => "0",
   "usd" => 0.0
 },
 ....
]}
Link to this function user_transactions_all(creds \\ nil) View Source
user_transactions_all(ExBitstamp.Credentials.t() | nil) :: tuple()

Fetches user transaction data for all currencies.

Example successful response:

{:ok,
[
 %{
   "btc" => 0.0,
   "datetime" => "2018-02-02 13:08:20",
   "eth" => "0.41245141",
   "eth_eur" => 725.54,
   "eur" => "-299.25",
   "fee" => "0.75",
   "id" => 51366122,
   "order_id" => 880205621,
   "type" => "2",
   "usd" => 0.0
 },
 %{
   "btc" => 0.0,
   "btc_usd" => "0.00",
   "datetime" => "2018-02-02 13:00:29",
   "eur" => "300.00",
   "fee" => "0.00",
   "id" => 51351200,
   "type" => "0",
   "usd" => 0.0
 },
 ....
]}
Link to this function withdrawal_bch(amount, address, creds \\ nil) View Source
withdrawal_bch(float(), String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Executes bitcoin cash withdrawal.

Link to this function withdrawal_btc(amount, address, instant, creds \\ nil) View Source
withdrawal_btc(float(), String.t(), boolean(), ExBitstamp.Credentials.t() | nil) ::
  tuple()

Executes bitcoin withdrawal.

Link to this function withdrawal_eth(amount, address, creds \\ nil) View Source
withdrawal_eth(float(), String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Executes ethereum withdrawal.

Link to this function withdrawal_ltc(amount, address, creds \\ nil) View Source
withdrawal_ltc(float(), String.t(), ExBitstamp.Credentials.t() | nil) :: tuple()

Executes litecoin withdrawal.

Link to this function withdrawal_requests(opts \\ [], creds \\ nil) View Source
withdrawal_requests(list(), ExBitstamp.Credentials.t() | nil) :: tuple()

Fetches all withdrawal requests.

Link to this function withdrawal_ripple(amount, address, currency, creds \\ nil) View Source
withdrawal_ripple(
  float(),
  String.t(),
  String.t(),
  ExBitstamp.Credentials.t() | nil
) :: tuple()

Executes ripple withdrawal using v1 API.

Link to this function withdrawal_xrp(amount, address, destination_tag \\ nil, creds \\ nil) View Source
withdrawal_xrp(
  float(),
  String.t(),
  String.t() | nil,
  ExBitstamp.Credentials.t() | nil
) :: tuple()

Executes ripple withdrawal.