BinanceFutures.USDM.MarketData (Binance Futures API v0.1.0) View Source

List of Market Data REST API's.

Link to this section Summary

Functions

Gets compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.

Gets continuous Kline/candlestick bars for a specific contract type. Klines are uniquely identified by their open time.

Gets Order Book.

Gets current exchange trading rules and symbol information.

Gets older market historical trades.

Gets Kline/candlestick bars for the index price of a pair. Klines are uniquely identified by their open time.

Gets Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

Gets Mark Price and Funding Rate If no symbol provided, prices for all symbols will be returned.

Gets Kline/candlestick bars for the mark price of a symbol. Klines are uniquely identified by their open time.

Tests API Connectivity.

Gets Binance Futures API Server time.

Link to this section Functions

Link to this function

aggregate_trades(symbol, from_id \\ nil, start_time \\ nil, end_time \\ nil, limit \\ 500)

View Source

Specs

aggregate_trades(
  binary(),
  nil | pos_integer(),
  nil | pos_integer(),
  nil | pos_integer(),
  pos_integer()
) :: {:ok, [map()]} | BinanceFutures.HTTPClient.error()

Gets compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.

Example

iex(1)> BinanceFutures.USDM.MarketData.aggregate_trades("BTCUSDT", nil, nil, nil, 2)
{:ok,
[
  %{
    "T" => 1616338617973,
    "a" => 391916312,
    "f" => 626090468,
    "l" => 626090468,
    "m" => false,
    "p" => "57215.00",
    "q" => "0.002"
  },
  %{
    "T" => 1616338618243,
    "a" => 391916313,
    "f" => 626090469,
    "l" => 626090469,
    "m" => false,
    "p" => "57215.00",
    "q" => "0.030"
  }
]}
Link to this function

continuous_klines(pair, contract_type, interval, start_time \\ nil, end_time \\ nil, limit \\ 500)

View Source

Specs

Gets continuous Kline/candlestick bars for a specific contract type. Klines are uniquely identified by their open time.

Contract types available:

  • PERPETUAL
  • CURRENT_MONTH
  • NEXT_MONTH

Example

iex(1)> BinanceFutures.USDM.MarketData.continuous_klines("BTCUSDT", "PERPETUAL", "5m", nil, nil, 2)
{:ok,
[
  [1616340000000, "57480.91", "57490.00", "57372.26", "57405.05", "571.101",
    1616340299999, "32796220.87635", 9024, "241.532", "13870331.23961", "0"],
  [1616340300000, "57405.05", "57430.00", "57350.00", "57385.99", "458.456",
    1616340599999, "26307719.07498", 6574, "198.989", "11419479.03403", "0"]
]}
Link to this function

depth(symbol, limit \\ 500)

View Source

Specs

Gets Order Book.

Example

iex(1)> BinanceFutures.USDM.MarketData.depth("BTCUSDT")
{:ok,
%{
  "E" => 1616333020858,
  "T" => 1616333020851,
  "asks" => [
    ["56865.63", "3.972"],
    ["56865.64", "0.023"],
    ["56882.96", ...],
    [...],
    ...
  ],
  "bids" => [
    ["56865.62", "0.501"],
    ["56865.00", "0.003"],
    ["56862.63", "0.088"],
    ["56851.92", ...],
    [...],
    ...
  ],
  "lastUpdateId" => 272144015637
}}

Specs

exchange_info() :: {:ok, map()} | BinanceFutures.HTTPClient.error()

Gets current exchange trading rules and symbol information.

Example

iex(1)> BinanceFutures.USDM.MarketData.exchange_info
{:ok,
  %{
    "exchangeFilters" => [],
    "futuresType" => "U_MARGINED",
    "rateLimits" => [
      %{
        "interval" => "MINUTE",
        "intervalNum" => 1,
        "limit" => 2400,
        "rateLimitType" => "REQUEST_WEIGHT"
      },
      %{
        "interval" => "MINUTE",
        "intervalNum" => 1,
        "limit" => 1200,
        "rateLimitType" => "ORDERS"
      },
      %{
        "interval" => "SECOND",
        "intervalNum" => 10,
        "limit" => 300,
        "rateLimitType" => "ORDERS"
      }
    ],
    "serverTime" => 1616348890107,
    ...
    "timezone" => "UTC"
}}
Link to this function

