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

#include <market_api.hpp>

Public Member Functions

 MarketApi (std::shared_ptr< common::WebsocketApi > client)
common::WebsocketApiResponse< AvgPriceResponseResult > avg_price (const AvgPriceParams &params) const
 Current average price.
template<class CompletionToken>
auto async_avg_price (const AvgPriceParams &params, CompletionToken &&token) const
 Asynchronous avg_price().
common::WebsocketApiResponse< std::vector< BlockTradesHistoricalResponseResultInner > > block_trades_historical (const BlockTradesHistoricalParams &params) const
 Historical Block Trades.
template<class CompletionToken>
auto async_block_trades_historical (const BlockTradesHistoricalParams &params, CompletionToken &&token) const
 Asynchronous block_trades_historical().
common::WebsocketApiResponse< DepthResponseResult > depth (const DepthParams &params) const
 Order book.
template<class CompletionToken>
auto async_depth (const DepthParams &params, CompletionToken &&token) const
 Asynchronous depth().
common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > klines (const KlinesParams &params) const
 Klines.
template<class CompletionToken>
auto async_klines (const KlinesParams &params, CompletionToken &&token) const
 Asynchronous klines().
common::WebsocketApiResponse< ReferencePriceResponseResult > reference_price (const ReferencePriceParams &params) const
 Query Reference Price.
template<class CompletionToken>
auto async_reference_price (const ReferencePriceParams &params, CompletionToken &&token) const
 Asynchronous reference_price().
common::WebsocketApiResponse< ReferencePriceCalculationResponseResult > reference_price_calculation (const ReferencePriceCalculationParams &params) const
 Query Reference Price Calculation.
template<class CompletionToken>
auto async_reference_price_calculation (const ReferencePriceCalculationParams &params, CompletionToken &&token) const
 Asynchronous reference_price_calculation().
common::WebsocketApiResponse< std::variant< TickerResponse1Result, std::vector< TickerResponse2ResultInner >, boost::json::value > > ticker (const TickerParams &params={}) const
 Rolling window price change statistics.
template<class CompletionToken>
auto async_ticker (const TickerParams &params, CompletionToken &&token) const
 Asynchronous ticker().
common::WebsocketApiResponse< std::variant< Ticker24hrResponse1Result, std::vector< Ticker24hrResponse2ResultInner >, boost::json::value > > ticker24hr (const Ticker24hrParams &params={}) const
 24hr ticker price change statistics
template<class CompletionToken>
auto async_ticker24hr (const Ticker24hrParams &params, CompletionToken &&token) const
 Asynchronous ticker24hr().
common::WebsocketApiResponse< std::variant< TickerBookResponse1Result, std::vector< TickerBookResponse2ResultInner >, boost::json::value > > ticker_book (const TickerBookParams &params={}) const
 Symbol order book ticker.
template<class CompletionToken>
auto async_ticker_book (const TickerBookParams &params, CompletionToken &&token) const
 Asynchronous ticker_book().
common::WebsocketApiResponse< std::variant< TickerPriceResponse1Result, std::vector< TickerPriceResponse2ResultInner >, boost::json::value > > ticker_price (const TickerPriceParams &params={}) const
 Symbol price ticker.
template<class CompletionToken>
auto async_ticker_price (const TickerPriceParams &params, CompletionToken &&token) const
 Asynchronous ticker_price().
common::WebsocketApiResponse< std::variant< TickerTradingDayResponse1Result, std::vector< TickerTradingDayResponse2ResultInner >, boost::json::value > > ticker_trading_day (const TickerTradingDayParams &params={}) const
 Trading Day Ticker.
template<class CompletionToken>
auto async_ticker_trading_day (const TickerTradingDayParams &params, CompletionToken &&token) const
 Asynchronous ticker_trading_day().
common::WebsocketApiResponse< std::vector< TradesAggregateResponseResultInner > > trades_aggregate (const TradesAggregateParams &params) const
 Aggregate trades.
template<class CompletionToken>
auto async_trades_aggregate (const TradesAggregateParams &params, CompletionToken &&token) const
 Asynchronous trades_aggregate().
common::WebsocketApiResponse< std::vector< TradesHistoricalResponseResultInner > > trades_historical (const TradesHistoricalParams &params) const
 Historical trades.
template<class CompletionToken>
auto async_trades_historical (const TradesHistoricalParams &params, CompletionToken &&token) const
 Asynchronous trades_historical().
common::WebsocketApiResponse< std::vector< TradesRecentResponseResultInner > > trades_recent (const TradesRecentParams &params) const
 Recent trades.
template<class CompletionToken>
auto async_trades_recent (const TradesRecentParams &params, CompletionToken &&token) const
 Asynchronous trades_recent().
common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > ui_klines (const UiKlinesParams &params) const
 UI Klines.
template<class CompletionToken>
auto async_ui_klines (const UiKlinesParams &params, CompletionToken &&token) const
 Asynchronous ui_klines().

Constructor & Destructor Documentation

◆ MarketApi()

binance::spot::websocket_api::MarketApi::MarketApi ( std::shared_ptr< common::WebsocketApi > client)
explicit

