BinanceFutures.USDM.MarketData (Binance Futures API v0.1.1) 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. Current exchange trading rules and symbol information

Gets older market historical trades.

Gets Composite Index Symbol Information.

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 the BLVT NAV system is based on Binance Futures, so the endpoint is based on fapi.

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.

Gets present open interest of a specific symbol.

Tests API Connectivity.

Gets Binance Futures API Server time. Test connectivity to the Rest API and get the current server time.

Gets 24hr Ticker Price Change Statistics.

Gets Symbol Order Book Ticker.

Best price/qty on the order book for a symbol or symbols.

Gets Symbol Price Ticker. Latest price for a symbol or symbols.

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

all_force_orders(symbol \\ nil, start_time \\ nil, end_time \\ nil, limit \\ 100)

View Source

Specs

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

Gets all Liquidation Orders.

If the symbol is not sent, liquidation orders for all symbols will be returned. The query time period must be within the recent 7 days.

Example

iex(1)> BinanceFutures.USDM.MarketData.all_force_orders("BTCUSDT", nil, nil, 1)
{:ok,
[
  %{
    "averagePrice" => "56560.35",
    "executedQty" => "0.002",
    "origQty" => "0.002",
    "price" => "56316.25",
    "side" => "SELL",
    "status" => "FILLED",
    "symbol" => "BTCUSDT",
    "time" => 1616438506969,
    "timeInForce" => "IOC",
    "type" => "LIMIT"
  }
]}
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. 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

global_long_short_account_ratio(symbol, interval, start_time \\ nil, end_time \\ nil, limit \\ 30)

View Source

Specs

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

Gets global Long/Short Ratio.

If startTime and endTime are not sent, the most recent data is returned. Only the data of the latest 30 days is available.

Example

iex(1)> BinanceFutures.USDM.MarketData.global_long_short_account_ratio("BTCUSDT", "5m", nil, nil, 1)
{:ok,
[
  %{
    "longAccount" => "0.7895",
    "longShortRatio" => "3.7506",
    "shortAccount" => "0.2105",
    "symbol" => "BTCUSDT",
    "timestamp" => 1616439600000
  }
]}
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_info(symbol \\ nil)

View Source

Specs

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

Gets Composite Index Symbol Information.

Only for composite index symbols.

Example

iex(1)> BinanceFutures.USDM.MarketData.index_info("DEFIUSDT")
{:ok,
%{
  "baseAssetList" => [
    %{
      "baseAsset" => "1INCH",
      "weightInPercentage" => "0.03031300",
      "weightInQuantity" => "16.58633812"
    },
    %{
      "baseAsset" => "AAVE",
      "weightInPercentage" => "0.05795000",
      "weightInQuantity" => "0.40345195"
    },
    ...
    %{
      "baseAsset" => "ZRX",
      "weightInPercentage" => "0.02559600",
      "weightInQuantity" => "42.58378099"
    }
  ],
  "symbol" => "DEFIUSDT",
  "time" => 1616440368000
}}
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

lvt_klines(symbol, interval, start_time \\ nil, end_time \\ nil, limit \\ 30)

View Source

Specs

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

Gets the BLVT NAV system is based on Binance Futures, so the endpoint is based on fapi.

Symbol here is not as everywhere. Here symbol means TOKEN_NAME + DOWN|UP Example: BTCDOWN or BTCUP

Example

