HitBTC REST API v0.1.1 Hitbtc.Trading View Source

Set of trading API methods

This set of methods requires auth information. You could configure it into config.exs file of your application

Link to this section Summary

Functions

Closes all orders. If symbol passed orders will be closed for given symbol only

Close order with given clientOrderId

Load details of your order

List of your current orders

Get list of your trading balance

Get trading fee for given symbol

Link to this section Functions

Link to this function cancel_all_orders(symbol \\ "") View Source
cancel_all_orders(String.t()) :: {:ok, [map()]} | {:error, term()}

Closes all orders. If symbol passed orders will be closed for given symbol only.

Example:

iex(1)> Hitbtc.Trading.close_all_ordes()
{:ok,
  [%{clientOrderId: "fe423a1615d6429dafa6549780615155",
    createdAt: "2017-10-26T05:47:22.520Z", cumQuantity: "0.000",
    id: "4645665806", price: "1.000000", quantity: "0.050", side: "sell",
    status: "canceled", symbol: "ETHBTC", timeInForce: "GTC", type: "limit",
    updatedAt: "2017-11-07T12:02:41.518Z"}]}
Link to this function cancel_order(clientOrderId) View Source
cancel_order(String.t()) :: {:ok, map()} | {:error, term()}

Close order with given clientOrderId

Example:

Or with non existing order

iex(1)> Hitbtc.Trading.cancel_order("fe423a1615d6429dafa6549780615155")
{:error, %{code: 20002, description: "", message: "Order not found"}}
Link to this function get_order(clientOrderId) View Source
get_order(String.t()) :: {:ok, map()} | {:error, term()}

Load details of your order

Example

iex(1)> Hitbtc.Trading.get_order("fe423a1615d6429dafa6549780615155")
{:ok,
  %{clientOrderId: "fe423a1615d6429dafa6549780615155",
    createdAt: "2017-10-26T05:47:22.520Z", cumQuantity: "0.000",
    id: "4645665806", price: "1.000000", quantity: "0.050", side: "sell",
    status: "new", symbol: "ETHBTC", timeInForce: "GTC", type: "limit",
    updatedAt: "2017-10-26T05:47:22.520Z"}}

Or error if something wrong with order:

iex(1)> Hitbtc.Trading.get_order("fe423a1615d6429dafa654978061515")
{:error, %{code: 20002, description: "", message: "Order not found"}}
Link to this function order(symbol \\ "") View Source
order(String.t()) :: {:ok, [map()]} | {:error, term()}

List of your current orders

Example:

iex(1)> Hitbtc.Trading.order()
{:ok,
  [%{clientOrderId: "fe423a1615d6429dafa6549780615155",
    createdAt: "2017-10-26T05:47:22.520Z", cumQuantity: "0.000",
    id: "4645665806", price: "1.000000", quantity: "0.050", side: "sell",
    status: "new", symbol: "ETHBTC", timeInForce: "GTC", type: "limit",
    updatedAt: "2017-10-26T05:47:22.520Z"}]}

Or with specified symbol:

iex(10)> Hitbtc.Trading.order("BTGUSD")
{:ok, []}

In case of error function will return an error message:

iex(6)> Hitbtc.Trading.order("ETHADT")
{:error,
  %{code: 2001,
    description: "Try get /api/2/public/symbol, to get list of all available symbols.",
    message: "Symbol not found"}}
Link to this function trading_balance() View Source
trading_balance() :: {:ok, [map()]} | {:error, term()}

Get list of your trading balance

Example

iex(1)> Hitbtc.Trading.trading_balance
{:ok,
  [%{available: "0", currency: "1ST", reserved: "0"},
   %{available: "0", currency: "8BT", reserved: "0"},
   %{available: "0", currency: "ADX", reserved: "0"},
   %{available: "0", currency: "DASH", reserved: "0"},
   %{available: "0", currency: "DCN", reserved: "0"},
   %{available: "0", currency: "DCT", reserved: "0"},
   %{available: "0", currency: "DDF", reserved: "0"},
   %{available: "0", currency: "DLT", ...}, %{available: "0", ...}, %{...}, ...]}
Link to this function trading_fee(symbol) View Source
trading_fee(String.t()) :: {:ok, map()} | {:error, term()}

Get trading fee for given symbol

Example

iex(1)> Hitbtc.Trading.trading_fee("ETHBTC")
{:ok, %{provideLiquidityRate: "-0.0001", takeLiquidityRate: "0.001"}}