|
Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
|
#include <market_api.hpp>
Public Member Functions | |
| MarketApi (std::shared_ptr< common::WebsocketApi > client) | |
| common::WebsocketApiResponse< AvgPriceResponseResult > | avg_price (const AvgPriceParams ¶ms) const |
| Current average price. | |
| template<class CompletionToken> | |
| auto | async_avg_price (const AvgPriceParams ¶ms, CompletionToken &&token) const |
| Asynchronous avg_price(). | |
| common::WebsocketApiResponse< std::vector< BlockTradesHistoricalResponseResultInner > > | block_trades_historical (const BlockTradesHistoricalParams ¶ms) const |
| Historical Block Trades. | |
| template<class CompletionToken> | |
| auto | async_block_trades_historical (const BlockTradesHistoricalParams ¶ms, CompletionToken &&token) const |
| Asynchronous block_trades_historical(). | |
| common::WebsocketApiResponse< DepthResponseResult > | depth (const DepthParams ¶ms) const |
| Order book. | |
| template<class CompletionToken> | |
| auto | async_depth (const DepthParams ¶ms, CompletionToken &&token) const |
| Asynchronous depth(). | |
| common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > | klines (const KlinesParams ¶ms) const |
| Klines. | |
| template<class CompletionToken> | |
| auto | async_klines (const KlinesParams ¶ms, CompletionToken &&token) const |
| Asynchronous klines(). | |
| common::WebsocketApiResponse< ReferencePriceResponseResult > | reference_price (const ReferencePriceParams ¶ms) const |
| Query Reference Price. | |
| template<class CompletionToken> | |
| auto | async_reference_price (const ReferencePriceParams ¶ms, CompletionToken &&token) const |
| Asynchronous reference_price(). | |
| common::WebsocketApiResponse< ReferencePriceCalculationResponseResult > | reference_price_calculation (const ReferencePriceCalculationParams ¶ms) const |
| Query Reference Price Calculation. | |
| template<class CompletionToken> | |
| auto | async_reference_price_calculation (const ReferencePriceCalculationParams ¶ms, CompletionToken &&token) const |
| Asynchronous reference_price_calculation(). | |
| common::WebsocketApiResponse< std::variant< TickerResponse1Result, std::vector< TickerResponse2ResultInner >, boost::json::value > > | ticker (const TickerParams ¶ms={}) const |
| Rolling window price change statistics. | |
| template<class CompletionToken> | |
| auto | async_ticker (const TickerParams ¶ms, CompletionToken &&token) const |
| Asynchronous ticker(). | |
| common::WebsocketApiResponse< std::variant< Ticker24hrResponse1Result, std::vector< Ticker24hrResponse2ResultInner >, boost::json::value > > | ticker24hr (const Ticker24hrParams ¶ms={}) const |
| 24hr ticker price change statistics | |
| template<class CompletionToken> | |
| auto | async_ticker24hr (const Ticker24hrParams ¶ms, CompletionToken &&token) const |
| Asynchronous ticker24hr(). | |
| common::WebsocketApiResponse< std::variant< TickerBookResponse1Result, std::vector< TickerBookResponse2ResultInner >, boost::json::value > > | ticker_book (const TickerBookParams ¶ms={}) const |
| Symbol order book ticker. | |
| template<class CompletionToken> | |
| auto | async_ticker_book (const TickerBookParams ¶ms, CompletionToken &&token) const |
| Asynchronous ticker_book(). | |
| common::WebsocketApiResponse< std::variant< TickerPriceResponse1Result, std::vector< TickerPriceResponse2ResultInner >, boost::json::value > > | ticker_price (const TickerPriceParams ¶ms={}) const |
| Symbol price ticker. | |
| template<class CompletionToken> | |
| auto | async_ticker_price (const TickerPriceParams ¶ms, CompletionToken &&token) const |
| Asynchronous ticker_price(). | |
| common::WebsocketApiResponse< std::variant< TickerTradingDayResponse1Result, std::vector< TickerTradingDayResponse2ResultInner >, boost::json::value > > | ticker_trading_day (const TickerTradingDayParams ¶ms={}) const |
| Trading Day Ticker. | |
| template<class CompletionToken> | |
| auto | async_ticker_trading_day (const TickerTradingDayParams ¶ms, CompletionToken &&token) const |
| Asynchronous ticker_trading_day(). | |
| common::WebsocketApiResponse< std::vector< TradesAggregateResponseResultInner > > | trades_aggregate (const TradesAggregateParams ¶ms) const |
| Aggregate trades. | |
| template<class CompletionToken> | |
| auto | async_trades_aggregate (const TradesAggregateParams ¶ms, CompletionToken &&token) const |
| Asynchronous trades_aggregate(). | |
| common::WebsocketApiResponse< std::vector< TradesHistoricalResponseResultInner > > | trades_historical (const TradesHistoricalParams ¶ms) const |
| Historical trades. | |
| template<class CompletionToken> | |
| auto | async_trades_historical (const TradesHistoricalParams ¶ms, CompletionToken &&token) const |
| Asynchronous trades_historical(). | |
| common::WebsocketApiResponse< std::vector< TradesRecentResponseResultInner > > | trades_recent (const TradesRecentParams ¶ms) const |
| Recent trades. | |
| template<class CompletionToken> | |
| auto | async_trades_recent (const TradesRecentParams ¶ms, CompletionToken &&token) const |
| Asynchronous trades_recent(). | |
| common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > | ui_klines (const UiKlinesParams ¶ms) const |
| UI Klines. | |
| template<class CompletionToken> | |
| auto | async_ui_klines (const UiKlinesParams ¶ms, CompletionToken &&token) const |
| Asynchronous ui_klines(). | |
|
explicit |
|
nodiscard |
Current average price.
avgPrice.
Get current average price for a symbol.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#avg-price
|
inline |
Asynchronous avg_price().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<AvgPriceResponseResult>).
|
nodiscard |
Historical Block Trades.
blockTrades.historical.
Get block trades.
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Database
|
inline |
Asynchronous block_trades_historical().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<BlockTradesHistoricalResponseResultInner>>).
|
nodiscard |
Order book.
Get current order book.
Note that this request returns limited market depth.
If you need to continuously monitor order book updates, please consider using WebSocket Streams:
You can use depth request together with <symbol>@depth streams to maintain a local order book.
Weight: Adjusted based on the limit:
| Limit | Request Weight |
|---|---|
| 1-100 | 5 |
| 101-500 | 25 |
| 501-1000 | 50 |
| 1001-5000 | 250 |
| 5001-7500 | 500 |
Security Type: NONE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#depth
|
inline |
Asynchronous depth().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<DepthResponseResult>).
|
nodiscard |
Klines.
Get klines (candlestick bars).
Klines are uniquely identified by their open & close time.
If you need access to real-time kline updates, please consider using WebSocket Streams:
If you need historical kline data, please consider using data.binance.vision.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Database
Supported kline intervals (case-sensitive):
| Interval | interval value |
|---|---|
| seconds | 1s |
| minutes | 1m, 3m, 5m, 15m, 30m |
| hours | 1h, 2h, 4h, 6h, 8h, 12h |
| days | 1d, 3d |
| weeks | 1w |
| months | 1M |
Notes:
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#klines
|
inline |
Asynchronous klines().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<std::vector<KlinesResponseResultInnerInner>>>).
|
nodiscard |
Query Reference Price.
referencePrice.
Query Reference Price
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
If the symbol has never had a reference price set, the request is rejected with:
|
inline |
Asynchronous reference_price().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<ReferencePriceResponseResult>).
|
nodiscard |
Query Reference Price Calculation.
referencePrice.calculation.
Query Reference Price Calculation
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
|
inline |
Asynchronous reference_price_calculation().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<ReferencePriceCalculationResponseResult>).
|
nodiscard |
Rolling window price change statistics.
Get rolling window price change statistics with a custom window.
This request is similar to ticker.24hr but statistics are computed on demand using the arbitrary window you specify.
Note: Window size precision is limited to 1 minute. While the closeTime is the current time of the request, openTime always start on a minute boundary. As such, the effective window might be up to 59999 ms wider than the requested windowSize.
Window computation example
For example, a request for "windowSize": "7d" might result in the following window:
Time of the request – closeTime – is 1660184865291 (August 11, 2022 02:27:45.291). Requested window size should put the openTime 7 days before that – August 4, 02:27:45.291 – but due to limited precision it ends up a bit earlier: 1659580020000 (August 4, 2022 02:27:00), exactly at the start of a minute.
If you need to continuously monitor trading statistics, please consider using WebSocket Streams:
Weight: Adjusted based on the number of requested symbols:
| Symbols | Weight |
|---|---|
| 1–50 | 4 per symbol |
| 51–100 | 200 |
Security Type: NONE
Notes: Data Source: Database
Supported window sizes:
| Unit | windowSize value |
|---|---|
| minutes | 1m, 2m ... 59m |
| hours | 1h, 2h ... 23h |
| days | 1d, 2d ... 7d |
Notes:
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker
|
inline |
Asynchronous ticker().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerResponse1Result, std::vector<TickerResponse2ResultInner>, boost::json::value>>).
|
nodiscard |
24hr ticker price change statistics
ticker.24hr.
Get 24-hour rolling window price change statistics.
If you need to continuously monitor trading statistics, please consider using WebSocket Streams:
If you need different window sizes,
use the ticker request.
Weight: Adjusted based on the number of requested symbols:
| Parameter | Symbols Provided | Weight |
|---|---|---|
| symbol | 1 | 2 |
| omitted | 80 | |
| symbols | 1-20 | 2 |
| 21-100 | 40 | |
| 101+ | 80 | |
| omitted | 80 |
Security Type: NONE
Notes: Data Source: Memory
Notes:
|
inline |
Asynchronous ticker24hr().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<Ticker24hrResponse1Result, std::vector<Ticker24hrResponse2ResultInner>, boost::json::value>>).
|
nodiscard |
Symbol order book ticker.
ticker.book.
Get the current best price and quantity on the order book.
If you need access to real-time order book ticker updates, please consider using WebSocket Streams:
Weight: Adjusted based on the number of requested symbols:
| Parameter | Symbols Provided | Weight |
|---|---|---|
| symbol | 1 | 2 |
| omitted | 4 | |
| symbols | Any | 4 |
Security Type: NONE
Notes: Data Source: Memory
Notes:
|
inline |
Asynchronous ticker_book().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerBookResponse1Result, std::vector<TickerBookResponse2ResultInner>, boost::json::value>>).
|
nodiscard |
Symbol price ticker.
ticker.price.
Get the latest market price for a symbol.
If you need access to real-time price updates, please consider using WebSocket Streams:
Weight: Adjusted based on the number of requested symbols:
| Parameter | Symbols Provided | Weight |
|---|---|---|
| symbol | 1 | 2 |
| omitted | 4 | |
| symbols | Any | 4 |
Security Type: NONE
Notes: Data Source: Memory
Notes:
|
inline |
Asynchronous ticker_price().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerPriceResponse1Result, std::vector<TickerPriceResponse2ResultInner>, boost::json::value>>).
|
nodiscard |
Trading Day Ticker.
ticker.tradingDay.
Price change statistics for a trading day.
Weight: 4 for each requested symbol regardless of windowSize. The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
Security Type: NONE
Notes: Data Source: Database
Notes:
|
inline |
Asynchronous ticker_trading_day().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerTradingDayResponse1Result, std::vector<TickerTradingDayResponse2ResultInner>, boost::json::value>>).
|
nodiscard |
Aggregate trades.
trades.aggregate.
Get aggregate trades.
An aggregate trade (aggtrade) represents one or more individual trades.
Trades that fill at the same time, from the same taker order, with the same price –
those trades are collected into an aggregate trade with total quantity of the individual trades.
If you need access to real-time trading activity, please consider using WebSocket Streams:
If you need historical aggregate trade data, please consider using data.binance.vision.
Weight(IP): 4
Security Type: NONE
Notes: Data Source: Database
|
inline |
Asynchronous trades_aggregate().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<TradesAggregateResponseResultInner>>).
|
nodiscard |
Historical trades.
trades.historical.
Get historical trades.
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Database
Notes:
|
inline |
Asynchronous trades_historical().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<TradesHistoricalResponseResultInner>>).
|
nodiscard |
Recent trades.
trades.recent.
Get recent trades.
If you need access to real-time trading activity, please consider using WebSocket Streams:
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Memory
|
inline |
Asynchronous trades_recent().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<TradesRecentResponseResultInner>>).
|
nodiscard |
UI Klines.
uiKlines.
Get klines (candlestick bars) optimized for presentation.
This request is similar to klines, having the same parameters and response. uiKlines return modified kline data, optimized for presentation of candlestick charts.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Database
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ui-klines
|
inline |
Asynchronous ui_klines().
Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::vector<std::vector<KlinesResponseResultInnerInner>>>).