Skip to content

USDT M Futures

andrea-c-binance edited this page Dec 9, 2021 · 3 revisions

binance.futures package

binance.futures.account module


binance.futures.account.account(self, **kwargs)

Account Information V2 (USER_DATA)

Get current account information

API endpoint

GET /fapi/v2/account

API doc

https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data

Parameters

  • recvWindow – optional int

binance.futures.account.adl_quantile(self, **kwargs)

Position ADL Quantile Estimation (USER_DATA)

Get Position ADL Quantile Estimation

API endpoint

GET /fapi/v1/adlQuantile

API doc

https://binance-docs.github.io/apidocs/futures/en/#position-adl-quantile-estimation-user_data

Parameters

  • symbol – optional string

  • recvWindow – optional int

Notes

  • Values update every 30s.

  • Values 0, 1, 2, 3, 4 shows the queue position and possibility of ADL from low to high.

  • For positions of the symbol are in One-way Mode or isolated margined in Hedge Mode, “LONG”, “SHORT”, and “BOTH” will be returned to show the positions’ adl quantiles of different position sides.

  • If the positions of the symbol are crossed margined in Hedge Mode:

    • “HEDGE” as a sign will be returned instead of “BOTH”
  • A same value caculated on unrealized pnls on long and short sides’ positions will be shown for “LONG” and “SHORT” when there are positions in both of long and short sides.


binance.futures.account.api_trading_status(self, **kwargs)

User API Trading Quantitative Rules Indicators (USER_DATA)

Get User API Trading Quantitative Rules Indicators

API endpoint

GET /fapi/v1/apiTradingStatus

API doc

https://binance-docs.github.io/apidocs/futures/en/#user-api-trading-quantitative-rules-indicators-user_data

Parameters

  • symbol – optional string

  • recvWindow – optional int


binance.futures.account.balance(self, **kwargs)

Futures Account Balance V2 (USER_DATA)

Get current account balance

API endpoint

GET /fapi/v2/balance

API doc

https://binance-docs.github.io/apidocs/futures/en/#futures-account-balance-v2-user_data

Parameters

recvWindow – optional int


binance.futures.account.cancel_batch_order(self, symbol: str, orderIdList: list, origClientOrderIdList: list, **kwargs)

Cancel Multiple Orders (TRADE)

Cancel a new batch order

API endpoint

DELETE /fapi/v1/batchOrders

API doc

https://binance-docs.github.io/apidocs/futures/en/#cancel-multiple-orders-trade

Parameters

  • symbol – string

  • orderIdList – int list; max length 10 e.g. [1234567, 2345678]

  • origClientOrderIdList – string list; max length 10 e.g. [“my_id_1”, “my_id_2”], encode the double quotes. No space after comma.

  • recvWindow – optional int

Notes

  • Either orderIdList or origClientOrderIdList must be sent.

binance.futures.account.cancel_open_orders(self, symbol: str, **kwargs)

Cancel All Open Orders (TRADE)

API endpoint

DELETE /fapi/v1/allOpenOrders

API doc

https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-orders-trade

Parameters

  • symbol – string

  • recvWindow – optional int; the value cannot be greater than 60000.


binance.futures.account.cancel_order(self, symbol: str, orderId: Optional[int] = None, origClientOrderId: Optional[str] = None, **kwargs)

Cancel Order (TRADE)

Cancel an active order.

API endpoint

DELETE /fapi/v1/order

API doc

https://binance-docs.github.io/apidocs/futures/en/#cancel-order-trade

Parameters

  • symbol – string

  • orderId – optional int

  • origClientOrderId – optional string

  • newClientOrderId – optional string

  • recvWindow – optional int


binance.futures.account.change_leverage(self, symbol: str, leverage: int, **kwargs)

Change Initial Leverage (TRADE)

Change user’s initial leverage of specific symbol market.

API endpoint

POST /fapi/v1/leverage

API doc

https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade

Parameters

  • symbol – string

  • leverage – int; target initial leverage: int from 1 to 125.

  • recvWindow – optional int; the value cannot be greater than 60000.


binance.futures.account.change_margin_type(self, symbol: str, marginType: str, **kwargs)

Change margin type (TRADE)

Change user’s margin type of specific symbol market.

API endpoint

POST /fapi/v1/marginType

API doc

