|
Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
|
#include <trade_api.hpp>
|
explicit |
|
nodiscard |
Create Special Key(Low-Latency Trading) (TRADE).
POST /sapi/v1/margin/apiKey.
Eligibility
For more information, please refer to FAQ.
Supported Products:
Unsupported Products:
We support several types of API keys:
We recommend to use Ed25519 API keys as it should provide the best performance and security out of all supported key types. We accept PKCS#8 (BEGIN PUBLIC KEY). For how to generate an RSA key pair to send API requests on Binance. Please refer to the document below FAQ .
How to use the Margin Special Key
Read REST API or WebSocket API documentation to learn how to use different API keys
You need to enable Permits “Enable Spot & Margin Trading” option for the API Key which requests this endpoint.
Weight(UID): 1
Security Type: TRADE
Response Notes:
|
inline |
Asynchronous create_special_key().
Completes with void(std::exception_ptr, common::RestApiResponse<CreateSpecialKeyResponse>).
|
nodiscard |
Delete Special Key(Low-Latency Trading) (TRADE).
DELETE /sapi/v1/margin/apiKey.
Deleting your Margin Special Key alone does not exit you from the Margin Special Key framework or discharge your obligations under the Margin Special Key Supplemental Product Terms. To fully exit, you must:
Only after step 4 is completed and the exit status is confirmed by Binance will your account revert to standard liquidation logic and no longer be subject to the Margin Special Key Supplemental Product Terms.
If apiKey is given, apiName will be ignored. If apiName is given with no apiKey, all apikeys with given apiName will be deleted.
You need to enable Permits “Enable Spot & Margin” option for the API Key which requests this endpoint.
Weight(UID): 1
Security Type: TRADE
|
inline |
Asynchronous delete_special_key().
Completes with void(std::exception_ptr, common::RestApiResponse<boost::json::value>).
|
nodiscard |
Query Special key(Low Latency Trading) (TRADE).
GET /sapi/v1/margin/apiKey.
Query Special Key Information.
This only applies to Special Key for Low Latency Trading.
Weight(UID): 1
Security Type: TRADE
|
inline |
Asynchronous query_special_key().
Completes with void(std::exception_ptr, common::RestApiResponse<QuerySpecialKeyResponse>).
|
nodiscard |
Edit ip for Special Key(Low-Latency Trading) (TRADE).
PUT /sapi/v1/margin/apiKey/ip.
Edit ip restriction. This only applies to Special Key for Low Latency Trading.
You need to enable Permits “Enable Spot & Margin” option for the API Key which requests this endpoint.
Weight(UID): 1
Security Type: TRADE
|
inline |
Asynchronous edit_ip_for_special_key().
Completes with void(std::exception_ptr, common::RestApiResponse<boost::json::value>).
|
nodiscard |
Exit Special Key Mode (TRADE).
POST /sapi/v1/margin/exit-special-key-mode.
Exit the Margin Special Key mode for Cross Margin Classic accounts.
All outstanding liabilities under the Cross Margin Classic account must be fully repaid before calling this endpoint. Deleting the Margin Special Key alone does not constitute a valid exit.
When a user creates a Margin Special API Key, the account enters "Special Key Mode". Upon a successful request, the following actions will be performed atomically:
For more information, please refer to FAQ.
Preconditions:
The following conditions must be met; otherwise the request will be rejected:
You need to enable "Permits Enable Spot & Margin Trading" option for the API Key which requests this endpoint.
Weight(UID): 10
Security Type: TRADE
|
inline |
Asynchronous exit_special_key_mode().
Completes with void(std::exception_ptr, common::RestApiResponse<boost::json::value>).
|
nodiscard |
Get Force Liquidation Record (USER_DATA).
GET /sapi/v1/margin/forceLiquidationRec.
Get Force Liquidation Record
Weight(IP): 1
Security Type: USER_DATA
Notes:
|
inline |
Asynchronous get_force_liquidation_record().
Completes with void(std::exception_ptr, common::RestApiResponse<GetForceLiquidationRecordResponse>).
|
nodiscard |
Get Small Liability Exchange Coin List (USER_DATA).
GET /sapi/v1/margin/exchange-small-liability.
Query the coins which can be small liability exchange
Weight(IP): 100
Security Type: USER_DATA
|
inline |
Asynchronous get_small_liability_exchange_coin_list().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<GetSmallLiabilityExchangeCoinListResponseInner>>).
|
nodiscard |
Small Liability Exchange (MARGIN).
POST /sapi/v1/margin/exchange-small-liability.
Small Liability Exchange
Weight(UID): 3000
Security Type: MARGIN
Notes:
|
inline |
Asynchronous small_liability_exchange().
Completes with void(std::exception_ptr, common::RestApiResponse<boost::json::value>).
|
nodiscard |
Get Small Liability Exchange History (USER_DATA).
GET /sapi/v1/margin/exchange-small-liability-history.
Get Small liability Exchange History
Weight(UID): 100
Security Type: USER_DATA
|
inline |
Asynchronous get_small_liability_exchange_history().
Completes with void(std::exception_ptr, common::RestApiResponse<GetSmallLiabilityExchangeHistoryResponse>).
|
nodiscard |
Liquidation Loan Repay (MARGIN).
POST /sapi/v1/margin/liquidation-loan/repay.
Repays the outstanding cross-margin liquidation loan from the user's spot wallet. A liquidation loan represents the account deficit incurred when account equity turns negative during liquidation (bankruptcy). The repayment amount must be greater than 0 and cannot exceed the remaining loan balance. If the Spot Account has insufficient USDC balance, the repayment will fail.
Weight(UID): 100
Security Type: MARGIN
|
inline |
Asynchronous liquidation_loan_repay().
Completes with void(std::exception_ptr, common::RestApiResponse<LiquidationLoanRepayResponse>).
|
nodiscard |
Margin Account Cancel all Open Orders on a Symbol (TRADE).
DELETE /sapi/v1/margin/openOrders.
Cancels all active orders on a symbol for margin account.
This includes OCO orders.
Weight(IP): 1
Security Type: TRADE
|
inline |
Asynchronous margin_account_cancel_all_open_orders_on_a_symbol().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>).
|
nodiscard |
Query Margin Account's Open Orders (USER_DATA).
GET /sapi/v1/margin/openOrders.
Query Margin Account's Open Orders
Weight(IP): 10
Security Type: USER_DATA
Notes:
|
inline |
Asynchronous query_margin_accounts_open_orders().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryMarginAccountsOpenOrdersResponseInner>>).
|
nodiscard |
Margin Account Cancel OCO (TRADE).
DELETE /sapi/v1/margin/orderList.
Cancel an entire Order List for a margin account.
Weight(UID): 1
Security Type: TRADE
Notes:
|
inline |
Asynchronous margin_account_cancel_oco().
Completes with void(std::exception_ptr, common::RestApiResponse<MarginAccountCancelOcoResponse>).
|
nodiscard |
Query Margin Account's OCO (USER_DATA).
GET /sapi/v1/margin/orderList.
Retrieves a specific OCO based on provided optional parameters
Weight(IP): 10
Security Type: USER_DATA
|
inline |
Asynchronous query_margin_accounts_oco().
Completes with void(std::exception_ptr, common::RestApiResponse<QueryMarginAccountsOcoResponse>).
|
nodiscard |
Margin Account Cancel Order (TRADE).
DELETE /sapi/v1/margin/order.
Cancel an active order for margin account.
Weight(IP): 10
Security Type: TRADE
Notes:
|
inline |
Asynchronous margin_account_cancel_order().
Completes with void(std::exception_ptr, common::RestApiResponse<MarginAccountCancelOrderResponse>).
|
nodiscard |
Margin Account New Order (TRADE).
POST /sapi/v1/margin/order.
Post a new order for margin account.
Weight: 6(UID) or 1500(UID) when sideEffectType is MARGIN_BUY or AUTO_BORROW_REPAY
Security Type: TRADE
Notes:
|
inline |
Asynchronous margin_account_new_order().
Completes with void(std::exception_ptr, common::RestApiResponse<MarginAccountNewOrderResponse>).
|
nodiscard |
Query Margin Account's Order (USER_DATA).
GET /sapi/v1/margin/order.
Query Margin Account's Order
Weight(IP): 10
Security Type: USER_DATA
Notes:
|
inline |
Asynchronous query_margin_accounts_order().
Completes with void(std::exception_ptr, common::RestApiResponse<QueryMarginAccountsOrderResponse>).
|
nodiscard |
Margin Account New OCO (TRADE).
POST /sapi/v1/margin/order/oco.
Send in a new OCO for a margin account
Weight: 6(UID) or 1500(UID) when sideEffectType is MARGIN_BUY or AUTO_BORROW_REPAY
Security Type: TRADE
Notes:
|
inline |
Asynchronous margin_account_new_oco().
Completes with void(std::exception_ptr, common::RestApiResponse<MarginAccountNewOcoResponse>).
|
nodiscard |
Margin Account New OTO (TRADE).
POST /sapi/v1/margin/order/oto.
Post a new OTO order for margin account:
Weight: 6(UID) or 1500(UID) when sideEffectType is MARGIN_BUY or AUTO_BORROW_REPAY
Security Type: TRADE
Notes:
| 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 | | | pendingTrailingDelta is provided | pendingPrice | |
|
inline |
Asynchronous margin_account_new_oto().
Completes with void(std::exception_ptr, common::RestApiResponse<MarginAccountNewOtoResponse>).
|
nodiscard |
Margin Account New OTOCO (TRADE).
POST /sapi/v1/margin/order/otoco.
Post a new OTOCO order for margin account:
Weight: 6(UID) or 1500(UID) when sideEffectType is MARGIN_BUY or AUTO_BORROW_REPAY
Security Type: TRADE
Notes:
|
inline |
Asynchronous margin_account_new_otoco().
Completes with void(std::exception_ptr, common::RestApiResponse<MarginAccountNewOtocoResponse>).
|
nodiscard |
Margin Manual Liquidation (TRADE).
POST /sapi/v1/margin/manual-liquidation.
Margin Manual Liquidation
Weight(UID): 3000
Security Type: TRADE
Notes:
|
inline |
Asynchronous margin_manual_liquidation().
Completes with void(std::exception_ptr, common::RestApiResponse<MarginManualLiquidationResponse>).
|
nodiscard |
Query Current Margin Order Count Usage (TRADE).
GET /sapi/v1/margin/rateLimit/order.
Displays the user's current margin order count usage for all intervals.
Weight(IP): 20
Security Type: TRADE
|
inline |
Asynchronous query_current_margin_order_count_usage().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryCurrentMarginOrderCountUsageResponseInner>>).
|
nodiscard |
Query Liquidation Loan (USER_DATA).
GET /sapi/v1/margin/liquidation-loan.
Query the current user's cross-margin liquidation loan information, including the original loan amount, repaid amount, and remaining amount. When a cross-margin account is liquidated and the account equity turns negative (bankruptcy), the system generates a liquidation loan record representing the deficit. This represents the shortfall amount denominated in USDC.
Weight(UID): 100
Security Type: USER_DATA
|
inline |
Asynchronous query_liquidation_loan().
Completes with void(std::exception_ptr, common::RestApiResponse<QueryLiquidationLoanResponse>).
|
nodiscard |
Query Liquidation Loan Repay History (USER_DATA).
GET /sapi/v1/margin/liquidation-loan/repay-history.
Query the repayment history of cross-margin liquidation loans (deficit caused by bankruptcy during liquidation). Supports time-range filtering and pagination.
Weight(UID): 100
Security Type: USER_DATA
Notes:
|
inline |
Asynchronous query_liquidation_loan_repay_history().
Completes with void(std::exception_ptr, common::RestApiResponse<QueryLiquidationLoanRepayHistoryResponse>).
|
nodiscard |
Query Margin Account's all OCO (USER_DATA).
GET /sapi/v1/margin/allOrderList.
Retrieves all OCO for a specific margin account based on provided optional parameters
Weight(IP): 200
Security Type: USER_DATA
|
inline |
Asynchronous query_margin_accounts_all_oco().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryMarginAccountsAllOcoResponseInner>>).
|
nodiscard |
Query Margin Account's All Orders (USER_DATA).
GET /sapi/v1/margin/allOrders.
Query Margin Account's All Orders
Weight(IP): 200
Security Type: USER_DATA
Notes:
|
inline |
Asynchronous query_margin_accounts_all_orders().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryMarginAccountsAllOrdersResponseInner>>).
|
nodiscard |
Query Margin Account's Open OCO (USER_DATA).
GET /sapi/v1/margin/openOrderList.
Query Margin Account's Open OCO
Weight(IP): 10
Security Type: USER_DATA
|
inline |
Asynchronous query_margin_accounts_open_oco().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryMarginAccountsOpenOcoResponseInner>>).
|
nodiscard |
Query Margin Account's Open OTO/OTOCO Order Lists (USER_DATA).
GET /sapi/v1/margin/oto/openOrderList.
Retrieves all open OTO / OTOCO order lists of the margin account.
Notes:
Weight(UID): 10
Security Type: USER_DATA
|
inline |
Asynchronous query_margin_accounts_open_otootoco_order_lists().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryMarginAccountsOpenOtootocoOrderListsResponseInner>>).
|
nodiscard |
Query Margin Account's Trade List (USER_DATA).
GET /sapi/v1/margin/myTrades.
Query Margin Account's Trade List
Weight(IP): 10
Security Type: USER_DATA
Notes:
|
inline |
Asynchronous query_margin_accounts_trade_list().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryMarginAccountsTradeListResponseInner>>).
|
nodiscard |
Query Prevented Matches (USER_DATA).
GET /sapi/v1/margin/myPreventedMatches.
Displays the list of orders that were expired due to STP. (Self-Trade Prevention).
Weight(IP): 10
Security Type: USER_DATA
Notes:
|
inline |
Asynchronous query_prevented_matches().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QueryPreventedMatchesResponseInner>>).
|
nodiscard |
Query Special key List(Low Latency Trading) (TRADE).
GET /sapi/v1/margin/api-key-list.
This only applies to Special Key for Low Latency Trading.
Weight(UID): 1
Security Type: TRADE
|
inline |
Asynchronous query_special_key_list().
Completes with void(std::exception_ptr, common::RestApiResponse<std::vector<QuerySpecialKeyListResponseInner>>).