Member Function Documentation

◆ avg_price()

common::WebsocketApiResponse< AvgPriceResponseResult > binance::spot::websocket_api::MarketApi::avg_price ( const AvgPriceParams & params) const
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

◆ async_avg_price()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_avg_price ( const AvgPriceParams & params,
CompletionToken && token ) const
inline

Asynchronous avg_price().

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

◆ block_trades_historical()

common::WebsocketApiResponse< std::vector< BlockTradesHistoricalResponseResultInner > > binance::spot::websocket_api::MarketApi::block_trades_historical ( const BlockTradesHistoricalParams & params) const
nodiscard

Historical Block Trades.

blockTrades.historical.

Get block trades.

Weight(IP): 25

Security Type: NONE

Notes: Data Source: Database

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#block-trades-historical

◆ async_block_trades_historical()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_block_trades_historical ( const BlockTradesHistoricalParams & params,
CompletionToken && token ) const
inline

Asynchronous block_trades_historical().

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

◆ depth()

common::WebsocketApiResponse< DepthResponseResult > binance::spot::websocket_api::MarketApi::depth ( const DepthParams & params) const
nodiscard

Order book.

depth.

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

◆ async_depth()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_depth ( const DepthParams & params,
CompletionToken && token ) const
inline

Asynchronous depth().

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

◆ klines()

common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > binance::spot::websocket_api::MarketApi::klines ( const KlinesParams & params) const
nodiscard

Klines.

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:

  • <symbol>@kline_<interval>

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:

  • If startTime and endTime are not sent, the most recent klines are returned.
  • Supported values for timeZone:
    • Hours and minutes (e.g. -1:00, 05:45)
    • Only hours (e.g. 0, 8, 4)
    • Accepted range is strictly [-12:00 to +14:00] inclusive
  • If timeZone provided, kline intervals are interpreted in that timezone instead of UTC.
  • Note that startTime and endTime are always interpreted in UTC, regardless of timeZone.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#klines

◆ async_klines()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_klines ( const KlinesParams & params,
CompletionToken && token ) const
inline

Asynchronous klines().

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

◆ reference_price()

common::WebsocketApiResponse< ReferencePriceResponseResult > binance::spot::websocket_api::MarketApi::reference_price ( const ReferencePriceParams & params) const
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:

{
"code": -2043,
"msg": "This symbol doesn't have a reference price."
}

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#reference-price

◆ async_reference_price()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_reference_price ( const ReferencePriceParams & params,
CompletionToken && token ) const
inline

Asynchronous reference_price().

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

◆ reference_price_calculation()

common::WebsocketApiResponse< ReferencePriceCalculationResponseResult > binance::spot::websocket_api::MarketApi::reference_price_calculation ( const ReferencePriceCalculationParams & params) const
nodiscard

Query Reference Price Calculation.

referencePrice.calculation.

Query Reference Price Calculation

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#reference-price-calculation

◆ async_reference_price_calculation()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_reference_price_calculation ( const ReferencePriceCalculationParams & params,
CompletionToken && token ) const
inline

◆ ticker()

common::WebsocketApiResponse< std::variant< TickerResponse1Result, std::vector< TickerResponse2ResultInner >, boost::json::value > > binance::spot::websocket_api::MarketApi::ticker ( const TickerParams & params = {}) const
nodiscard

Rolling window price change statistics.

ticker.

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:

{
"openTime": 1659580020000,
"closeTime": 1660184865291
}

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:

  • <symbol>@ticker_<window_size> or !ticker_<window-size>@arr

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:

  • Either symbol or symbols must be specified.
  • Maximum number of symbols in one request: 200.
  • Window size units cannot be combined. E.g., 1d 2h is not supported.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker

◆ async_ticker()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_ticker ( const TickerParams & params,
CompletionToken && token ) const
inline

Asynchronous ticker().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerResponse1Result, std::vector<TickerResponse2ResultInner>, boost::json::value>>).

◆ ticker24hr()

common::WebsocketApiResponse< std::variant< Ticker24hrResponse1Result, std::vector< Ticker24hrResponse2ResultInner >, boost::json::value > > binance::spot::websocket_api::MarketApi::ticker24hr ( const Ticker24hrParams & params = {}) const
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:

  • <symbol>@ticker or !ticker@arr
  • <symbol>@miniTicker or !miniTicker@arr

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:

  • symbol and symbols cannot be used together.
  • If no symbol is specified, returns information about all symbols currently trading on the exchange.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker24hr

◆ async_ticker24hr()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_ticker24hr ( const Ticker24hrParams & params,
CompletionToken && token ) const
inline

Asynchronous ticker24hr().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<Ticker24hrResponse1Result, std::vector<Ticker24hrResponse2ResultInner>, boost::json::value>>).

◆ ticker_book()

common::WebsocketApiResponse< std::variant< TickerBookResponse1Result, std::vector< TickerBookResponse2ResultInner >, boost::json::value > > binance::spot::websocket_api::MarketApi::ticker_book ( const TickerBookParams & params = {}) const
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:

  • <symbol>@bookTicker

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:

  • symbol and symbols cannot be used together.
  • If no symbol is specified, returns information about all symbols currently trading on the exchange.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker-book