https://binance-docs.github.io/apidocs/futures/en/#change-margin-type-trade

Parameters

  • symbol – string

  • marginType – string; ISOLATED, CROSSED.

  • recvWindow – optional int; the value cannot be greater than 60000.


binance.futures.account.change_multi_asset_mode(self, multiAssetsMargin: str, **kwargs)

Change Multi-Assets Mode (TRADE)

Change user’s Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol

API endpoint

POST /fapi/v1/multiAssetsMargin

API doc

https://binance-docs.github.io/apidocs/futures/en/#change-multi-assets-mode-trade

Parameters

  • multiAssetsMargin – string; “true”: Multi-Assets Mode; “false”: Single-Asset Mode

  • recvWindow – optional int


binance.futures.account.change_position_mode(self, dualSidePosition: str, **kwargs)

Change Position Mode (TRADE)

Change user’s position mode (Hedge Mode or One-way Mode) on EVERY symbol

API endpoint

POST /fapi/v1/positionSide/dual

API doc

https://binance-docs.github.io/apidocs/futures/en/#change-position-mode-trade

Parameters

  • dualSidePosition – string

  • recvWindow – optional int


binance.futures.account.commission_rate(self, symbol: str, **kwargs)

User Commission Rate (USER_DATA)

Get commission rate of symbol

API endpoint

GET /fapi/v1/commissionRate

API doc

https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data

Parameters

  • symbol – string

  • recvWindow – optional int


binance.futures.account.countdown_cancel_order(self, symbol: str, countdownTime: int, **kwargs)

Auto-Cancel All Open Orders (TRADE)

Cancel all open orders of the specified symbol at the end of the specified countdown.

API endpoint

POST /fapi/v1/countdownCancelAll

API doc

https://binance-docs.github.io/apidocs/futures/en/#auto-cancel-all-open-orders-trade

Parameters

  • symbol – string

  • countdownTime – int list; countdown time, 1000 for 1 second. 0 to cancel the timer.

  • recvWindow – optional int

Notes

  • The endpoint should be called repeatedly as heartbeats so that the existing countdown time can be canceled and replaced by a new one.

  • Example usage:

    • Call this endpoint at 30s intervals with an countdownTime of 120000 (120s).

    • If this endpoint is not called within 120 seconds, all your orders of the specified symbol will be automatically canceled.

    • If this endpoint is called with an countdownTime of 0, the countdown timer will be stopped.

  • The system will check all countdowns approximately every 10 milliseconds, so please note that sufficient redundancy should be considered when using this function.

  • We do not recommend setting the countdown time to be too precise or too small.


binance.futures.account.force_orders(self, **kwargs)

User’s Force Orders (USER_DATA)

Get User’s Force Orders

API endpoint

GET /fapi/v1/forceOrders

API doc

https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data

Parameters

  • symbol – optional string

  • autoCloseType – optional string; “LIQUIDATION” for liquidation orders, “ADL” for ADL orders.

  • startTime – optional int

  • endTime – optional int

  • Limit – optional int; default 50, max 100.

  • recvWindow – optional int

Notes

  • If “autoCloseType” is not sent, orders with both of the types will be returned

  • If “startTime” is not sent, data within 7 days before “endTime” can be queried


binance.futures.account.get_account_trades(self, symbol: str, **kwargs)

Account Trade List (USER_DATA)

Get trades for a specific account and symbol.

API endpoint

GET /fapi/v1/userTrades

API doc

https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data

Parameters

  • symbol – string

  • startTime – optional int

  • endTime – optional int

  • fromId – optional int; trade ID to fetch from, default gets most recent trades.

  • limit – optional int; default: 500, max: 1000.

  • recvWindow – optional int

Notes

  • If startTime and endTime are both not sent, then the last 7 days’ data will be returned.

  • The time between startTime and endTime cannot be longer than 7 days.

  • The parameter fromId cannot be sent with startTime or endTime.


binance.futures.account.get_all_orders(self, symbol: str, **kwargs)

All Orders (USER_DATA)

Get all account orders; active, canceled, or filled.

API endpoint

GET /fapi/v1/allOrders

API doc

https://binance-docs.github.io/apidocs/futures/en/#all-orders-user_data

Parameters

  • symbol – string

  • orderId – optional int

  • startTime – optional int

  • endTime – optional int

  • limit – optional int

  • recvWindow – optional int; the value cannot be greater than 60000.


