|
Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
|
Stocks REST API client. More...
#include <rest_api.hpp>
Public Member Functions | |
| RestApi (common::RestApiConfig configuration) | |
| Throws common::ConfigError if the configuration is invalid. | |
| const common::RestApiConfig & | configuration () const noexcept |
| template<class T> | |
| common::RestApiResponse< T > | send_request (std::string endpoint, common::HttpMethod method, common::Params query={}, common::Params body={}) const |
| Calls an endpoint the SDK does not wrap yet. T may be boost::json::value. | |
| template<class T> | |
| common::RestApiResponse< T > | send_signed_request (std::string endpoint, common::HttpMethod method, common::Params query={}, common::Params body={}) const |
| Like send_request, but signed (adds timestamp and signature). | |
| template<class T, class CompletionToken> | |
| auto | async_send_request (std::string endpoint, common::HttpMethod method, common::Params query, common::Params body, CompletionToken &&token) const |
| template<class T, class CompletionToken> | |
| auto | async_send_signed_request (std::string endpoint, common::HttpMethod method, common::Params query, common::Params body, CompletionToken &&token) const |
| common::RestApiResponse< SignUsEquityDisclaimerResponse > | sign_us_equity_disclaimer (const SignUsEquityDisclaimerParams ¶ms={}) const |
| Sign US Equity Disclaimer (TRADE). | |
| template<class CompletionToken> | |
| auto | async_sign_us_equity_disclaimer (const SignUsEquityDisclaimerParams ¶ms, CompletionToken &&token) const |
| Asynchronous sign_us_equity_disclaimer(). | |
| common::RestApiResponse< ExchangeInfoResponse > | exchange_info (const ExchangeInfoParams ¶ms={}) const |
| Exchange Info (MARKET_DATA). | |
| template<class CompletionToken> | |
| auto | async_exchange_info (const ExchangeInfoParams ¶ms, CompletionToken &&token) const |
| Asynchronous exchange_info(). | |
| common::RestApiResponse< LatestQuoteResponse > | latest_quote (const LatestQuoteParams ¶ms) const |
| Latest Quote (MARKET_DATA). | |
| template<class CompletionToken> | |
| auto | async_latest_quote (const LatestQuoteParams ¶ms, CompletionToken &&token) const |
| Asynchronous latest_quote(). | |
| common::RestApiResponse< std::vector< TokenizedAssetsResponseInner > > | tokenized_assets () const |
| Tokenized Assets (MARKET_DATA). | |
| template<class CompletionToken> | |
| auto | async_tokenized_assets (CompletionToken &&token) const |
| Asynchronous tokenized_assets(). | |
| common::RestApiResponse< BstocksCorporateActionRecordsResponse > | bstocks_corporate_action_records (const BstocksCorporateActionRecordsParams ¶ms) const |
| Bstocks Corporate Action Records (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_bstocks_corporate_action_records (const BstocksCorporateActionRecordsParams ¶ms, CompletionToken &&token) const |
| Asynchronous bstocks_corporate_action_records(). | |
| common::RestApiResponse< CorporateActionRecordsResponse > | corporate_action_records (const CorporateActionRecordsParams ¶ms) const |
| Corporate Action Records (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_corporate_action_records (const CorporateActionRecordsParams ¶ms, CompletionToken &&token) const |
| Asynchronous corporate_action_records(). | |
| common::RestApiResponse< TokenizedConvertHistoryResponse > | tokenized_convert_history (const TokenizedConvertHistoryParams ¶ms={}) const |
| Tokenized Convert History (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_tokenized_convert_history (const TokenizedConvertHistoryParams ¶ms, CompletionToken &&token) const |
| Asynchronous tokenized_convert_history(). | |
| common::RestApiResponse< TokenizedConvertStatusResponse > | tokenized_convert_status (const TokenizedConvertStatusParams ¶ms) const |
| Tokenized Convert Status (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_tokenized_convert_status (const TokenizedConvertStatusParams ¶ms, CompletionToken &&token) const |
| Asynchronous tokenized_convert_status(). | |
| common::RestApiResponse< TokenizedMintResponse > | tokenized_mint (const TokenizedMintParams ¶ms) const |
| Tokenized Mint (TRADE). | |
| template<class CompletionToken> | |
| auto | async_tokenized_mint (const TokenizedMintParams ¶ms, CompletionToken &&token) const |
| Asynchronous tokenized_mint(). | |
| common::RestApiResponse< TokenizedRedeemResponse > | tokenized_redeem (const TokenizedRedeemParams ¶ms) const |
| Tokenized Redeem (TRADE). | |
| template<class CompletionToken> | |
| auto | async_tokenized_redeem (const TokenizedRedeemParams ¶ms, CompletionToken &&token) const |
| Asynchronous tokenized_redeem(). | |
| common::RestApiResponse< CancelAllEquityOrdersResponse > | cancel_all_equity_orders (const CancelAllEquityOrdersParams ¶ms={}) const |
| Cancel All Equity Orders (TRADE). | |
| template<class CompletionToken> | |
| auto | async_cancel_all_equity_orders (const CancelAllEquityOrdersParams ¶ms, CompletionToken &&token) const |
| Asynchronous cancel_all_equity_orders(). | |
| common::RestApiResponse< CancelEquityOrderResponse > | cancel_equity_order (const CancelEquityOrderParams ¶ms) const |
| Cancel Equity Order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_cancel_equity_order (const CancelEquityOrderParams ¶ms, CompletionToken &&token) const |
| Asynchronous cancel_equity_order(). | |
| common::RestApiResponse< std::vector< CurrentOpenOrdersResponseInner > > | current_open_orders (const CurrentOpenOrdersParams ¶ms={}) const |
| Current Open Orders (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_current_open_orders (const CurrentOpenOrdersParams ¶ms, CompletionToken &&token) const |
| Asynchronous current_open_orders(). | |
| common::RestApiResponse< EquityOrderDetailResponse > | equity_order_detail (const EquityOrderDetailParams ¶ms={}) const |
| Equity Order Detail (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_equity_order_detail (const EquityOrderDetailParams ¶ms, CompletionToken &&token) const |
| Asynchronous equity_order_detail(). | |
| common::RestApiResponse< EquityOrderHistoryResponse > | equity_order_history (const EquityOrderHistoryParams ¶ms) const |
| Equity Order History (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_equity_order_history (const EquityOrderHistoryParams ¶ms, CompletionToken &&token) const |
| Asynchronous equity_order_history(). | |
| common::RestApiResponse< EquityTradeHistoryResponse > | equity_trade_history (const EquityTradeHistoryParams ¶ms) const |
| Equity Trade History (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_equity_trade_history (const EquityTradeHistoryParams ¶ms, CompletionToken &&token) const |
| Asynchronous equity_trade_history(). | |
| common::RestApiResponse< PlaceEquityOrderResponse > | place_equity_order (const PlaceEquityOrderParams ¶ms) const |
| Place Equity Order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_place_equity_order (const PlaceEquityOrderParams ¶ms, CompletionToken &&token) const |
| Asynchronous place_equity_order(). | |
| common::RestApiResponse< CreateRenewListenKeyResponse > | create_renew_listen_key (const CreateRenewListenKeyParams ¶ms={}) const |
| Create / Renew Listen Key (USER_STREAM). | |
| template<class CompletionToken> | |
| auto | async_create_renew_listen_key (const CreateRenewListenKeyParams ¶ms, CompletionToken &&token) const |
| Asynchronous create_renew_listen_key(). | |
Static Public Member Functions | |
| static RestApi | from_config (common::RestApiConfig config) |
| A client for config.base_path, production when it is not set. | |
| static RestApi | production (common::RestApiConfig config) |
| A client for production (Stocks REST API). | |
Stocks REST API client.
Cheap to copy: copies share one common::RestClient (connection pool and executor).
Every endpoint has a blocking form (name(params)) and an asynchronous form (async_name(params, token)) that accepts any Asio completion token.
|
explicit |
Throws common::ConfigError if the configuration is invalid.
|
staticnodiscard |
A client for config.base_path, production when it is not set.
|
staticnodiscard |
A client for production (Stocks REST API).
|
nodiscardnoexcept |
|
inlinenodiscard |
Calls an endpoint the SDK does not wrap yet. T may be boost::json::value.
|
inlinenodiscard |
Like send_request, but signed (adds timestamp and signature).
|
inline |
|
inline |
|
inlinenodiscard |
Sign US Equity Disclaimer (TRADE).
POST /sapi/v1/equity/account/disclaimer.
Records the user's acknowledgement and acceptance of the US equity disclaimer. This must be completed before the account can access certain US equity trading features. The acceptance is tied to the account associated with the API key.
Weight: 1
Security Type: TRADE
|
inline |
Asynchronous sign_us_equity_disclaimer().
|
inlinenodiscard |
Exchange Info (MARKET_DATA).
GET /sapi/v1/equity/market/exchangeInfo.
Returns current exchange trading rules and the list of tradable US-equity symbols. MARKET_DATA endpoint — requires an API key (X-MBX-APIKEY) but no signature. Response is served from a server-side cache.
Weight: 1
Security Type: MARKET_DATA
|
inline |
Asynchronous exchange_info().
|
inlinenodiscard |
Latest Quote (MARKET_DATA).
GET /sapi/v1/equity/market/quote.
Returns the latest best bid / best ask for a single US-equity ticker. The returned value is at most ~5 seconds stale. Returns an empty response body (not the literal null) when no quote is available for the supplied ticker (e.g. the ticker is unknown, halted, or de-listed).
Weight: 1
Security Type: MARKET_DATA
|
inline |
Asynchronous latest_quote().
|
inlinenodiscard |
Tokenized Assets (MARKET_DATA).
GET /sapi/v1/equity/market/tokenized-assets.
Returns the list of all tokenized assets currently available for mint / redeem, together with each asset's underlying equity symbol and conversion multiplier. MARKET_DATA endpoint — requires an API key (X-MBX-APIKEY) but no signature. Response is served from a server-side cache.
Weight: 1
Security Type: MARKET_DATA
|
inline |
Asynchronous tokenized_assets().
|
inlinenodiscard |
Bstocks Corporate Action Records (USER_DATA).
GET /sapi/v1/bstocks/corp-action/history.
Query the asset balance changes caused by corporate actions (for example stock splits and cash dividends) on the caller's account. Cursor-style pagination — supply the nextTime and nextId from the previous page's response as lastTime and lastId to fetch the next page. Records are returned in descending order of modification time. This endpoint is equivalent to /sapi/v1/equity/corp-action/history.
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous bstocks_corporate_action_records().
|
inlinenodiscard |
Corporate Action Records (USER_DATA).
GET /sapi/v1/equity/corp-action/history.
Query the asset balance changes caused by corporate actions (for example stock splits and cash dividends) on the caller's account. Cursor-style pagination — supply the nextTime and nextId from the previous page's response as lastTime and lastId to fetch the next page. Records are returned in descending order of modification time. This endpoint is equivalent to /sapi/v1/bstocks/corp-action/history.
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous corporate_action_records().
|
inlinenodiscard |
Tokenized Convert History (USER_DATA).
GET /sapi/v1/equity/tokenized/history.
Paged history of mint / redeem conversions for the caller. Cursor-style pagination — supply the nextLastId from the previous page's response to fetch the next page.
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous tokenized_convert_history().
|
inlinenodiscard |
Tokenized Convert Status (USER_DATA).
GET /sapi/v1/equity/tokenized/convert-status.
Query the current status of a single mint / redeem request by its issuerRequestId. Returns an empty object when no record matches (caller's ID scope only).
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous tokenized_convert_status().
|
inlinenodiscard |
Tokenized Mint (TRADE).
POST /sapi/v1/equity/tokenized/mint.
Mint a tokenized asset from an underlying equity holding. The caller's underlying equity (e.g. AAPL) is burned (or locked), and the corresponding tokenized asset (e.g. AAPLB) is credited. The tokenized asset is resolved server-side from underlyingAsset; callers only provide the underlying ticker and quantity. Mint is asynchronous: the endpoint returns an issuerRequestId immediately with a transient status; poll /tokenized/convert-status to observe the terminal state, or inspect /tokenized/history for the full record. Rate limit: 50 requests / min (UID).
Weight: 1
Security Type: TRADE
|
inline |
Asynchronous tokenized_mint().
|
inlinenodiscard |
Tokenized Redeem (TRADE).
POST /sapi/v1/equity/tokenized/redeem.
Redeem a tokenized asset back into the underlying equity. The caller's tokenized asset (e.g. AAPLB) is burned, and the corresponding underlying equity (e.g. AAPL) is released. The underlying asset is resolved server-side from tokenizedAsset; callers only provide the tokenized asset and quantity. Redeem is asynchronous: the endpoint returns an issuerRequestId immediately with a transient status; poll /tokenized/convert-status to observe the terminal state, or inspect /tokenized/history for the full record. Rate limit: 200 requests / min (UID).
Weight: 1
Security Type: TRADE
|
inline |
Asynchronous tokenized_redeem().
|
inlinenodiscard |
Cancel All Equity Orders (TRADE).
POST /sapi/v1/equity/order/cancel-all.
Cancel all open orders for the caller. No request body is required — the scope is all of the caller's open orders. The downstream service handles idempotency; to inspect per-order outcomes, query /order/history after the call.
Weight: 1
Security Type: TRADE
|
inline |
Asynchronous cancel_all_equity_orders().
|
inlinenodiscard |
Cancel Equity Order (TRADE).
POST /sapi/v1/equity/order/cancel.
Cancel a single open order by its orderId.
Weight: 1
Security Type: TRADE
|
inline |
Asynchronous cancel_equity_order().
|
inlinenodiscard |
Current Open Orders (USER_DATA).
GET /sapi/v1/equity/order/open-orders.
Query all unfinished (open) orders for the caller. No business parameters are needed — user identity is derived from the signature.
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous current_open_orders().
|
inlinenodiscard |
Equity Order Detail (USER_DATA).
GET /sapi/v1/equity/order/detail.
Returns a single order along with its trade execution list. Callers can only read their own orders — the user identity is derived from the signed request.
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous equity_order_detail().
|
inlinenodiscard |
Equity Order History (USER_DATA).
GET /sapi/v1/equity/order/history.
Paged order history for the caller. Filters by symbol, order type, side, status, and time range.
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous equity_order_history().
|
inlinenodiscard |
Equity Trade History (USER_DATA).
GET /sapi/v1/equity/trade/history.
Paged equity trade (per-fill) history for the caller. Each row is one execution, not one order — a partially filled order produces multiple rows. Filters by symbol, side, specific orderId, and time range.
Weight: 1
Security Type: USER_DATA
|
inline |
Asynchronous equity_trade_history().
|
inlinenodiscard |
Place Equity Order (TRADE).
POST /sapi/v1/equity/order/place.
Place a new equity order. Supports all combinations of LIMIT / MARKET × BUY / SELL. For LIMIT BUY orders the commission fee is automatically computed and reserved by the server at placement time — callers submit price and quantity only, no fee field is required.
Field combination matrix
| Side | OrderType | Required | Forbidden |
|---|---|---|---|
| BUY | LIMIT | price, quantity, tradingSession | notional |
| BUY | MARKET | notional | price, quantity, tradingSession |
| SELL | LIMIT | price, quantity, tradingSession | notional |
| SELL | MARKET | quantity | price, notional, tradingSession |
Fractional shares: when quantity has a decimal component, or an order is placed by notional, it is treated as a fractional-share order. A fractional-share GTC order must be paired with tradingSession = EXTENDED or 24H.
Rate limit: 200 requests / min (UID).
Weight: 1
Security Type: TRADE
|
inline |
Asynchronous place_equity_order().
|
inlinenodiscard |
Create / Renew Listen Key (USER_STREAM).
POST /sapi/v1/equity/listenKey.
Create a new stock user-data-stream listenKey, or renew an existing one. Calling this endpoint for the same user with an active listenKey extends its validity; if there is no active key, a new one is issued. Use the returned listenKey to subscribe to the stock user data stream.
Weight: 1
Security Type: USER_STREAM
|
inline |
Asynchronous create_renew_listen_key().