◆ async_ticker_book()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_ticker_book ( const TickerBookParams & params,
CompletionToken && token ) const
inline

Asynchronous ticker_book().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerBookResponse1Result, std::vector<TickerBookResponse2ResultInner>, boost::json::value>>).

◆ ticker_price()

common::WebsocketApiResponse< std::variant< TickerPriceResponse1Result, std::vector< TickerPriceResponse2ResultInner >, boost::json::value > > binance::spot::websocket_api::MarketApi::ticker_price ( const TickerPriceParams & params = {}) const
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:

  • <symbol>@aggTrade
  • <symbol>@trade

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:

  • symbol and symbols cannot be used together.
  • If no symbol is specified, returns information about all symbols currently trading on the exchange.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker-price

◆ async_ticker_price()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_ticker_price ( const TickerPriceParams & params,
CompletionToken && token ) const
inline

Asynchronous ticker_price().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerPriceResponse1Result, std::vector<TickerPriceResponse2ResultInner>, boost::json::value>>).

◆ ticker_trading_day()

common::WebsocketApiResponse< std::variant< TickerTradingDayResponse1Result, std::vector< TickerTradingDayResponse2ResultInner >, boost::json::value > > binance::spot::websocket_api::MarketApi::ticker_trading_day ( const TickerTradingDayParams & params = {}) const
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:

  • Supported values for timeZone:
    • Hours and minutes (e.g. -1:00, 05:45)
    • Only hours (e.g. 0, 8, 4)

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker-trading-day

◆ async_ticker_trading_day()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_ticker_trading_day ( const TickerTradingDayParams & params,
CompletionToken && token ) const
inline

Asynchronous ticker_trading_day().

Completes with void(std::exception_ptr, common::WebsocketApiResponse<std::variant<TickerTradingDayResponse1Result, std::vector<TickerTradingDayResponse2ResultInner>, boost::json::value>>).

◆ trades_aggregate()

common::WebsocketApiResponse< std::vector< TradesAggregateResponseResultInner > > binance::spot::websocket_api::MarketApi::trades_aggregate ( const TradesAggregateParams & params) const
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:

  • <symbol>@aggTrade

If you need historical aggregate trade data, please consider using data.binance.vision.

Weight(IP): 4

Security Type: NONE

Notes: Data Source: Database

  • If fromId is specified, return aggtrades with aggregate trade ID >= fromId. Use fromId and limit to page through all aggtrades.
  • If startTime and/or endTime are specified, aggtrades are filtered by execution time (T). fromId cannot be used together with startTime and endTime.
  • If no condition is specified, the most recent aggregate trades are returned.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#trades-aggregate

◆ async_trades_aggregate()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_trades_aggregate ( const TradesAggregateParams & params,
CompletionToken && token ) const
inline

Asynchronous trades_aggregate().

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

◆ trades_historical()

common::WebsocketApiResponse< std::vector< TradesHistoricalResponseResultInner > > binance::spot::websocket_api::MarketApi::trades_historical ( const TradesHistoricalParams & params) const
nodiscard

Historical trades.

trades.historical.

Get historical trades.

Weight(IP): 25

Security Type: NONE

Notes: Data Source: Database

Notes:

  • If fromId is not specified, the most recent trades are returned.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#trades-historical

◆ async_trades_historical()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_trades_historical ( const TradesHistoricalParams & params,
CompletionToken && token ) const
inline

Asynchronous trades_historical().

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

◆ trades_recent()

common::WebsocketApiResponse< std::vector< TradesRecentResponseResultInner > > binance::spot::websocket_api::MarketApi::trades_recent ( const TradesRecentParams & params) const
nodiscard

Recent trades.

trades.recent.

Get recent trades.

If you need access to real-time trading activity, please consider using WebSocket Streams:

  • <symbol>@trade

Weight(IP): 25

Security Type: NONE

Notes: Data Source: Memory

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#trades-recent

◆ async_trades_recent()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_trades_recent ( const TradesRecentParams & params,
CompletionToken && token ) const
inline

Asynchronous trades_recent().

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

◆ ui_klines()

common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > binance::spot::websocket_api::MarketApi::ui_klines ( const UiKlinesParams & params) const
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

  • If startTime and endTime are not sent, the most recent klines are returned.
  • Supported values for timeZone:
    • Hours and minutes (e.g. -1:00, 05:45)
    • Only hours (e.g. 0, 8, 4)
    • Accepted range is strictly [-12:00 to +14:00] inclusive
  • If timeZone provided, kline intervals are interpreted in that timezone instead of UTC.
  • Note that startTime and endTime are always interpreted in UTC, regardless of timeZone.

See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ui-klines

◆ async_ui_klines()

template<class CompletionToken>
auto binance::spot::websocket_api::MarketApi::async_ui_klines ( const UiKlinesParams & params,
CompletionToken && token ) const
inline

Asynchronous ui_klines().

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