|
Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
|
#include <trade_api.hpp>
Public Member Functions | |
| TradeApi (std::shared_ptr< common::WebsocketApi > client) | |
| common::WebsocketApiResponse< std::vector< OpenOrdersCancelAllResponseResultInner > > | open_orders_cancel_all (const OpenOrdersCancelAllParams ¶ms) const |
| Cancel open orders (TRADE). | |
| template<class CompletionToken> | |
| auto | async_open_orders_cancel_all (const OpenOrdersCancelAllParams ¶ms, CompletionToken &&token) const |
| Asynchronous open_orders_cancel_all(). | |
| common::WebsocketApiResponse< OrderAmendKeepPriorityResponseResult > | order_amend_keep_priority (const OrderAmendKeepPriorityParams ¶ms) const |
| Order Amend Keep Priority (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_amend_keep_priority (const OrderAmendKeepPriorityParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_amend_keep_priority(). | |
| common::WebsocketApiResponse< OrderCancelResponseResult > | order_cancel (const OrderCancelParams ¶ms) const |
| Cancel order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_cancel (const OrderCancelParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_cancel(). | |
| common::WebsocketApiResponse< OrderCancelReplaceResponseResult > | order_cancel_replace (const OrderCancelReplaceParams ¶ms) const |
| Cancel and replace order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_cancel_replace (const OrderCancelReplaceParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_cancel_replace(). | |
| common::WebsocketApiResponse< OrderListCancelResponseResult > | order_list_cancel (const OrderListCancelParams ¶ms) const |
| Cancel Order list (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_cancel (const OrderListCancelParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_list_cancel(). | |
| common::WebsocketApiResponse< OrderListPlaceResponseResult > | order_list_place (const OrderListPlaceParams ¶ms) const |
| Place new OCO - Deprecated (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place (const OrderListPlaceParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_list_place(). | |
| common::WebsocketApiResponse< OrderListPlaceOcoResponseResult > | order_list_place_oco (const OrderListPlaceOcoParams ¶ms) const |
| Place new Order list - OCO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_oco (const OrderListPlaceOcoParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_list_place_oco(). | |
| common::WebsocketApiResponse< OrderListPlaceOpoResponseResult > | order_list_place_opo (const OrderListPlaceOpoParams ¶ms) const |
| OPO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_opo (const OrderListPlaceOpoParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_list_place_opo(). | |
| common::WebsocketApiResponse< OrderListPlaceOpocoResponseResult > | order_list_place_opoco (const OrderListPlaceOpocoParams ¶ms) const |
| OPOCO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_opoco (const OrderListPlaceOpocoParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_list_place_opoco(). | |
| common::WebsocketApiResponse< OrderListPlaceOtoResponseResult > | order_list_place_oto (const OrderListPlaceOtoParams ¶ms) const |
| Place new Order list - OTO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_oto (const OrderListPlaceOtoParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_list_place_oto(). | |
| common::WebsocketApiResponse< OrderListPlaceOtocoResponseResult > | order_list_place_otoco (const OrderListPlaceOtocoParams ¶ms) const |
| Place new Order list - OTOCO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_otoco (const OrderListPlaceOtocoParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_list_place_otoco(). | |
| common::WebsocketApiResponse< OrderPlaceResponseResult > | order_place (const OrderPlaceParams ¶ms) const |
| Place new order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_place (const OrderPlaceParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_place(). | |
| common::WebsocketApiResponse< OrderTestResponseResult > | order_test (const OrderTestParams ¶ms) const |
| Test new order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_test (const OrderTestParams ¶ms, CompletionToken &&token) const |
| Asynchronous order_test(). | |
| common::WebsocketApiResponse< std::vector< SorOrderPlaceResponseResultInner > > | sor_order_place (const SorOrderPlaceParams ¶ms) const |
| Place new order using SOR (TRADE). | |
| template<class CompletionToken> | |
| auto | async_sor_order_place (const SorOrderPlaceParams ¶ms, CompletionToken &&token) const |
| Asynchronous sor_order_place(). | |
| common::WebsocketApiResponse< SorOrderTestResponseResult > | sor_order_test (const SorOrderTestParams ¶ms) const |
| Test new order using SOR (TRADE). | |
| template<class CompletionToken> | |
| auto | async_sor_order_test (const SorOrderTestParams ¶ms, CompletionToken &&token) const |
| Asynchronous sor_order_test(). | |
|
explicit |
|
nodiscard |
Cancel open orders (TRADE).
openOrders.cancelAll.
Cancel all open orders on a symbol. This includes orders that are part of an order list.
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
Asynchronous open_orders_cancel_all().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<OpenOrdersCancelAllResponseResultInner>>).
|
nodiscard |
Order Amend Keep Priority (TRADE).
order.amend.keepPriority.
Reduce the quantity of an existing open order.
This adds 0 orders to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
Read Order Amend Keep Priority FAQ to learn more.
Weight(IP): 4
Unfilled Order Count: 0
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
Asynchronous order_amend_keep_priority().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderAmendKeepPriorityResponseResult>).
|
nodiscard |
Cancel order (TRADE).
order.cancel.
Cancel an active order.
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Notes:
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
Regarding cancelRestrictions
|
inline |
Asynchronous order_cancel().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderCancelResponseResult>).
|
nodiscard |
Cancel and replace order (TRADE).
order.cancelReplace.
Weight(IP): 1
Unfilled Order Count: 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Similar to the order.place request, additional mandatory parameters (*) are determined by the new order type.
Available cancelReplaceMode options:
Notes:
newClientOrderId specifies clientOrderId value for the placed order.
A new order with the same clientOrderId is accepted only when the previous one is filled or expired.
The new order can reuse old clientOrderId of the canceled order.
This cancel-replace operation is not transactional.
If one operation succeeds but the other one fails, the successful operation is still executed.
For example, in STOP_ON_FAILURE mode, if the new order placement fails, the old order is still canceled.
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
Asynchronous order_cancel_replace().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderCancelReplaceResponseResult>).
|
nodiscard |
Cancel Order list (TRADE).
orderList.cancel.
Cancel an active order list.
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Notes:
|
inline |
Asynchronous order_list_cancel().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderListCancelResponseResult>).
|
nodiscard |
Place new OCO - Deprecated (TRADE).
orderList.place.
Send in a new one-cancels-the-other (OCO) pair: LIMIT_MAKER + STOP_LOSS/STOP_LOSS_LIMIT orders (called legs), where activation of one order immediately cancels the other.
This adds 1 order to EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter
Weight(IP): 1
Unfilled Order Count: 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Notes:
listClientOrderId parameter specifies listClientOrderId for the OCO pair.
A new OCO with the same listClientOrderId is accepted only when the previous one is filled or completely expired.
listClientOrderId is distinct from clientOrderId of individual orders.
limitClientOrderId and stopClientOrderId specify clientOrderId values for both legs of the OCO.
A new order with the same clientOrderId is accepted only when the previous one is filled or expired.
| side | Price relation |
|---|---|
| BUY | price < market price < stopPrice |
| SELL | price > market price > stopPrice |
Both legs have the same quantity.
However, you can set different iceberg quantity for individual legs.
If stopIcebergQty is used, stopLimitTimeInForce must be GTC.
Deprecated: this endpoint may be removed in a future version.
|
inline |
Asynchronous order_list_place().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderListPlaceResponseResult>).
|
nodiscard |
Place new Order list - OCO (TRADE).
orderList.place.oco.
Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
|
inline |
Asynchronous order_list_place_oco().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderListPlaceOcoResponseResult>).
|
nodiscard |
OPO (TRADE).
orderList.place.opo.
Place an OPO.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
Asynchronous order_list_place_opo().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderListPlaceOpoResponseResult>).
|
nodiscard |
OPOCO (TRADE).
orderList.place.opoco.
Place an OPOCO.
Weight(IP): 1
Unfilled Order Count: 3
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
Asynchronous order_list_place_opoco().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderListPlaceOpocoResponseResult>).
|
nodiscard |
Place new Order list - OTO (TRADE).
orderList.place.oto.
Places an OTO.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
Mandatory parameters based on pendingType or workingType
Depending on the pendingType or workingType, some optional parameters will become mandatory.
|Type |Additional mandatory parameters|Additional information| |-— |-— |---— |workingType = LIMIT |workingTimeInForce | |pendingType = LIMIT |pendingPrice, pendingTimeInForce | |pendingType = STOP_LOSS or TAKE_PROFIT |pendingStopPrice and/or pendingTrailingDelta| |pendingType =STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT|pendingPrice, pendingStopPrice and/or pendingTrailingDelta, pendingTimeInForce|
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
Asynchronous order_list_place_oto().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderListPlaceOtoResponseResult>).
|
nodiscard |
Place new Order list - OTOCO (TRADE).
orderList.place.otoco.
Place an OTOCO.
Weight(IP): 1
Unfilled Order Count: 3
Security Type: TRADE
Notes: Data Source: Matching Engine
Mandatory parameters based on pendingAboveType, pendingBelowType or workingType
Depending on the pendingAboveType/pendingBelowType or workingType, some optional parameters will become mandatory.
|Type |Additional mandatory parameters|Additional information| |-— |-— |---— |workingType = LIMIT |workingTimeInForce | |pendingAboveType= LIMIT_MAKER |pendingAbovePrice | |pendingAboveType = STOP_LOSS/TAKE_PROFIT |pendingAboveStopPrice and/or pendingAboveTrailingDelta| |pendingAboveType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT|pendingAbovePrice, pendingAboveStopPrice and/or pendingAboveTrailingDelta, pendingAboveTimeInForce| |pendingBelowType= LIMIT_MAKER |pendingBelowPrice | pendingBelowType= STOP_LOSS/TAKE_PROFIT |pendingBelowStopPrice and/or pendingBelowTrailingDelta| |pendingBelowType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT|pendingBelowPrice, pendingBelowStopPrice and/or pendingBelowTrailingDelta, pendingBelowTimeInForce|
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
Asynchronous order_list_place_otoco().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderListPlaceOtocoResponseResult>).
|
nodiscard |
Place new order (TRADE).
order.place.
Send in a new order.
This adds 1 order to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
Weight(IP): 1
Unfilled Order Count: 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Certain parameters (*) become mandatory based on the order type:
Supported order types:
, Buy or sell quantity at the specified price or better.,
, LIMIT order that will be rejected if it immediately matches and trades as a taker.,
,
, This order type is also known as a POST-ONLY order.,
, Buy or sell at the best available market price.,
, ,
, MARKET order with quantity parameter, specifies the amount of the base asset you want to buy or sell., Actually executed quantity of the quote asset will be determined by available market liquidity.,
,
, E.g., a MARKET BUY order on BTCUSDT for "quantity": "0.1000", specifies that you want to buy 0.1 BTC at the best available price., If there is not enough BTC at the best price, keep buying at the next best price,, until either your order is filled, or you run out of USDT, or market runs out of BTC.,
, ,
, MARKET order with quoteOrderQty parameter, specifies the amount of the quote asset you want to spend (when buying) or receive (when selling)., Actually executed quantity of the base asset will be determined by available market liquidity.,
,
, E.g., a MARKET BUY on BTCUSDT for "quoteOrderQty": "100.00", specifies that you want to buy as much BTC as you can for 100 USDT at the best available price., Similarly, a SELL order will sell as much available BTC as needed for you to receive 100 USDT, (before commission).,
, ,
, Execute a MARKET order for given quantity when specified conditions are met.,
,
, I.e., when stopPrice is reached, or when trailingDelta is activated.,
, Place a LIMIT order with given parameters when specified conditions are met.,
, Like STOP_LOSS but activates when market price moves in the favorable direction.,
, Like STOP_LOSS_LIMIT but activates when market price moves in the favorable direction.,
Notes on using parameters for Pegged Orders:
Available timeInForce options, setting how long the order should be active before expiration:
| TIF | Description |
|---|---|
| GTC | Good 'til Canceled – the order will remain on the book until you cancel it, or |
| the order is completely filled. IOC | Immediate or Cancel – the order will be filled |
| for as much as possible, the unfilled quantity immediately expires. FOK | Fill or Kill |
– the order will expire unless it cannot be immediately filled for the entire quantity.
Notes:
newClientOrderId specifies clientOrderId value for the order.
A new order with the same clientOrderId is accepted only when the previous one is filled or expired.
Any LIMIT or LIMIT_MAKER order can be made into an iceberg order by specifying the icebergQty.
An order with an icebergQty must have timeInForce set to GTC.
MARKET orders using quoteOrderQty follow LOT_SIZE filter rules.
The order will execute a quantity that has notional value as close as possible to requested quoteOrderQty.
|
inline |
Asynchronous order_place().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderPlaceResponseResult>).
|
nodiscard |
Test new order (TRADE).
order.test.
Test order placement.
Validates new order parameters and verifies your signature but does not send the order into the matching engine.
Weight: | Condition | Request Weight | | — | — | | Without computeCommissionRates | 1 | | With computeCommissionRates | 20 |
Security Type: TRADE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-test
|
inline |
Asynchronous order_test().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<OrderTestResponseResult>).
|
nodiscard |
Place new order using SOR (TRADE).
sor.order.place.
Places an order using smart order routing (SOR).
This adds 1 order to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
Read SOR FAQ to learn more.
Weight(IP): 1
Unfilled Order Count: 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Note: sor.order.place only supports LIMIT and MARKET orders. quoteOrderQty is not supported.
|
inline |
Asynchronous sor_order_place().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<SorOrderPlaceResponseResultInner>>).
|
nodiscard |
Test new order using SOR (TRADE).
sor.order.test.
Test new order creation and signature/recvWindow using smart order routing (SOR). Creates and validates a new order but does not send it into the matching engine.
Weight: | Condition | Request Weight | | — | — | | Without computeCommissionRates | 1 | | With computeCommissionRates | 20 |
Security Type: TRADE
Notes: Data Source: Memory
|
inline |
Asynchronous sor_order_test().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<SorOrderTestResponseResult>).