Account / Trade Endpoints
Test New Order (TRADE)
- new_order_test(self, symbol: str, side: str, type: str, **kwargs)
Test New Order (TRADE)
Test new order creation and signature/recvWindow. Creates and validates a new order but does not send it into the matching engine.
POST /api/v3/order/test
- Parameters:
symbol (str)
side (str)
type (str)
- Keyword Arguments:
timeInForce (str, optional)
quantity (float, optional)
quoteOrderQty (float, optional)
price (float, optional)
newClientOrderId (str, optional) – A unique id among open orders. Automatically generated if not sent.
stopPrice (float, optional) – Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
icebergQty (float, optional) – Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
newOrderRespType (str, optional) – Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.
recvWindow (int, optional) – The value cannot be greater than 60000
New Order (TRADE)
- new_order(self, symbol: str, side: str, type: str, **kwargs)
New Order (TRADE)
Post a new order
POST /api/v3/order
https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
- Parameters:
symbol (str)
side (str)
type (str)
- Keyword Arguments:
timeInForce (str, optional)
quantity (float, optional)
quoteOrderQty (float, optional)
price (float, optional)
newClientOrderId (str, optional) – A unique id among open orders. Automatically generated if not sent.
strategyId (int, optional)
strategyType (int, optional) – The value cannot be less than 1000000.
stopPrice (float, optional) – Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
icebergQty (float, optional) – Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
newOrderRespType (str, optional) – Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.
recvWindow (int, optional) – The value cannot be greater than 60000
Cancel Order (TRADE)
- cancel_order(self, symbol: str, **kwargs)
Cancel Order (TRADE)
Cancel an active order.
DELETE /api/v3/order
- Parameters:
symbol (str)
- Keyword Arguments:
orderId (int, optional)
origClientOrderId (str, optional)
newClientOrderId (str, optional)
recvWindow (int, optional) – The value cannot be greater than 60000
Cancel all Open Orders on a Symbol (TRADE)
- cancel_open_orders(self, symbol: str, **kwargs)
Cancel all Open Orders on a Symbol (TRADE)
Cancels all active orders on a symbol. This includes OCO orders.
DELETE api/v3/openOrders
- Parameters:
symbol (str)
- Keyword Arguments:
recvWindow (int, optional) – The value cannot be greater than 60000
Query Order (USER_DATA)
- get_order(self, symbol, **kwargs)
Query Order (USER_DATA)
Check an order’s status.
GET /api/v3/order
- Parameters:
symbol (str)
- Keyword Arguments:
orderId (int, optional)
origClientOrderId (str, optional)
recvWindow (int, optional) – The value cannot be greater than 60000
Cancel an Existing Order and Send a New Order (USER_DATA)
- cancel_and_replace(self, symbol: str, side: str, type: str, cancelReplaceMode: str, **kwargs)
Cancel an Existing Order and Send a New Order (USER_DATA)
Cancels an existing order and places a new order on the same symbol.
Filters are evaluated before the cancel order is placed.
If the new order placement is successfully sent to the engine, the order count will increase by 1.
Weight(IP): 1
POST /api/v3/order/cancelReplace
- Parameters:
symbol (str)
side (str)
type (str)
cancelReplaceMode (str)
- Keyword Arguments:
timeInForce (str, optional) – Order time in force
quantity (float, optional) – Order quantity
quoteOrderQty (float, optional) – Quote quantity
price (float, optional) – Order price
cancelNewClientOrderId (str, optional) – Used to uniquely identify this cancel. Automatically generated by default
cancelOrigClientOrderId (str, optional) – Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence.
cancelOrderId (int, optional) – Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence.
newClientOrderId (str, optional) – Used to identify the new order. Automatically generated by default
strategyId (int, optional)
strategyType (int, optional) – The value cannot be less than 1000000.
stopPrice (float, optional) – Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
trailingDelta (float, optional) – Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
icebergQty (float, optional) – Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
newOrderRespType (str, optional) – Set the response JSON. MARKET and LIMIT order types default to FULL, all other orders default to ACK.
selfTradePreventionMode (str, optional) – The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
cancelRestrictions (str, optional) – Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW. ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED.
orderRateLimitExceededMode (str, optional) – Supported values: DO_NOTHING (default)- will only attempt to cancel the order if account has not exceeded the order rate limit. CANCEL_ONLY - will always cancel the order.
recvWindow (int, optional) – The value cannot be greater than 60000
Current Open Orders (USER_DATA)
- get_open_orders(self, symbol=None, **kwargs)
Current Open Orders (USER_DATA)
Get all open orders on a symbol.
GET /api/v3/openOrders
- Parameters:
symbol (str, optional)
- Keyword Arguments:
recvWindow (int, optional) – The value cannot be greater than 60000
All Orders (USER_DATA)
- get_orders(self, symbol: str, **kwargs)
All Orders (USER_DATA)
Get all account orders; active, canceled, or filled.
GET /api/v3/allOrders
- Parameters:
symbol (str)
- Keyword Arguments:
orderId (int, optional)
startTime (int, optional)
endTime (int, optional)
limit (int, optional) – Default 500; max 1000.
recvWindow (int, optional) – The value cannot be greater than 60000
New OCO (TRADE)
- new_oco_order(self, symbol: str, side: str, quantity: float, aboveType: str, belowType: str, **kwargs)
New Order List - OCO (TRADE)
Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other.
An OCO has 2 legs called the above leg and below leg.
One of the legs must be a LIMIT_MAKER order and the other leg must be STOP_LOSS or STOP_LOSS_LIMIT order.
- Price restrictions:
If the OCO is on the SELL side: LIMIT_MAKER price > Last Traded Price > stopPrice
If the OCO is on the BUY side: LIMIT_MAKER price < Last Traded Price < stopPrice
OCO counts as 2 orders against the order rate limit.
Response format for orderReports is selected using the newOrderRespType parameter. The response example is for the RESULT response type. See POST /api/v3/order for more examples.
POST /api/v3/orderList/oco
- Parameters:
symbol (str)
side (str)
quantity (float)
aboveType (str)
belowType (str)
- Keyword Arguments:
listClientOrderId (str, optional) – Arbitrary unique ID among open order lists. Automatically generated if not sent. A new order list with the same listClientOrderId is accepted only when the previous one is filled or completely expired. listClientOrderId is distinct from the aboveClientOrderId and the belowCLientOrderId
aboveClientOrderId (str, optional) – Supported values : STOP_LOSS_LIMIT, STOP_LOSS, LIMIT_MAKER
aboveIcebergQty (int, optional) – Note that this can only be used if aboveTimeInForce is GTC.
abovePrice (float, optional)
aboveStopPrice (float, optional) – Can be used if aboveType is STOP_LOSS or STOP_LOSS_LIMIT. Either aboveStopPrice or aboveTrailingDelta or both, must be specified.
aboveTrailingDelta (int, optional)
aboveTimeInForce (float, optional) – Required if the aboveType is STOP_LOSS_LIMIT.
aboveStrategyId (int, optional) – Arbitrary numeric value identifying the above leg order within an order strategy.
aboveStrategyType (int, optional) – Arbitrary numeric value identifying the above leg order strategy. Values smaller than 1000000 are reserved and cannot be used.
belowClientOrderId (str, optional) – Arbitrary unique ID among open orders for the below leg order. Automatically generated if not sent
belowIcebergQty (int, optional) – Note that this can only be used if belowTimeInForce is GTC.
belowPrice (float, optional)
belowStopPrice (float, optional) – Can be used if belowType is STOP_LOSS or STOP_LOSS_LIMIT. Either belowStopPrice or belowTrailingDelta or both, must be specified.
belowTrailingDelta (int, optional)
belowTimeInForce (str, optional) – Required if the belowType is STOP_LOSS_LIMIT.
belowStrategyId (int, optional) – Arbitrary numeric value identifying the below leg order within an order strategy.
belowStrategyType (int, optional) – Arbitrary numeric value identifying the below leg order strategy. Values smaller than 1000000 are reserved and cannot be used.
newOrderRespType (str, optional) – Select response format: ACK, RESULT, FULL
selfTradePreventionMode (str, optional) – The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
recvWindow (int, optional) – The value cannot be greater than 60000
Cancel OCO (TRADE)
- cancel_oco_order(self, symbol, **kwargs)
Cancel OCO (TRADE)
Cancel an entire Order List
DELETE /api/v3/orderList
- Parameters:
symbol (str)
- Keyword Arguments:
orderListId (int, optional) – Either orderListId or listClientOrderId must be provided
listClientOrderId (str, optional) – Either orderListId or listClientOrderId must be provided
newClientOrderId (str, optional) – Used to uniquely identify this cancel. Automatically generated by default.
recvWindow (int, optional) – The value cannot be greater than 60000
Query OCO (USER_DATA)
- get_oco_order(self, **kwargs)
Query OCO (USER_DATA)
Retrieves a specific OCO based on provided optional parameters
GET /api/v3/orderList
- Keyword Arguments:
orderListId (int, optional) – Either orderListId or listClientOrderId must be provided
origClientOrderId (str, optional) – Either orderListId or listClientOrderId must be provided.
recvWindow (int, optional) – The value cannot be greater than 60000
Query all OCO (USER_DATA)
- get_oco_orders(self, **kwargs)
Query all OCO (USER_DATA)
Retrieves all OCO based on provided optional parameters
GET /api/v3/allOrderList
- Keyword Arguments:
fromId (int, optional) – If supplied, neither startTime or endTime can be provided
startTime (int, optional)
endTime (int, optional)
limit (int, optional) – Default Value: 500; Max Value: 1000
recvWindow (int, optional) – The value cannot be greater than 60000
Query Open OCO (USER_DATA)
- get_oco_open_orders(self, **kwargs)
Query Open OCO (USER_DATA)
GET /api/v3/openOrderList
- Keyword Arguments:
recvWindow (int, optional) – The value cannot be greater than 60000
Account Information (USER_DATA)
- account(self, **kwargs)
Account Information (USER_DATA)
Get current account information
GET /api/v3/account
- Keyword Arguments:
omitZeroBalances (bool, optional) – When set to true, emits only the non-zero balances of an account. Default value: false
recvWindow (int, optional) – The value cannot be greater than 60000
Account Trade List (USER_DATA)
- my_trades(self, symbol: str, **kwargs)
Account Trade List (USER_DATA)
Get trades for a specific account and symbol.
GET /api/v3/myTrades
- Parameters:
symbol (str)
- Keyword Arguments:
fromId (int, optional) – TradeId to fetch from. Default gets most recent trades.
orderId (int, optional) – This can only be used in combination with symbol
startTime (int, optional)
endTime (int, optional)
limit (int, optional) – Default Value: 500; Max Value: 1000
recvWindow (int, optional) – The value cannot be greater than 60000
Query Current Order Count Usage (TRADE)
- get_order_rate_limit(self, **kwargs)
Query Current Order Count Usage (TRADE)
Displays the user’s current order count usage for all intervals.
GET /api/v3/rateLimit/order
- Keyword Arguments:
recvWindow (int, optional) – The value cannot be greater than 60000
Query Prevented Matches (USER_DATA)
- query_prevented_matches(self, symbol: str, **kwargs)
Query Prevented Matches (USER_DATA)
Displays the list of orders that were expired because of STP.
For additional information on what a Prevented match is, as well as Self Trade Prevention (STP), please refer to our STP FAQ page.
These are the combinations supported:
symbol + preventedMatchId
symbol + orderId
symbol + orderId + fromPreventedMatchId (limit will default to 500)
symbol + orderId + fromPreventedMatchId + limit
Weight(IP):
Case Weight If symbol is invalid: 2 Querying by preventedMatchId: 2 Querying by orderId: 20
GET /api/v3/myPreventedMatches
- Parameters:
symbol (str)
- Keyword Arguments:
preventedMatchId (int, optional)
orderId (int, optional) – Order id
fromPreventedMatchId (int, optional)
limit (int, optional) – Default 500; max 1000.
recvWindow (int, optional) – The value cannot be greater than 60000
Query Cross-Collateral Information (USER_DATA)
- query_allocations(self, symbol: str, **kwargs)
Query Cross-Collateral Information (USER_DATA)
GET /api/v3/myAllocations
- Parameters:
symbol (str)
- Keyword Arguments:
startTime (int, optional)
endTime (int, optional)
fromAllocationId (int, optional)
limit (int, optional) – Default Value: 500; Max Value: 1000
orderId (int, optional)
recvWindow (int, optional) – The value cannot be greater than 60000
Query Commission Rates (USER_DATA)
- query_commission_rates(self, symbol: str, **kwargs)
Query Commission Rates (USER_DATA)
GET /api/v3/account/commission
- Parameters:
symbol (str)
- Keyword Arguments:
recvWindow (int, optional) – The value cannot be greater than 60000