funding_rate(symbol \\ nil, start_time \\ nil, end_time \\ nil, limit \\ 500)

View Source

Specs

funding_rate(
  nil | binary(),
  nil | pos_integer(),
  nil | pos_integer(),
  pos_integer()
) :: {:ok, map()} | {:ok, [map()]} | BinanceFutures.HTTPClient.error()

Gets Funding Rate History.

Additional API details:

  • If startTime and endTime are not sent, the most recent limit datas are returned.
  • If the number of data between startTime and endTime is larger than limit, return as startTime + limit.
  • In ascending order.

If symbol will be omitted rates for all symbols will be returned.

Example

iex(3)> BinanceFutures.USDM.MarketData.funding_rate("BNBUSDT")
{:ok,
[
  %{
    "fundingRate" => "-0.00149526",
    "fundingTime" => 1601971200005,
    "symbol" => "BNBUSDT"
  },
  %{
    "fundingRate" => "-0.00081215",
    "fundingTime" => 1602000000000,
    "symbol" => "BNBUSDT"
  },
  %{"fundingRate" => "0.00000000", "fundingTime" => 1603267200004, ...},
  %{"fundingRate" => "0.00000000", ...},
  %{...},
  ...
]}
Link to this function

historical_trades(symbol, from_id \\ nil, limit \\ 500)

View Source

Specs

historical_trades(binary(), nil | pos_integer(), pos_integer()) ::
  {:ok, [map()]} | BinanceFutures.HTTPClient.error()

Gets older market historical trades.

Example

iex(1)> BinanceFutures.USDM.MarketData.historical_trades("BTCUSDT", nil, 2)
{:ok,
[
  %{
    "id" => 626078533,
    "isBuyerMaker" => false,
    "price" => "57267.94",
    "qty" => "0.001",
    "quoteQty" => "57.26",
    "time" => 1616338040822
  },
  %{
    "id" => 626078534,
    "isBuyerMaker" => true,
    "price" => "57263.20",
    "qty" => "0.010",
    "quoteQty" => "572.63",
    "time" => 1616338040920
  }
]}
Link to this function

index_price_klines(pair, interval, start_time \\ nil, end_time \\ nil, limit \\ 500)

View Source

Specs

index_price_klines(
  binary(),
  BinanceFutures.interval(),
  nil | pos_integer(),
  nil | pos_integer(),
  pos_integer()
) :: {:ok, [list()]} | BinanceFutures.HTTPClient.error()

Gets Kline/candlestick bars for the index price of a pair. Klines are uniquely identified by their open time.

Example

iex(1)> BinanceFutures.USDM.MarketData.index_price_klines("BTCUSDT", "5m", nil, nil, 2)
{:ok,
[
  [1616340600000, "57366.98431599", "57429.73139441", "57284.92735200",
    "57284.92735200", "0", 1616340899999, "0", 300, "0", "0", "0"],
  [1616340900000, "57283.26395200", "57294.43035200", "57224.03776400",
    "57265.85639717", "0", 1616341199999, "0", 89, "0", "0", "0"]
]}
Link to this function

klines(symbol, interval, start_time \\ nil, end_time \\ nil, limit \\ 500)

View Source

Specs

Gets Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

Example

iex(1)> BinanceFutures.USDM.MarketData.klines("BTCUSDT", "5m", nil, nil, 2)
{:ok,
[
  [1616338800000, "57212.69", "57315.00", "57196.19", "57300.00", "496.263",
    1616339099999, "28425514.78940", 7160, "273.108", "15642623.69718", "0"],
  [1616339100000, "57300.00", "57300.00", "57200.61", "57206.47", "174.865",
    1616339399999, "10009130.07051", 2602, "60.409", "3457649.49072", "0"]
]}
Link to this function

