Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
Loading...
Searching...
No Matches
binance::derivatives_trading_coin_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< 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_coin_futures::websocket_api::TradeApi::TradeApi ( std::shared_ptr< common::WebsocketApi > client)
explicit

Member Function Documentation

◆ cancel_algo_order()

common::WebsocketApiResponse< CancelAlgoOrderResponseResult > binance::derivatives_trading_coin_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-coin-m-futures/api/ws-api/trade#cancel-algo-order

◆ async_cancel_algo_order()

template<class CompletionToken>
auto binance::derivatives_trading_coin_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_coin_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-coin-m-futures/api/ws-api/trade#cancel-order

◆ async_cancel_order()

template<class CompletionToken>
auto binance::derivatives_trading_coin_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_coin_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.
  • 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 modified for less than 10000 times.

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

◆ async_modify_order()

template<class CompletionToken>
auto binance::derivatives_trading_coin_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_coin_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 /dapi/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 parameter
  • 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.

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

◆ async_new_algo_order()

template<class CompletionToken>
auto binance::derivatives_trading_coin_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_coin_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: | Type | Additional mandatory parameters | | :—: | — | | LIMIT | timeInForce, quantity, price | | MARKET | quantity | | STOP/TAKE_PROFIT | quantity, price, stopPrice | | STOP_MARKET/TAKE_PROFIT_MARKET | stopPrice | | TRAILING_STOP_MARKET | callbackRate |
    • Order with type STOP, parameter timeInForce can be sent ( default GTC). * Order with type TAKE_PROFIT, parameter timeInForce can be sent ( default GTC). * Condition orders will be triggered when:
    • If parameter priceProtect is sent as true:
    • when price reaches the stopPrice,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 /dapi/v1/exchangeInfo
    • STOP, STOP_MARKET:
    • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= stopPrice
    • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <= stopPrice
    • TAKE_PROFIT, TAKE_PROFIT_MARKET:
    • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <= stopPrice
    • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= stopPrice
    • TRAILING_STOP_MARKET:
    • BUY: the lowest price after order placed <= activationPrice, and the latest price >= the lowest price * (1 + callbackRate)
    • SELL: the highest price after order placed >= activationPrice, and the latest price <= the highest price * (1 - callbackRate)
    • For TRAILING_STOP_MARKET, if you got such error code.
    • BUY: activationPrice should be smaller than latest price.
    • SELL: activationPrice should be larger than latest price.
    • 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.
    • 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 parameter
    • 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

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

◆ async_new_order()

template<class CompletionToken>
auto binance::derivatives_trading_coin_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_coin_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-coin-m-futures/api/ws-api/trade#position-information

◆ async_position_information()

template<class CompletionToken>
auto binance::derivatives_trading_coin_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>>).

◆ query_order()

common::WebsocketApiResponse< QueryOrderResponseResult > binance::derivatives_trading_coin_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:

  • Either orderId or origClientOrderId must be sent.

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

◆ async_query_order()

template<class CompletionToken>
auto binance::derivatives_trading_coin_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>).