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

#include <trade_api.hpp>

Public Member Functions

 TradeApi (std::shared_ptr< common::RestClient > client)
common::RestApiResponse< BatchCancelOrdersResponse > batch_cancel_orders (const BatchCancelOrdersParams &params) const
 Batch Cancel Orders (PREDICTION_TRADE).
template<class CompletionToken>
auto async_batch_cancel_orders (const BatchCancelOrdersParams &params, CompletionToken &&token) const
 Asynchronous batch_cancel_orders().
common::RestApiResponse< GetQuoteResponse > get_quote (const GetQuoteParams &params) const
 Get Quote (PREDICTION_TRADE).
template<class CompletionToken>
auto async_get_quote (const GetQuoteParams &params, CompletionToken &&token) const
 Asynchronous get_quote().
common::RestApiResponse< PlaceOrderResponse > place_order (const PlaceOrderParams &params) const
 Place Order (PREDICTION_TRADE).
template<class CompletionToken>
auto async_place_order (const PlaceOrderParams &params, CompletionToken &&token) const
 Asynchronous place_order().
common::RestApiResponse< QueryActiveOrdersResponse > query_active_orders (const QueryActiveOrdersParams &params) const
 Query Active Orders (PREDICTION_TRADE).
template<class CompletionToken>
auto async_query_active_orders (const QueryActiveOrdersParams &params, CompletionToken &&token) const
 Asynchronous query_active_orders().
common::RestApiResponse< QueryOrderHistoryResponse > query_order_history (const QueryOrderHistoryParams &params) const
 Query Order History (PREDICTION_TRADE).
template<class CompletionToken>
auto async_query_order_history (const QueryOrderHistoryParams &params, CompletionToken &&token) const
 Asynchronous query_order_history().

Constructor & Destructor Documentation

◆ TradeApi()

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

Member Function Documentation

◆ batch_cancel_orders()

common::RestApiResponse< BatchCancelOrdersResponse > binance::w3w_prediction::rest_api::TradeApi::batch_cancel_orders ( const BatchCancelOrdersParams & params) const
nodiscard

Batch Cancel Orders (PREDICTION_TRADE).

POST /sapi/v1/w3w/wallet/prediction/trade/batch-cancel.

Cancel one or more active prediction orders in a single request. Requires SAS authorization.

Known Issue — Bracket Encoding Incompatibility: This endpoint uses indexed bracket notation (cancelInfoList[0].orderId). Binance SAPI signature verification runs over the raw, unencoded canonical string. However, mainstream HTTP libraries (Python requests, Java HttpURLConnection/URI, Go net/url, Node.js url) automatically percent-encode [ → %5B and ] → %5D, producing a signature mismatch with error -1022 Signature for this request is not valid. Postman is unaffected because it does not encode keys.

Workarounds (use low-level HTTP APIs that do not normalize URLs):

  • Python: use http.client (stdlib) and hand-build the body string.
  • Java: use HttpURLConnection and write the raw body bytes directly.
  • Go: use strings.NewReader with a hand-built body instead of url.Values.Encode().

Weight(IP): 1

Security Type: PREDICTION_TRADE

Notes:

  • Use dot notation for nested list fields: cancelInfoList[0].orderId, cancelInfoList[1].orderId, etc.
  • vendor does not need to be supplied. The server automatically sets the correct vendor (predict_fun) for every item in the batch.

See https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#batch-cancel-orders

◆ async_batch_cancel_orders()

template<class CompletionToken>
auto binance::w3w_prediction::rest_api::TradeApi::async_batch_cancel_orders ( const BatchCancelOrdersParams & params,
CompletionToken && token ) const
inline

Asynchronous batch_cancel_orders().

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

◆ get_quote()

common::RestApiResponse< GetQuoteResponse > binance::w3w_prediction::rest_api::TradeApi::get_quote ( const GetQuoteParams & params) const
nodiscard

Get Quote (PREDICTION_TRADE).

POST /sapi/v1/w3w/wallet/prediction/trade/get-quote.

Get a price quote for a prediction order. The returned quoteId must be used in the subsequent Place Order request.

Weight(IP): 1

Security Type: PREDICTION_TRADE

Response Notes:

  • feeAmount is a string because it is denominated in wei (18 decimals) and may exceed JavaScript's safe integer range. feeDiscountBps is also a string to allow fractional basis-point values in the future. feeRateBps and slippageBps are integers and will never exceed safe integer bounds.
  • Minimum order amount: The minimum order amount is set by the server and the upstream market rules and may change, so no fixed value is documented. BUY orders are checked by amount (amountIn) and SELL orders by share quantity, for both MARKET and LIMIT orders. If the amountIn of a BUY order is below the minimum, the server returns -9000 with the message Your order amount is too small. A successful quote does not guarantee that the order is accepted or filled, so check the error message and the final order status.

See https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#get-quote

◆ async_get_quote()

template<class CompletionToken>
auto binance::w3w_prediction::rest_api::TradeApi::async_get_quote ( const GetQuoteParams & params,
CompletionToken && token ) const
inline

Asynchronous get_quote().

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

◆ place_order()

common::RestApiResponse< PlaceOrderResponse > binance::w3w_prediction::rest_api::TradeApi::place_order ( const PlaceOrderParams & params) const
nodiscard

Place Order (PREDICTION_TRADE).

POST /sapi/v1/w3w/wallet/prediction/trade/place-order-bundle.

Place a prediction order using a previously obtained quote. Requires SAS authorization.

Weight(IP): 1

Security Type: PREDICTION_TRADE

Notes:

  • Validation rules:
orderType timeInForce priceLimit
MARKET Must be FOK Not required
LIMIT Must be GTC Required, must be > 0

See https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#place-order

◆ async_place_order()

template<class CompletionToken>
auto binance::w3w_prediction::rest_api::TradeApi::async_place_order ( const PlaceOrderParams & params,
CompletionToken && token ) const
inline

Asynchronous place_order().

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

◆ query_active_orders()

common::RestApiResponse< QueryActiveOrdersResponse > binance::w3w_prediction::rest_api::TradeApi::query_active_orders ( const QueryActiveOrdersParams & params) const
nodiscard

Query Active Orders (PREDICTION_TRADE).

GET /sapi/v1/w3w/wallet/prediction/order/list.

Get active (open) prediction orders for the authenticated user.

Weight(IP): 1

Security Type: PREDICTION_TRADE

See https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#query-active-orders

◆ async_query_active_orders()

template<class CompletionToken>
auto binance::w3w_prediction::rest_api::TradeApi::async_query_active_orders ( const QueryActiveOrdersParams & params,
CompletionToken && token ) const
inline

Asynchronous query_active_orders().

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

◆ query_order_history()

common::RestApiResponse< QueryOrderHistoryResponse > binance::w3w_prediction::rest_api::TradeApi::query_order_history ( const QueryOrderHistoryParams & params) const
nodiscard

Query Order History (PREDICTION_TRADE).

GET /sapi/v1/w3w/wallet/prediction/order/history.

Get historical prediction orders (all statuses) for the authenticated user, with optional filters.

Weight(IP): 1

Security Type: PREDICTION_TRADE

See https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#query-order-history

◆ async_query_order_history()

template<class CompletionToken>
auto binance::w3w_prediction::rest_api::TradeApi::async_query_order_history ( const QueryOrderHistoryParams & params,
CompletionToken && token ) const
inline

Asynchronous query_order_history().

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