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

#include <trade_api.hpp>

Public Member Functions

 TradeApi (std::shared_ptr< common::WebsocketApi > client)
common::WebsocketApiResponse< CancelAlgoOrderResponseResult > cancel_algo_order (const CancelAlgoOrderParams &params={}) const
 Cancel Algo Order (TRADE).
template<class CompletionToken>
auto async_cancel_algo_order (const CancelAlgoOrderParams &params, CompletionToken &&token) const
 Asynchronous cancel_algo_order().
common::WebsocketApiResponse< CancelOrderResponseResult > cancel_order (const CancelOrderParams &params) const
 Cancel Order (TRADE).
template<class CompletionToken>
auto async_cancel_order (const CancelOrderParams &params, CompletionToken &&token) const
 Asynchronous cancel_order().
common::WebsocketApiResponse< ModifyOrderResponseResult > modify_order (const ModifyOrderParams &params) const
 Modify Order (TRADE).
template<class CompletionToken>
auto async_modify_order (const ModifyOrderParams &params, CompletionToken &&token) const
 Asynchronous modify_order().
common::WebsocketApiResponse< NewAlgoOrderResponseResult > new_algo_order (const NewAlgoOrderParams &params) const
 New Algo Order (TRADE).
template<class CompletionToken>
auto async_new_algo_order (const NewAlgoOrderParams &params, CompletionToken &&token) const
 Asynchronous new_algo_order().
common::WebsocketApiResponse< NewOrderResponseResult > new_order (const NewOrderParams &params) const
 New Order (TRADE).
template<class CompletionToken>
auto async_new_order (const NewOrderParams &params, CompletionToken &&token) const
 Asynchronous new_order().
common::WebsocketApiResponse< std::vector< PositionInformationResponseResultInner > > position_information (const PositionInformationParams &params={}) const
 Position Information (USER_DATA).
template<class CompletionToken>
auto async_position_information (const PositionInformationParams &params, CompletionToken &&token) const
 Asynchronous position_information().
common::WebsocketApiResponse< std::vector< PositionInformationV2ResponseResultInner > > position_information_v2 (const PositionInformationV2Params &params={}) const
 Position Information V2 (USER_DATA).
template<class CompletionToken>
auto async_position_information_v2 (const PositionInformationV2Params &params, CompletionToken &&token) const
 Asynchronous position_information_v2().
common::WebsocketApiResponse< QueryOrderResponseResult > query_order (const QueryOrderParams &params) const
 Query Order (USER_DATA).
template<class CompletionToken>
auto async_query_order (const QueryOrderParams &params, CompletionToken &&token) const
 Asynchronous query_order().

Constructor & Destructor Documentation

◆ TradeApi()

binance::derivatives_trading_usds_futures::websocket_api::TradeApi::TradeApi ( std::shared_ptr< common::WebsocketApi > client)
explicit

Member Function Documentation

◆ cancel_algo_order()

common::WebsocketApiResponse< CancelAlgoOrderResponseResult > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::cancel_algo_order ( const CancelAlgoOrderParams & params = {}) const
nodiscard

Cancel Algo Order (TRADE).

algoOrder.cancel.

Cancel an active algo order.

Weight(IP): 1

Security Type: TRADE

Notes:

  • Either algoId or clientAlgoId must be sent.

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#cancel-algo-order

◆ async_cancel_algo_order()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_cancel_algo_order ( const CancelAlgoOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous cancel_algo_order().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<CancelAlgoOrderResponseResult>).

◆ cancel_order()

common::WebsocketApiResponse< CancelOrderResponseResult > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::cancel_order ( const CancelOrderParams & params) const
nodiscard

Cancel Order (TRADE).

order.cancel.

Cancel an active order.

Weight(IP): 1

Security Type: TRADE

Notes:

  • Either orderId or origClientOrderId must be sent.

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#cancel-order

◆ async_cancel_order()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_cancel_order ( const CancelOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous cancel_order().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<CancelOrderResponseResult>).

◆ modify_order()

common::WebsocketApiResponse< ModifyOrderResponseResult > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::modify_order ( const ModifyOrderParams & params) const
nodiscard

Modify Order (TRADE).

order.modify.

Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue

Weight: 1 on 10s order rate limit(X-MBX-ORDER-COUNT-10S); 1 on 1min order rate limit(X-MBX-ORDER-COUNT-1M); 0 on IP rate limit(x-mbx-used-weight-1m)

Security Type: TRADE

Notes:

  • Either orderId or origClientOrderId must be sent, and the orderId will prevail if both are sent.
  • Both quantity and price must be sent. (After CM migration, the dapi modify order endpoint follows the same rule.)
  • When the new quantity or price doesn't satisfy PRICE_FILTER / PERCENT_FILTER / LOT_SIZE, amendment will be rejected and the order will stay as it is.
  • However the order will be cancelled by the amendment in the following situations:
  • when the order is in partially filled status and the new quantity <= executedQty
  • When the order is GTX and the new price will cause it to be executed immediately
  • One order can only be modfied for less than 10000 times
  • reduceOnly behavior:
    • false or omitted: behave as today — min_notional is enforced on the modified order.
    • true and the original order's reduceOnly attribute is also true (consistent): the min_notional check is skipped on the modified order, matching placement semantics.
    • true but the original order's reduceOnly attribute is false (inconsistent): the modify request is rejected with error code -5047, "The original order is not a reduce-only order".
    • reduceOnly is used purely for validation — passing true does not change the original order's reduceOnly attribute; that flag remains whatever it was set to at placement time.

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#modify-order