binance.futures.account.get_income_history(self, **kwargs)

Get Income History (USER_DATA)

Get trades for a specific account and symbol.

API endpoint

GET /fapi/v1/income

API doc

https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data

Parameters

  • symbol – optional string

  • incomeType – optional string; “TRANSFER”, “WELCOME_BONUS”, “REALIZED_PNL”, “FUNDING_FEE”, “COMMISSION” and “INSURANCE_CLEAR”.

  • startTime – optional int; timestamp in ms to get funding from INCLUSIVE.

  • endTime – optional int; timestamp in ms to get funding from INCLUSIVE.

  • limit – optional int; default: 100, max: 1000.

  • recvWindow – optional int

Notes

  • If neither startTime nor endTime is sent, the recent 7-day data will be returned.

  • If incomeType is not sent, all kinds of flow will be returned

  • “trandId” is unique in the same incomeType for a user


binance.futures.account.get_multi_asset_mode(self, **kwargs)

Get Current Multi-Assets Mode (USER_DATA)

Get user’s Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol

API endpoint

GET /fapi/v1/multiAssetsMargin

API doc

https://binance-docs.github.io/apidocs/futures/en/#get-current-multi-assets-mode-user_data

Parameters

  • recvWindow – optional int

binance.futures.account.get_open_orders(self, symbol: str, orderId: Optional[int] = None, origClientOrderId: Optional[str] = None, **kwargs)

Query Current Open Order (USER_DATA)

Get all open orders on a symbol.

API endpoint

GET /fapi/v1/openOrder

API doc

https://binance-docs.github.io/apidocs/futures/en/#query-current-open-order-user_data

Parameters

  • symbol – string

  • orderId – optional int

  • origClientOrderId – optional int

  • recvWindow – optional int; the value cannot be greater than 60000.

Notes

  • Either orderId or origClientOrderId must be sent

  • If the queried order has been filled or cancelled, the error message “Order does not exist” will be returned.


binance.futures.account.get_orders(self, **kwargs)

Current All Open Orders (USER_DATA)

Get all open orders on a symbol. Careful when accessing this with no symbol.

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

API endpoint

GET /fapi/v1/openOrders

API doc

https://binance-docs.github.io/apidocs/futures/en/#current-all-open-orders-user_data

Parameters

  • symbol – optional string

  • recvWindow – optional int; the value cannot be greater than 60000.


binance.futures.account.get_position_margin_history(self, symbol: str, **kwargs)

Get Position Margin Change History (TRADE)

Get position margin history on a symbol.

API endpoint

GET /fapi/v1/positionMargin/history

API doc

https://binance-docs.github.io/apidocs/futures/en/#get-position-margin-change-history-trade

Parameters

  • symbol – string

  • type – optional int; 1: Add position margin, 2: Reduce position margin.

  • startTime – optional int

  • endTime – optional int

  • limit – optional int; default: 500.

  • recvWindow – optional int


binance.futures.account.get_position_mode(self, **kwargs)

Get Current Position Mode (USER_DATA)

Get user’s position mode (Hedge Mode or One-way Mode) on EVERY symbol

API endpoint

GET /fapi/v1/positionSide/dual

API doc

https://binance-docs.github.io/apidocs/futures/en/#get-current-position-mode-user_data

Parameters

  • recvWindow – optional int

binance.futures.account.get_position_risk(self, **kwargs)

Position Information V2 (USER_DATA)

Get current position information.

API endpoint

GET /fapi/v2/positionRisk

API doc

https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data

Parameters

  • symbol – string

  • recvWindow – optional int


binance.futures.account.leverage_brackets(self, **kwargs)

Notional and Leverage Brackets (USER_DATA)

Get notional and leverage bracket.

API endpoint

GET /fapi/v1/leverageBracket

API doc

https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-user_data

Parameters

  • symbol – optional string

  • recvWindow – optional int


binance.futures.account.modify_isolated_position_margin(self, symbol: str, amount: float, type: int, **kwargs)

Modify Isolated Position Margin (TRADE)

API endpoint

POST /fapi/v1/positionMargin

API doc

https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade

Parameters

  • symbol – string

  • amount – float

  • type – int; 1: Add position margin, 2: Reduce position margin

  • positionSide – optional string; default BOTH for One-way Mode, LONG or SHORT for Hedge Mode. It must be sent with Hedge Mode.

  • recvWindow – optional int; the value cannot be greater than 60000.