iex(1)> BinanceFutures.USDM.MarketData.lvt_klines("BTCDOWN", "5m", nil, nil, 1)
{:ok,
[
  [1616439900000, "0.05134788", "0.05217493", "0.05113578", "0.05186245",
    "2.56527976", 1616440199999, "0", 274, "703.56900864", "0", "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

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

Gets present open interest of a specific symbol.

Example

iex(1)> BinanceFutures.USDM.MarketData.open_interest("BTCUSDT")
{:ok,
%{
  "openInterest" => "33877.933",
  "symbol" => "BTCUSDT",
  "time" => 1616438337232
}}
Link to this function

open_interest_hist(symbol, interval \\ nil, start_time \\ nil, end_time \\ nil, limit \\ 30)

View Source

Specs

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

Gets Open Interest Statistics.

If startTime and endTime are not sent, the most recent data is returned. Only the data of the latest 30 days is available.

Example

iex(1)> BinanceFutures.USDM.MarketData.open_interest_hist("BTCUSDT", "5m", nil, nil, 1)
{:ok,
[
  %{
    "sumOpenInterest" => "34085.00000000",
    "sumOpenInterestValue" => "1927265695.27131325",
    "symbol" => "BTCUSDT",
    "timestamp" => 1616438700000
  }
]}

Specs

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

Tests API Connectivity.

Weight: 1

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. Test connectivity to the Rest API and get the current server time.

Example

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

taker_long_short_ratio(symbol, interval, start_time \\ nil, end_time \\ nil, limit \\ 30)

View Source

Specs

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

Gets Taker Long/Short Ratio.

If startTime and endTime are not sent, the most recent data is returned. Only the data of the latest 30 days is available.

Example

iex(1)> BinanceFutures.USDM.MarketData.taker_long_short_ratio("BTCUSDT", "5m", nil, nil, 1)
{:ok,
[
  %{
    "buySellRatio" => "1.1603",
    "buyVol" => "298.2800",
    "sellVol" => "257.0660",
    "timestamp" => 1616439300000
  }
]}
Link to this function

ticker_24h(symbol \\ nil)

View Source

Specs

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

Gets 24hr Ticker Price Change Statistics.

24 hour rolling window price change statistics. Careful when accessing this with no symbol (has very big weight).

If the symbol is not sent, tickers for all symbols will be returned in an array.

Example

iex(1)> BinanceFutures.USDM.MarketData.ticker_24h("BTCUSDT")
{:ok,
%{
  "closeTime" => 1616437801503,
  "count" => 2829671,
  "firstId" => 626470086,
  "highPrice" => "58500.00",
  "lastId" => 629299761,
  "lastPrice" => "57028.37",
  "lastQty" => "0.025",
  "lowPrice" => "56243.00",
  "openPrice" => "57325.02",
  "openTime" => 1616351400000,
  "priceChange" => "-296.65",
  "priceChangePercent" => "-0.517",
  "quoteVolume" => "13059748167.78",
  "symbol" => "BTCUSDT",
  "volume" => "227696.666",
  "weightedAvgPrice" => "57355.90"
}}
Link to this function

ticker_book(symbol \\ nil)

View Source

Specs

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

Gets Symbol Order Book Ticker.

Best price/qty on the order book for a symbol or symbols.

If the symbol is not sent, bookTickers for all symbols will be returned in an array.

Example

iex(7)> BinanceFutures.USDM.MarketData.ticker_book("BTCUSDT")
{:ok,
%{
  "askPrice" => "56685.27",
  "askQty" => "0.077",
  "bidPrice" => "56683.18",
  "bidQty" => "1.392",
  "symbol" => "BTCUSDT",
  "time" => 1616438105137
}}
Link to this function

ticker_price(symbol \\ nil)

View Source

Specs

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

Gets Symbol Price Ticker. Latest price for a symbol or symbols.

If the symbol is not sent, prices for all symbols will be returned in an array.

Example

iex(1)> BinanceFutures.USDM.MarketData.ticker_price("BTCUSDT")
{:ok, %{"price" => "56832.56", "symbol" => "BTCUSDT", "time" => 1616437944238}}
Link to this function

top_long_short_account_ratio(symbol, interval, start_time \\ nil, end_time \\ nil, limit \\ 30)

View Source

Specs

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

Gets Top Trader Long/Short Ratio (Accounts).

If startTime and endTime are not sent, the most recent data is returned. Only the data of the latest 30 days is available.

Example

iex(1)> BinanceFutures.USDM.MarketData.top_long_short_account_ratio("BTCUSDT", "5m", nil, nil, 1)
{:ok,
[
  %{
    "longAccount" => "0.7739",
    "longShortRatio" => "3.4228",
    "shortAccount" => "0.2261",
    "symbol" => "BTCUSDT",
    "timestamp" => 1616439000000
  }
]}
Link to this function

top_long_short_position_ratio(symbol, interval, start_time \\ nil, end_time \\ nil, limit \\ 30)

View Source

Specs

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

Gets Top Trader Long/Short Ratio (Positions).

If startTime and endTime are not sent, the most recent data is returned. Only the data of the latest 30 days is available.

Example

iex(1)> BinanceFutures.USDM.MarketData.top_long_short_position_ratio("BTCUSDT", "5m", nil, nil, 1)
{:ok,
  [
    %{
      "longAccount" => "0.5482",
      "longShortRatio" => "1.2131",
      "shortAccount" => "0.4518",
      "symbol" => "BTCUSDT",
      "timestamp" => 1616439300000
    }
  ]}