◆ async_modify_order()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_modify_order ( const ModifyOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous modify_order().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<ModifyOrderResponseResult>).

◆ new_algo_order()

common::WebsocketApiResponse< NewAlgoOrderResponseResult > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::new_algo_order ( const NewAlgoOrderParams & params) const
nodiscard

New Algo Order (TRADE).

algoOrder.place.

Send in a new algo order.

Weight(IP): 0

Security Type: TRADE

Notes:

  • Condition orders will be triggered when:

  • If parameterpriceProtectis sent as true:
  • when price reaches the triggerPrice ,the difference rate between "MARK_PRICE" and "CONTRACT_PRICE" cannot be larger than the "triggerProtect" of the symbol
  • "triggerProtect" of a symbol can be got from GET /fapi/v1/exchangeInfo

  • STOP, STOP_MARKET:
  • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= triggerPrice
  • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <= triggerPrice
  • TAKE_PROFIT, TAKE_PROFIT_MARKET:
  • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <= triggerPrice
  • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= triggerPrice
  • TRAILING_STOP_MARKET:
  • BUY: the lowest price after order placed <= activatePrice, and the latest price >= the lowest price * (1 + callbackRate)
  • SELL: the highest price after order placed >= activatePrice, and the latest price <= the highest price * (1 - callbackRate)

  • For TRAILING_STOP_MARKET, if you got such error code.

{"code": -2021, "msg": "Order would immediately trigger."}

means that the parameters you send do not meet the following requirements:

  • BUY: activatePrice should be smaller than latest price.
  • SELL: activatePrice should be larger than latest price.

  • STOP_MARKET, TAKE_PROFIT_MARKET with closePosition=true:
  • Follow the same rules for condition orders.
  • If triggered,**close all** current long position( if SELL) or current short position( if BUY).
  • Cannot be used with quantity paremeter
  • Cannot be used with reduceOnly parameter
  • In Hedge Mode,cannot be used with BUY orders in LONG position side. and cannot be used with SELL orders in SHORT position side
  • selfTradePreventionMode is only effective when timeInForce set to IOC or GTC or GTD.

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#new-algo-order

◆ async_new_algo_order()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_new_algo_order ( const NewAlgoOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous new_algo_order().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<NewAlgoOrderResponseResult>).

◆ new_order()

common::WebsocketApiResponse< NewOrderResponseResult > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::new_order ( const NewOrderParams & params) const
nodiscard

New Order (TRADE).

order.place.

Send in a new order.

Weight(IP): 0

Security Type: TRADE

Notes: Additional mandatory parameters based on type:

  • LIMIT: timeInForce, quantity, price
  • MARKET: quantity
  • If newOrderRespType is sent as RESULT:
    • MARKET order: the final FILLED result of the order will be return directly.
    • LIMIT order with special timeInForce: the final status result of the order(FILLED or EXPIRED) will be returned directly.
  • selfTradePreventionMode is only effective when timeInForce set to IOC or GTC or GTD. > * In extreme market conditions, timeInForce GTD order auto cancel time might be delayed comparing to goodTillDate

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#new-order

◆ async_new_order()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_new_order ( const NewOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous new_order().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<NewOrderResponseResult>).

◆ position_information()

common::WebsocketApiResponse< std::vector< PositionInformationResponseResultInner > > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::position_information ( const PositionInformationParams & params = {}) const
nodiscard

Position Information (USER_DATA).

account.position.

Get current position information.

Weight(IP): 5

Security Type: USER_DATA

Notes:

  • Please use with user data stream ACCOUNT_UPDATE to meet your timeliness and accuracy needs.

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#position-information

◆ async_position_information()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_position_information ( const PositionInformationParams & params,
CompletionToken && token ) const
inline

Asynchronous position_information().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<PositionInformationResponseResultInner>>).

◆ position_information_v2()

common::WebsocketApiResponse< std::vector< PositionInformationV2ResponseResultInner > > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::position_information_v2 ( const PositionInformationV2Params & params = {}) const
nodiscard

Position Information V2 (USER_DATA).

v2/account.position.

Get current position information(only symbol that has position or open orders will be returned).

Weight(IP): 5

Security Type: USER_DATA

Notes:

  • Please use with user data stream ACCOUNT_UPDATE to meet your timeliness and accuracy needs.

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#position-information-v2

◆ async_position_information_v2()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_position_information_v2 ( const PositionInformationV2Params & params,
CompletionToken && token ) const
inline

Asynchronous position_information_v2().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<PositionInformationV2ResponseResultInner>>).

◆ query_order()

common::WebsocketApiResponse< QueryOrderResponseResult > binance::derivatives_trading_usds_futures::websocket_api::TradeApi::query_order ( const QueryOrderParams & params) const
nodiscard

Query Order (USER_DATA).

order.status.

Check an order's status.

  • These orders will not be found:
    • order status is CANCELED or EXPIRED AND order has NO filled trade AND created time + 3 days < current time
    • order create time + 90 days < current time

Weight(IP): 1

Security Type: USER_DATA

Notes: Notes:

  • Either orderId or origClientOrderId must be sent.
  • orderId is self-increment for each specific symbol

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-api/trade#query-order

◆ async_query_order()

template<class CompletionToken>
auto binance::derivatives_trading_usds_futures::websocket_api::TradeApi::async_query_order ( const QueryOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous query_order().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<QueryOrderResponseResult>).