mark_price(symbol \\ nil)

View Source

Specs

mark_price(nil | binary()) ::
  {:ok, map()} | {:ok, [map()]} | BinanceFutures.HTTPClient.error()

Gets Mark Price and Funding Rate If no symbol provided, prices for all symbols will be returned.

Example

iex(1)> BinanceFutures.USDM.MarketData.mark_price("BTCUSDT")
{:ok,
%{
  "estimatedSettlePrice" => "57311.26556567",
  "indexPrice" => "57299.56815703",
  "interestRate" => "0.00010000",
  "lastFundingRate" => "0.00010000",
  "markPrice" => "57325.76000000",
  "nextFundingTime" => 1616342400000,
  "symbol" => "BTCUSDT",
  "time" => 1616341403005
}}
iex(2)> BinanceFutures.USDM.MarketData.mark_price()
{:ok,
[
  %{
    "estimatedSettlePrice" => "18.99792722",
    "indexPrice" => "18.98676895",
    "interestRate" => "0.00010000",
    "lastFundingRate" => "0.00036359",
    "markPrice" => "18.99830000",
    "nextFundingTime" => 1616342400000,
    "symbol" => "SUSHIUSDT",
    "time" => 1616341422000
  },
  %{
      "estimatedSettlePrice" => "2.71120145",
      "indexPrice" => "2.69011741",
      "interestRate" => "0.00010000",
      ...
    },
    %{
      "estimatedSettlePrice" => "196.26837596",
      "indexPrice" => "196.02526316",
      ...
    },
    %{"estimatedSettlePrice" => "3.96997638", ...},
    %{...},
    ...
  ]}
Link to this function

mark_price_klines(symbol, interval, start_time \\ nil, end_time \\ nil, limit \\ 500)

View Source

Specs

mark_price_klines(
  binary(),
  BinanceFutures.interval(),
  nil | pos_integer(),
  nil | pos_integer(),
  pos_integer()
) :: {:ok, [list()]} | BinanceFutures.HTTPClient.error()

Gets Kline/candlestick bars for the mark price of a symbol. Klines are uniquely identified by their open time.

Example

iex(1)> BinanceFutures.USDM.MarketData.mark_price_klines("BTCUSDT", "5m", nil, nil, 2)
{:ok,
[
  [1616340900000, "57302", "57319.11709042", "57185.40000000",
    "57247.46000000", "0", 1616341199999, "0", 300, "0", "0", "0"],
  [1616341200000, "57240", "57311.07657677", "57240", "57307.87695491", "0",
    1616341499999, "0", 53, "0", "0", "0"]
]}

Specs

ping() :: {:ok, map()} | BinanceFutures.HTTPClient.error()

Tests API Connectivity.

Example

iex(1)> BinanceFutures.USDM.MarketData.ping()
{:ok, %{}}
Link to this function

recent_trades(symbol, limit \\ 500)

View Source

Specs

recent_trades(binary(), pos_integer()) ::
  {:ok, [map()]} | BinanceFutures.HTTPClient.error()

Gets recent trades.

Example

iex(1)> BinanceFutures.USDM.MarketData.recent_trades("BTCUSDT", 2)
{:ok,
[
  %{
    "id" => 625947549,
    "isBuyerMaker" => true,
    "price" => "57080.03",
    "qty" => "0.100",
    "quoteQty" => "5708.00",
    "time" => 1616333975439
  },
  %{
    "id" => 625947550,
    "isBuyerMaker" => true,
    "price" => "57080.03",
    "qty" => "0.011",
    "quoteQty" => "627.88",
    "time" => 1616333975579
  }
]}

Specs

server_time() :: {:ok, pos_integer()} | BinanceFutures.HTTPClient.error()

Gets Binance Futures API Server time.

Example

iex(1)> BinanceFutures.USDM.MarketData.server_time()
{:ok, 1616276229598}