Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
Loading...
Searching...
No Matches
binance::stock_options::rest_api::TradeApi Class Reference

#include <trade_api.hpp>

Public Member Functions

 TradeApi (std::shared_ptr< common::RestClient > client)
common::RestApiResponse< CancelAllOptionOrdersResponse > cancel_all_option_orders (const CancelAllOptionOrdersParams &params={}) const
 Cancel All Option Orders (TRADE).
template<class CompletionToken>
auto async_cancel_all_option_orders (const CancelAllOptionOrdersParams &params, CompletionToken &&token) const
 Asynchronous cancel_all_option_orders().
common::RestApiResponse< CancelOptionOrderResponse > cancel_option_order (const CancelOptionOrderParams &params) const
 Cancel Option Order (TRADE).
template<class CompletionToken>
auto async_cancel_option_order (const CancelOptionOrderParams &params, CompletionToken &&token) const
 Asynchronous cancel_option_order().
common::RestApiResponse< PlaceOptionOrderResponse > place_option_order (const PlaceOptionOrderParams &params) const
 Place Option Order (TRADE).
template<class CompletionToken>
auto async_place_option_order (const PlaceOptionOrderParams &params, CompletionToken &&token) const
 Asynchronous place_option_order().
common::RestApiResponse< SubmitOptionExerciseResponse > submit_option_exercise (const SubmitOptionExerciseParams &params) const
 Submit Option Exercise (TRADE).
template<class CompletionToken>
auto async_submit_option_exercise (const SubmitOptionExerciseParams &params, CompletionToken &&token) const
 Asynchronous submit_option_exercise().

Constructor & Destructor Documentation

◆ TradeApi()

binance::stock_options::rest_api::TradeApi::TradeApi ( std::shared_ptr< common::RestClient > client)
explicit

Member Function Documentation

◆ cancel_all_option_orders()

common::RestApiResponse< CancelAllOptionOrdersResponse > binance::stock_options::rest_api::TradeApi::cancel_all_option_orders ( const CancelAllOptionOrdersParams & params = {}) const
nodiscard

Cancel All Option Orders (TRADE).

POST /sapi/v1/equity/option/order/cancel-all.

Cancel all of the caller's open orders.

This also cancels open stock orders. Cancel-all is account-level at the broker and does not distinguish asset classes; it is the same operation as /sapi/v1/equity/order/cancel-all.

To cancel option orders only, fetch them with Current Open Option Orders and cancel each one with Cancel Option Order.

Errors on this endpoint use the Stocks Trading error codes (486xxx). See Stocks Trading Error Code.

Weight: 1

Security Type: TRADE

See https://developers.binance.com/en/docs/catalog/advanced-trading-stock-option-trading/api/rest-api/trade#cancel-all-option-orders

◆ async_cancel_all_option_orders()

template<class CompletionToken>
auto binance::stock_options::rest_api::TradeApi::async_cancel_all_option_orders ( const CancelAllOptionOrdersParams & params,
CompletionToken && token ) const
inline

Asynchronous cancel_all_option_orders().

Completes with void(std::exception_ptr, common::RestApiResponse<CancelAllOptionOrdersResponse>).

◆ cancel_option_order()

common::RestApiResponse< CancelOptionOrderResponse > binance::stock_options::rest_api::TradeApi::cancel_option_order ( const CancelOptionOrderParams & params) const
nodiscard

Cancel Option Order (TRADE).

POST /sapi/v1/equity/option/order/cancel.

Cancel an open order by orderId.

Cancellation applies to the caller's own brokerage account and is not restricted by asset class: passing the orderId of a stock order also cancels it, and /sapi/v1/equity/order/cancel can likewise cancel option orders. Only the caller's own orders can be canceled.

Errors on this endpoint use the Stocks Trading error codes (486xxx). See Stocks Trading Error Code.

Weight: 1

Security Type: TRADE

See https://developers.binance.com/en/docs/catalog/advanced-trading-stock-option-trading/api/rest-api/trade#cancel-option-order

