BinanceApi (binance_api v0.2.10) View Source

This library interacts with binance in a very simple way and doesn't make attempts to deserialize the results of the api into a struct.

To utilize this library we need to first set up some configuration

Config

config :binance_api,
  api_key: "<BINANCE_API_KEY>", # required
  secret_key: "<BINANCE_SECRET_KEY>", # required
  base_url: "https://api.binance.com" # default,
  secure_receive_window: 5_000 # default,

  request: [
    pool_timeout: 5_000 # default,
    receive_timeout: 15_000 # default
  ]

Options

For all requests we can provide the same options to override any of the default config, however it's not required to pass them at all as long as the config is set

  • :secured? - The default value is false.

  • :secret_key - The default value is nil.

  • :api_key - The default value is nil.

  • :base_futures_url - The default value is "https://fapi.binance.com".

  • :base_url - The default value is "https://api.binance.com".

  • :secure_receive_window - The default value is 5000.

  • :pool_timeout - The default value is 5000.

  • :receive_timeout - The default value is 15000.

Link to this section Summary

Functions

Get account details

Get all active all orders

Cancels an order for a specific symbol by the order_id

Cancels an order for a specific symbol by the order_id

Cancels an order for a specific symbol by the order_id

Get all active open orders

Get all active open orders for a specific symbol

Ping Binance servers to get pong

Opens and order in binance futures (See BinanceApi.Order.Builder)

Get the last price for a ticker

Server time from Binance

Get all active all orders

Cancels an order for a specific symbol by the order_id

Cancels an order for a specific symbol by the order_id

Get all active open orders

Get all active open orders for a specific symbol

Ping Binance servers to get pong

Get the last price for a ticker

Link to this section Functions

Specs

Get account details

Link to this function

exchange_info(opts \\ [])

View Source

Specs

Exchange info

Link to this function

futures_all_orders(opts \\ [])

View Source

Specs

futures_all_orders(BinanceApi.HTTP.opts()) :: BinanceApi.HTTP.res_multi()

Get all active all orders

Link to this function

futures_cancel_open_orders(symbol, opts \\ [])

View Source

Specs

futures_cancel_open_orders(symbol :: String.t(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res()

Cancels an order for a specific symbol by the order_id

Link to this function

futures_cancel_order(symbol, order_id, opts \\ [])

View Source

Specs

futures_cancel_order(
  symbol :: String.t(),
  order_id :: String.t(),
  BinanceApi.HTTP.opts()
) :: BinanceApi.HTTP.res_single()

Cancels an order for a specific symbol by the order_id

Link to this function

futures_cancel_orders(symbol, order_ids, opts \\ [])

View Source

Specs

futures_cancel_orders(
  symbol :: String.t(),
  order_ids :: [non_neg_integer()],
  BinanceApi.HTTP.opts()
) :: BinanceApi.HTTP.res_single()

Cancels an order for a specific symbol by the order_id

Link to this function

futures_open_orders(opts \\ [])

View Source

Specs

futures_open_orders(BinanceApi.HTTP.opts()) :: BinanceApi.HTTP.res_multi()

Get all active open orders

Link to this function

futures_open_orders_by_symbol(symbol, opts \\ [])

View Source

Specs

futures_open_orders_by_symbol(symbol :: String.t(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_multi()

Get all active open orders for a specific symbol

Link to this function

futures_ping(opts \\ [])

View Source

Specs

futures_ping(BinanceApi.HTTP.opts()) :: :pong | BinanceApi.HTTP.error()

Ping Binance servers to get pong

Link to this function

futures_place_order(symbol, opts \\ [])

View Source

Specs

futures_place_order(params :: map(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_single()

Opens and order in binance futures (See BinanceApi.Order.Builder)

Link to this function

futures_place_orders(symbol, opts \\ [])

View Source

Specs

futures_place_orders(params_list :: [map()], BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_single()

Opens batch orders in binance (See BinanceApi.Order.Builder)

Link to this function

futures_ticker_price(symbol, opts \\ [])

View Source

Specs

futures_ticker_price(symbol :: String.t(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_single()

Get the last price for a ticker

Specs

Server time from Binance

Link to this function

spot_all_orders(opts \\ [])

View Source

Specs

Get all active all orders

Link to this function

spot_cancel_open_orders(symbol, opts \\ [])

View Source

Specs

spot_cancel_open_orders(symbol :: String.t(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res()

Cancels an order for a specific symbol by the order_id

Link to this function

spot_cancel_order(symbol, order_id, opts \\ [])

View Source

Specs

spot_cancel_order(
  symbol :: String.t(),
  order_id :: String.t(),
  BinanceApi.HTTP.opts()
) :: BinanceApi.HTTP.res_single()

Cancels an order for a specific symbol by the order_id

Link to this function

spot_open_orders(opts \\ [])

View Source

Specs

Get all active open orders

Link to this function

spot_open_orders_by_symbol(symbol, opts \\ [])

View Source

Specs

spot_open_orders_by_symbol(symbol :: String.t(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_multi()

Get all active open orders for a specific symbol

Specs

spot_ping(BinanceApi.HTTP.opts()) :: :pong | BinanceApi.HTTP.error()

Ping Binance servers to get pong

Link to this function

spot_place_order(symbol, opts \\ [])

View Source

Specs

spot_place_order(params :: map(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_single()

Opens and order in binance see: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade

Can also use BinanceApi.Order.Builder

Link to this function

spot_place_orders(symbol, opts \\ [])

View Source

Specs

spot_place_orders(params_list :: [map()], BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_single()

Opens batch orders in binance, see: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade

Link to this function

spot_ticker_price(symbol, opts \\ [])

View Source

Specs

spot_ticker_price(symbol :: String.t(), BinanceApi.HTTP.opts()) ::
  BinanceApi.HTTP.res_single()

Get the last price for a ticker

Link to this function

system_status(opts \\ [])

View Source

Specs

System status