binance.futures.account.new_batch_order(self, batchOrders: list)

Place Multiple Orders (TRADE)

Post a new batch order

API endpoint

POST /fapi/v1/batchOrders

API doc

https://binance-docs.github.io/apidocs/futures/en/#place-multiple-orders-trade

Parameters

  • symbol – string

  • side – string

  • type – string

  • positionSide – optional string. Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be passed in Hedge Mode.

  • timeInForce – optional string

  • quantity – optional float

  • reduceOnly – optional string

  • price – optional float

  • newClientOrderId – optional string. An unique ID among open orders. Automatically generated if not sent.

  • stopPrice – optional float. Use with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders.

  • closePosition – optional string. true or false; Close-All, use with STOP_MARKET or TAKE_PROFIT_MARKET.

  • activationPrice – optional float. Use with TRAILING_STOP_MARKET orders, default is the latest price (supporting different workingType).

  • callbackRate – optional float. Use with TRAILING_STOP_MARKET orders, min 0.1, max 5 where 1 for 1%.

  • workingType – optional string. stopPrice triggered by: “MARK_PRICE”, “CONTRACT_PRICE”. Default “CONTRACT_PRICE”.

  • priceProtect – optional string. “TRUE” or “FALSE”, default “FALSE”. Use with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders.

  • newOrderRespType – optional float. “ACK” or “RESULT”, default “ACK”.

  • recvWindow – optional int

Notes

  • Batch orders are processed concurrently, and the order of matching is not guaranteed.

  • The order of returned contents for batch orders is the same as the order of the order list.

    • batchOrders (list): order list. Max 5 orders
  • batchOrders is the list of order parameters in JSON

  • example:

batchOrders = {

“batchOrders”: \[

{

“symbol”:”BTCUSDT”, “side”: “SELL”, “type”: “LIMIT”, “quantity”: “0.001”, “timeInForce”: “GTC”, “reduceOnly”: “false”, “price”: “9563.51”

}, {

“symbol”:”BTCUSDT”, “side”: “SELL”, “type”: “LIMIT”, “quantity”: “0.001”, “timeInForce”: “GTC”, “reduceOnly”: “false”, “price”: “9613.51”

}

binance.futures.account.new_order(self, symbol: str, side: str, type: str, **kwargs)

New Order (TRADE)

Send a new order

API endpoint

POST /fapi/v1/order

API doc

https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

Parameters

  • symbol – string

  • side – string

  • type – string

  • positionSide – optional string. Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be passed in Hedge Mode.

  • timeInForce – optional string

  • quantity – optional float

  • reduceOnly – optional string

  • price – optional float

  • newClientOrderId – optional string. An unique ID among open orders. Automatically generated if not sent.

  • stopPrice – optional float. Use with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders.

  • closePosition – optional string. true or false; Close-All, use with STOP_MARKET or TAKE_PROFIT_MARKET.

  • activationPrice – optional float. Use with TRAILING_STOP_MARKET orders, default is the latest price (supporting different workingType).

  • callbackRate – optional float. Use with TRAILING_STOP_MARKET orders, min 0.1, max 5 where 1 for 1%.

  • workingType – optional string. stopPrice triggered by: “MARK_PRICE”, “CONTRACT_PRICE”. Default “CONTRACT_PRICE”.

  • priceProtect – optional string. “TRUE” or “FALSE”, default “FALSE”. Use with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders.

  • newOrderRespType – optional float. “ACK” or “RESULT”, default “ACK”.

  • recvWindow – optional int


binance.futures.account.new_order_test(self, symbol: str, side: str, type: str, **kwargs)

New Test Order (TRADE)

Send a new test order

API endpoint

POST /fapi/v1/order/test

API doc

https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

Parameters

  • symbol – string

  • side – string

  • type – string

  • positionSide – optional string. Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be passed in Hedge Mode.

  • timeInForce – optional string

  • quantity – optional float

  • reduceOnly – optional string

  • price – optional float

  • newClientOrderId – optional string. An unique ID among open orders. Automatically generated if not sent.

  • stopPrice – optional float. Use with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders.

  • closePosition – optional string. true or false; Close-All, use with STOP_MARKET or TAKE_PROFIT_MARKET.

  • activationPrice – optional float. Use with TRAILING_STOP_MARKET orders, default is the latest price (supporting different workingType).

  • callbackRate – optional float. Use with TRAILING_STOP_MARKET orders, min 0.1, max 5 where 1 for 1%.

  • workingType – optional string. stopPrice triggered by: “MARK_PRICE”, “CONTRACT_PRICE”. Default “CONTRACT_PRICE”.

  • priceProtect – optional string. “TRUE” or “FALSE”, default “FALSE”. Use with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders.

  • newOrderRespType – optional float. “ACK” or “RESULT”, default “ACK”.

  • recvWindow – optional int


binance.futures.account.query_order(self, symbol: str, orderId: Optional[int] = None, origClientOrderId: Optional[str] = None, **kwargs)

Query Order (USER_DATA)

Check an order’s status

API endpoint

GET /fapi/v1/order

API doc

https://binance-docs.github.io/apidocs/futures/en/#query-order-user_data

Parameters

  • symbol – string

  • orderId – optional int

  • origClientOrderId – optional string

  • recvWindow – optional int


binance.futures.data_stream module


binance.futures.data_stream.close_listen_key(self, listenKey: str)

Close a ListenKey (USER_STREAM)

API endpoint

DELETE /fapi/v1/listenKey

API doc

https://binance-docs.github.io/apidocs/futures/en/#close-user-data-stream-user_stream

Parameters

  • listenKey – string

binance.futures.data_stream.new_listen_key(self)

Create a ListenKey (USER_STREAM)

API endpoint

POST /fapi/v1/listenKey

API doc

https://binance-docs.github.io/apidocs/futures/en/#start-user-data-stream-user_stream


binance.futures.data_stream.renew_listen_key(self, listenKey: str)

Ping/Keep-alive a ListenKey (USER_STREAM)

API endpoint

PUT /fapi/v1/listenKey

API doc

https://binance-docs.github.io/apidocs/futures/en/#keepalive-user-data-stream-user_stream

Parameters

  • listenKey – string

binance.futures.market module


binance.futures.market.agg_trades(self, symbol: str, **kwargs)

Compressed/Aggregate Trades List

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

API endpoint

GET /fapi/v1/aggTrades

API doc

https://binance-docs.github.io/apidocs/futures/en/#compressed-aggregate-trades-list

Parameters

  • symbol – string; the trading symbol.

  • limit – optional int; limit the results. Default 500, max 1000.

  • formId – optional int; ID to get aggregate trades from INCLUSIVE.

  • startTime – optional int; timestamp in ms to get aggregate trades from INCLUSIVE.

  • endTime – optional int; timestamp in ms to get aggregate trades from INCLUSIVE.


binance.futures.market.asset_Index(self, symbol: Optional[str] = None)

Get asset index for Multi-Assets mode

API endpoint

GET /fapi/v1/assetIndex

API doc

https://binance-docs.github.io/apidocs/futures/en/#multi-assets-mode-asset-index

Parameters

  • symbol – optional string; Asset pair in multi asset mode (ex: BTCUSD).

binance.futures.market.blvt_kline(self, symbol: str, interval: str, **kwargs)

Get Historical BLVT NAV Kline

API endpoint

GET /fapi/v1/lvtKlines

API doc

https://binance-docs.github.io/apidocs/futures/en/#historical-blvt-nav-kline-candlestick

Parameters

  • symbol – string; the trading symbol.

  • period – string; the period of open interest, “5m”, “15m”, “30m”, “1h”, “2h”, “4h”, “6h”, “12h”, “1d”. (see more in https://binance-docs.github.io/apidocs/futures/en/#public-endpoints-info)

  • limit – optional int; limit the results. Default 500, max 1000.

  • startTime – optional int

  • endTime – optional int

Notes

  • If startTime and endTime are not sent, the most recent data is returned.

binance.futures.market.book_ticker(self, symbol: Optional[str] = None)

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

API endpoint

GET /fapi/v1/ticker/bookTicker

API doc

https://binance-docs.github.io/apidocs/futures/en/#symbol-order-book-ticker

Parameters

  • symbol – optional string; the trading symbol.

Notes

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

binance.futures.market.continuous_klines(self, pair: str, contractType: str, interval: str, **kwargs)

Continuous Kline/Candlestick Data

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

API endpoint

GET /fapi/v1/continuousKlines

API doc

https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-data

Parameters

  • pair – string; the trading pair.

  • contractType – string; PERPETUAL, CURRENT_MONTH, NEXT_MONTH, CURRENT_QUARTER, NEXT_QUARTER.

  • interval – string; the interval of kline, e.g 1m, 5m, 1h, 1d, etc. (see more in https://binance-docs.github.io/apidocs/futures/en/#public-endpoints-info)

  • limit – optional int; limit the results. Default 500, max 1000.

  • startTime – optional int

  • endTime – optional int


binance.futures.market.depth(self, symbol: str, **kwargs)

Get Orderbook

API endpoint

GET /fapi/v1/depth

API doc

https://binance-docs.github.io/apidocs/futures/en/#order-book

Parameters

  • symbol – string; the trading symbol.

  • limit – optional int; limit the results. Default 500, valid limits: [5, 10, 20, 50, 100, 500, 1000].


binance.futures.market.exchange_info(self)

Exchange Information

Current exchange trading rules and symbol information.

API endpoint

GET /fapi/v1/exchangeInfo

API doc

https://binance-docs.github.io/apidocs/futures/en/#exchange-information


binance.futures.market.funding_rate(self, symbol: str, **kwargs)

**Funding Rate History

API endpoint

GET /fapi/v1/fundingRate

API doc

https://binance-docs.github.io/apidocs/futures/en/#get-funding-rate-history

Parameters

  • symbol – string; the trading symbol.

  • limit – optional int; limit the results. Default 500, max 1000.

  • startTime – optional int

  • endTime – optional int

Notes

  • 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.


binance.futures.market.historical_trades(self, symbol: str, **kwargs)

Old Trade Lookup

Get older market historical trades.

API endpoint

GET /fapi/v1/historicalTrades

API doc

https://binance-docs.github.io/apidocs/futures/en/#old-trades-lookup-market_data

Parameters

  • symbol – string; the trading symbol.

  • limit – optional int; limit the results. Default 500, max 1000.

  • formId – optional int; trade ID to fetch from. Default gets most recent trades.


binance.futures.market.index_info(self, symbol: Optional[str] = None)

Get Index Composite

API endpoint

GET /fapi/v1/indexInfo

API doc

https://binance-docs.github.io/apidocs/futures/en/#composite-index-symbol-information

Parameters

  • symbol – optional string; the trading symbol.

Notes

  • Only for composite index symbols.

binance.futures.market.index_price_klines(self, pair: str, interval: str, **kwargs)

Kline/Candlestick Data for the index price of a pair.

Klines are uniquely identified by their open time.

API endpoint

GET /fapi/v1/indexPriceKlines

API doc

https://binance-docs.github.io/apidocs/futures/en/#index-price-kline-candlestick-data

Parameters


binance.futures.market.klines(self, symbol: str, interval: str, **kwargs)

Kline/Candlestick Data

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

API endpoint

GET /fapi/v1/klines

API doc

https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data

Parameters


binance.futures.market.long_short_account_ratio(self, symbol: str, period: str, **kwargs)

Get top long short account ratio.

API endpoint

GET /futures/data/globalLongShortAccountRatio

API doc

https://binance-docs.github.io/apidocs/futures/en/#long-short-ratio

Parameters

  • symbol – string; the trading symbol.

  • period – string; the period of open interest, “5m”, “15m”, “30m”, “1h”, “2h”, “4h”, “6h”, “12h”, “1d”. (see more in https://binance-docs.github.io/apidocs/futures/en/#public-endpoints-info)

  • limit – optional int; limit the results. Default 30, max 500.

  • startTime – optional int

  • endTime – optional int

Notes

  • If startTime and endTime are not sent, the most recent data is returned.

  • Only the data of the latest 30 days is available.


binance.futures.market.mark_price(self, symbol: str)

Mark Price and Funding Rate

API endpoint

GET /fapi/v1/premiumIndex

API doc

https://binance-docs.github.io/apidocs/futures/en/#mark-price

Parameters

  • symbol – string; the trading symbol.

binance.futures.market.mark_price_klines(self, symbol: str, interval: str, **kwargs)

Kline/candlestick bars for the mark price of a symbol.

Klines are uniquely identified by their open time.

API endpoint

GET /fapi/v1/markPriceKlines

API doc

https://binance-docs.github.io/apidocs/futures/en/#mark-price-kline-candlestick-data

Parameters


binance.futures.market.open_interest(self, symbol: str)

Get present open interest of a specific symbol.

API endpoint

GET /fapi/v1/openInterest

API doc

https://binance-docs.github.io/apidocs/futures/en/#open-interest

Parameters

  • symbol – string; the trading symbol.

binance.futures.market.open_interest_hist(self, symbol: str, period: str, **kwargs)

Get historical open interest of a specific symbol.

API endpoint

GET /futures/data/openInterestHist

API doc

https://binance-docs.github.io/apidocs/futures/en/#open-interest-statistics

Parameters

  • symbol – string; the trading symbol.

  • period – string; the period of open interest, “5m”, “15m”, “30m”, “1h”, “2h”, “4h”, “6h”, “12h”, “1d”.

  • limit – optional int; limit the results. Default 30, max 500.

  • startTime – optional int

  • endTime – optional int

Notes

  • If startTime and endTime are not sent, the most recent data is returned.

  • Only the data of the latest 30 days is available.


binance.futures.market.ping(self)

Test Connectivity

Test connectivity to the Rest API.

API endpoint

GET /fapi/v1/ping

API doc

https://binance-docs.github.io/apidocs/futures/en/#test-connectivity


binance.futures.market.taker_long_short_ratio(self, symbol: str, period: str, **kwargs)

Get taker long short ratio.

API endpoint

GET /futures/data/takerlongshortRatio

API doc

https://binance-docs.github.io/apidocs/futures/en/#taker-buy-sell-volume

Parameters

  • symbol – string; the trading symbol.

  • period – string; the period of open interest, “5m”, “15m”, “30m”, “1h”, “2h”, “4h”, “6h”, “12h”, “1d”. (see more in https://binance-docs.github.io/apidocs/futures/en/#public-endpoints-info)

  • limit – optional int; limit the results. Default 30, max 500.

  • startTime – optional int

  • endTime – optional int

Notes

  • If startTime and endTime are not sent, the most recent data is returned.

  • Only the data of the latest 30 days is available.


binance.futures.market.ticker_24hr_price_change(self, symbol: Optional[str] = None)

24 hour rolling window price change statistics.

Careful when accessing this with no symbol.

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

API endpoint

GET /fapi/v1/ticker/24hr

API doc

https://binance-docs.github.io/apidocs/futures/en/#24hr-ticker-price-change-statistics

Parameters

  • symbol – string; the trading symbol.

binance.futures.market.ticker_price(self, symbol: Optional[str] = None)

Latest price for a symbol or symbols.

API endpoint

GET /fapi/v1/ticker/price

API doc

https://binance-docs.github.io/apidocs/futures/en/#symbol-price-ticker

Parameters

  • symbol – optional string; the trading symbol.

Notes

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

binance.futures.market.time(self)

Check Server Time

Test connectivity to the Rest API and get the current server time.

API endpoint

GET /fapi/v1/time

API doc

https://binance-docs.github.io/apidocs/futures/en/#check-server-time


binance.futures.market.top_long_short_position_ratio(self, symbol: str, period: str, **kwargs)

Get top long short position ratio.

API endpoint

GET /futures/data/topLongShortPositionRatio

API doc

https://binance-docs.github.io/apidocs/futures/en/#top-trader-long-short-ratio-positions

Parameters

  • symbol – string; the trading symbol.

  • period – string; the period of open interest, “5m”, “15m”, “30m”, “1h”, “2h”, “4h”, “6h”, “12h”, “1d”. (see more in https://binance-docs.github.io/apidocs/futures/en/#public-endpoints-info)

  • limit – optional int; limit the results. Default 30, max 500.

  • startTime – optional int

  • endTime – optional int

Notes

  • If startTime and endTime are not sent, the most recent data is returned.

  • Only the data of the latest 30 days is available.


binance.futures.market.trades(self, symbol: str, **kwargs)

Get Recent Market Trades

API endpoint

GET /fapi/v1/trades

API doc

https://binance-docs.github.io/apidocs/futures/en/#recent-trades-list

Parameters

  • symbol – string; the trading symbol.

  • limit – optional int; limit the results. Default 500, max 1000.



© Copyright 2021, Binance Futures.

Clone this wiki locally