◆ async_cancel_option_order()

template<class CompletionToken>
auto binance::stock_options::rest_api::TradeApi::async_cancel_option_order ( const CancelOptionOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous cancel_option_order().

Completes with void(std::exception_ptr, common::RestApiResponse<CancelOptionOrderResponse>).

◆ place_option_order()

common::RestApiResponse< PlaceOptionOrderResponse > binance::stock_options::rest_api::TradeApi::place_option_order ( const PlaceOptionOrderParams & params) const
nodiscard

Place Option Order (TRADE).

POST /sapi/v1/equity/option/order/place.

Place an option limit order.

The server calculates the amount to lock based on positionIntent and the contract type: buy to open locks the premium plus fees; sell to open locks the underlying shares for a covered call, or the strike-equivalent cash for a cash-secured put. Fees are calculated by the server; callers do not pass payment details.

positionIntent: may be omitted, in which case it is derived from side: BUY → BUY_TO_OPEN, SELL → SELL_TO_CLOSE. The derivation is unreliable in two cases, and an order without positionIntent is rejected (parameter error): a BUY while you hold a short position in the contract (it may be meant as BUY_TO_CLOSE), and a SELL while you hold no long position in the contract (it can only be SELL_TO_OPEN). Therefore always pass it for the short side (SELL_TO_OPEN / BUY_TO_CLOSE). When passed, it must match side (BUY_* with BUY, SELL_* with SELL), otherwise the order is rejected.

Only LIMIT orders with timeInForce = DAY are supported, and quantity must be a whole number of contracts.

Resubmitting with the same clientOrderId is idempotent: if the original order was accepted or is still processing, the original order is returned (S / P); if the original order failed, 497401 is returned.

If the request returns 497001, 497301 or a broker-rejection error code after the order has already been submitted to the broker, the order may still be processing. Retry with the same clientOrderId (a replay then returns P) or query Option Order Detail by clientOrderId for the final status. Do not retry with a new clientOrderId.

Rate limit: 200 requests / min (UID).

Weight: 1

Security Type: TRADE

See https://developers.binance.com/en/docs/catalog/advanced-trading-stock-option-trading/api/rest-api/trade#place-option-order

◆ async_place_option_order()

template<class CompletionToken>
auto binance::stock_options::rest_api::TradeApi::async_place_option_order ( const PlaceOptionOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous place_option_order().

Completes with void(std::exception_ptr, common::RestApiResponse<PlaceOptionOrderResponse>).

◆ submit_option_exercise()

common::RestApiResponse< SubmitOptionExerciseResponse > binance::stock_options::rest_api::TradeApi::submit_option_exercise ( const SubmitOptionExerciseParams & params) const
nodiscard

Submit Option Exercise (TRADE).

POST /sapi/v1/equity/option/exercise/submit.

Submit an exercise request for a long option position.

Requires the TRADE permission, because exercising changes positions and balances.

Exercise is asynchronous. The request returns PROCESSING; delivery is handled by the broker. Poll Option Exercise Detail for the final status.

quantity cannot exceed availableQty from Exercisable Options.

Resubmitting with the same clientOrderId is idempotent: if the original exercise was accepted or is still processing, it is returned with its current status; if it failed, 497401 is returned. If the request returns 497001, 497301 or a broker-rejection error code, the exercise may still be processing: retry with the same clientOrderId or query Option Exercise Detail by clientOrderId. Do not resubmit with a new clientOrderId.

Weight: 1

Security Type: TRADE

See https://developers.binance.com/en/docs/catalog/advanced-trading-stock-option-trading/api/rest-api/trade#submit-option-exercise

◆ async_submit_option_exercise()

template<class CompletionToken>
auto binance::stock_options::rest_api::TradeApi::async_submit_option_exercise ( const SubmitOptionExerciseParams & params,
CompletionToken && token ) const
inline

Asynchronous submit_option_exercise().

Completes with void(std::exception_ptr, common::RestApiResponse<SubmitOptionExerciseResponse>).