Market data

Get orderbooks and prices from the binance API

Order book

Get orderbook for a specific symbol.

Weight: Adjusted based on the limit:

Code

await client.fetch_order_book(symbol, limit=100)

symbol must be provided. limit should be 5, 10, 20, 50, 100, 500, 1000 or 5000.

Response

{
  "lastUpdateId": 1027024,
  "bids": [
    [
      "4.00000000",     // PRICE
      "431.00000000"    // QTY
    ]
  ],
  "asks": [
    [
      "4.00000200",
      "12.00000000"
    ]
  ]
}

Recent trades list

Get recent trades (up to last 1000).

Weight: 1

Code

await client.fetch_recent_trades_list(symbol, limit=500)

symbol must be provided. limit should be inferior to 1000.

Response

[
  {
    "id": 28457,
    "price": "4.00000100",
    "qty": "12.00000000",
    "quoteQty": "48.000012",
    "time": 1499865549590,
    "isBuyerMaker": true,
    "isBestMatch": true
  }
]

Old trade lookup (MARKET_DATA)

Get older trades.

Weight: 5

Code

await client.fetch_old_trades_list(symbol, from_id=None, limit=500)

symbol must be provided. from_id is the tradeId to fetch from. Default gets most recent trades. limit should be inferior to 1000.

Response

[
  {
    "id": 28457,
    "price": "4.00000100",
    "qty": "12.00000000",
    "quoteQty": "48.000012",
    "time": 1499865549590,
    "isBuyerMaker": true,
    "isBestMatch": true
  }
]

Compressed/Aggregate trades list

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

Weight: 1

Code

await client.fetch_aggregate_trades_list(symbol, from_id=None, start_time=None, end_time=None, limit=500)

symbol must be provided fromId is the tradeId to get aggregate trades from (INCLUSIVE). start_time is the timestamp in ms to get aggregate trades from (INCLUSIVE) end_time is the timestamp in ms to get aggregate trades until (INCLUSIVE). limit should be inferior to 1000.

Response

[
  {
    "id": 28457,
    "price": "4.00000100",
    "qty": "12.00000000",
    "quoteQty": "48.000012",
    "time": 1499865549590,
    "isBuyerMaker": true,
    "isBestMatch": true
  }
]

Kline/Candlestick data

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

Weight: 1

Code

await client.fetch_klines(symbol, interval, start_time=None, end_time=None, limit=500)

symbol must be provided. interval is an Interval enum. start_time is not mandatory. end_time is not mandatory. limit should be inferior to 1000.

Response

[
  [
    1499040000000,      // Open time
    "0.01634790",       // Open
    "0.80000000",       // High
    "0.01575800",       // Low
    "0.01577100",       // Close
    "148976.11427815",  // Volume
    1499644799999,      // Close time
    "2434.19055334",    // Quote asset volume
    308,                // Number of trades
    "1756.87402397",    // Taker buy base asset volume
    "28.46694368",      // Taker buy quote asset volume
    "17928899.62484339" // Ignore.
  ]
]

Current average price

Current average price for a symbol.

Weight: 1

Code

await client.fetch_average_price(symbol)

symbol must be provided.

Response

{
  "mins": 5,
  "price": "9.35751834"
}

24hr ticker price change statistics

24 hour rolling window price change statistics. Careful when accessing this with no symbol.

Weight: 1 for a single symbol; 40 when the symbol parameter is omitted

Code

await client.fetch_ticker_price_change_statistics(symbol)

symbol is not mandatory.

Response

{
  "symbol": "BNBBTC",
  "priceChange": "-94.99999800",
  "priceChangePercent": "-95.960",
  "weightedAvgPrice": "0.29628482",
  "prevClosePrice": "0.10002000",
  "lastPrice": "4.00000200",
  "lastQty": "200.00000000",
  "bidPrice": "4.00000000",
  "askPrice": "4.00000200",
  "openPrice": "99.00000000",
  "highPrice": "100.00000000",
  "lowPrice": "0.10000000",
  "volume": "8913.30000000",
  "quoteVolume": "15.30000000",
  "openTime": 1499783499040,
  "closeTime": 1499869899040,
  "firstId": 28385,   // First tradeId
  "lastId": 28460,    // Last tradeId
  "count": 76         // Trade count
}

or

[
  {
    "symbol": "BNBBTC",
    "priceChange": "-94.99999800",
    "priceChangePercent": "-95.960",
    "weightedAvgPrice": "0.29628482",
    "prevClosePrice": "0.10002000",
    "lastPrice": "4.00000200",
    "lastQty": "200.00000000",
    "bidPrice": "4.00000000",
    "askPrice": "4.00000200",
    "openPrice": "99.00000000",
    "highPrice": "100.00000000",
    "lowPrice": "0.10000000",
    "volume": "8913.30000000",
    "quoteVolume": "15.30000000",
    "openTime": 1499783499040,
    "closeTime": 1499869899040,
    "firstId": 28385,   // First tradeId
    "lastId": 28460,    // Last tradeId
    "count": 76         // Trade count
  }
]

Symbol price ticker

Latest price for a symbol or symbols.

Weight: 1 for a single symbol; 2 when the symbol parameter is omitted

Code

await client.fetch_symbol_price_ticker(symbol)

symbol is not mandatory.

Response

{
  "symbol": "LTCBTC",
  "price": "4.00000200"
}

or

[
  {
    "symbol": "LTCBTC",
    "price": "4.00000200"
  },
  {
    "symbol": "ETHBTC",
    "price": "0.07946600"
  }
]

Symbol order book ticker

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

Weight: 1 for a single symbol; 2 when the symbol parameter is omittedCode

await client.fetch_symbol_order_book_ticker(symbol)

symbol is not mandatory.

Response

{
  "symbol": "LTCBTC",
  "bidPrice": "4.00000000",
  "bidQty": "431.00000000",
  "askPrice": "4.00000200",
  "askQty": "9.00000000"
}

or

[
  {
    "symbol": "LTCBTC",
    "bidPrice": "4.00000000",
    "bidQty": "431.00000000",
    "askPrice": "4.00000200",
    "askQty": "9.00000000"
  },
  {
    "symbol": "ETHBTC",
    "bidPrice": "0.07946700",
    "bidQty": "9.00000000",
    "askPrice": "100000.00000000",
    "askQty": "1000.00000000"
  }
]

Last updated