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

#include <market_api.hpp>

Public Member Functions

 MarketApi (std::shared_ptr< common::RestClient > client)
common::RestApiResponse< std::vector< AggTradesResponseInner > > agg_trades (const AggTradesParams &params) const
 Compressed/Aggregate trades list.
template<class CompletionToken>
auto async_agg_trades (const AggTradesParams &params, CompletionToken &&token) const
 Asynchronous agg_trades().
common::RestApiResponse< AvgPriceResponse > 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::RestApiResponse< DepthResponse > depth (const DepthParams &params) const
 Order book.
template<class CompletionToken>
auto async_depth (const DepthParams &params, CompletionToken &&token) const
 Asynchronous depth().
common::RestApiResponse< std::vector< GetTradesResponseInner > > get_trades (const GetTradesParams &params) const
 Recent trades list.
template<class CompletionToken>
auto async_get_trades (const GetTradesParams &params, CompletionToken &&token) const
 Asynchronous get_trades().
common::RestApiResponse< std::vector< HistoricalBlockTradesResponseInner > > historical_block_trades (const HistoricalBlockTradesParams &params) const
 Historical Block Trades (MARKET_DATA).
template<class CompletionToken>
auto async_historical_block_trades (const HistoricalBlockTradesParams &params, CompletionToken &&token) const
 Asynchronous historical_block_trades().
common::RestApiResponse< std::vector< GetTradesResponseInner > > historical_trades (const HistoricalTradesParams &params) const
 Old trade lookup.
template<class CompletionToken>
auto async_historical_trades (const HistoricalTradesParams &params, CompletionToken &&token) const
 Asynchronous historical_trades().
common::RestApiResponse< std::vector< std::vector< KlinesItemInner > > > klines (const KlinesParams &params) const
 Kline/Candlestick data.
template<class CompletionToken>
auto async_klines (const KlinesParams &params, CompletionToken &&token) const
 Asynchronous klines().
common::RestApiResponse< ReferencePriceResponse > 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::RestApiResponse< ReferencePriceCalculationResponse > 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::RestApiResponse< TickerResponse > 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::RestApiResponse< Ticker24hrResponse > 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::RestApiResponse< TickerBookTickerResponse > ticker_book_ticker (const TickerBookTickerParams &params={}) const
 Symbol order book ticker.
template<class CompletionToken>
auto async_ticker_book_ticker (const TickerBookTickerParams &params, CompletionToken &&token) const
 Asynchronous ticker_book_ticker().
common::RestApiResponse< TickerPriceResponse > 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::RestApiResponse< TickerTradingDayResponse > 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::RestApiResponse< std::vector< std::vector< KlinesItemInner > > > ui_klines (const UiKlinesParams &params) const
 UIKlines.
template<class CompletionToken>
auto async_ui_klines (const UiKlinesParams &params, CompletionToken &&token) const
 Asynchronous ui_klines().

Constructor & Destructor Documentation

◆ MarketApi()

binance::spot::rest_api::MarketApi::MarketApi ( std::shared_ptr< common::RestClient > client)
explicit

Member Function Documentation

◆ agg_trades()

common::RestApiResponse< std::vector< AggTradesResponseInner > > binance::spot::rest_api::MarketApi::agg_trades ( const AggTradesParams & params) const
nodiscard

Compressed/Aggregate trades list.

GET /api/v3/aggTrades.

Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.

Weight(IP): 4

Security Type: NONE

Notes: Data Source: Database

  • If fromId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.

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

◆ async_agg_trades()

template<class CompletionToken>
auto binance::spot::rest_api::MarketApi::async_agg_trades ( const AggTradesParams & params,
CompletionToken && token ) const
inline

Asynchronous agg_trades().

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

◆ avg_price()

common::RestApiResponse< AvgPriceResponse > binance::spot::rest_api::MarketApi::avg_price ( const AvgPriceParams & params) const
nodiscard

Current average price.

GET /api/v3/avgPrice.

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/rest-api/market#avg-price

◆ async_avg_price()

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

Asynchronous avg_price().

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

◆ depth()

common::RestApiResponse< DepthResponse > binance::spot::rest_api::MarketApi::depth ( const DepthParams & params) const
nodiscard

Order book.

GET /api/v3/depth.

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/rest-api/market#depth

◆ async_depth()

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

Asynchronous depth().

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

◆ get_trades()

common::RestApiResponse< std::vector< GetTradesResponseInner > > binance::spot::rest_api::MarketApi::get_trades ( const GetTradesParams & params) const
nodiscard

Recent trades list.

GET /api/v3/trades.

Get recent trades.

Weight(IP): 25

Security Type: NONE

Notes: Data Source: Memory

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

◆ async_get_trades()

template<class CompletionToken>
auto binance::spot::rest_api::MarketApi::async_get_trades ( const GetTradesParams & params,
CompletionToken && token ) const
inline

Asynchronous get_trades().

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

◆ historical_block_trades()

common::RestApiResponse< std::vector< HistoricalBlockTradesResponseInner > > binance::spot::rest_api::MarketApi::historical_block_trades ( const HistoricalBlockTradesParams & params) const
nodiscard

Historical Block Trades (MARKET_DATA).

GET /api/v3/historicalBlockTrades.

Get block trades.

Weight(IP): 25

Security Type: MARKET_DATA

Notes: Data Source: Database

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

◆ async_historical_block_trades()

template<class CompletionToken>
auto binance::spot::rest_api::MarketApi::async_historical_block_trades ( const HistoricalBlockTradesParams & params,
CompletionToken && token ) const
inline

Asynchronous historical_block_trades().

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

◆ historical_trades()

common::RestApiResponse< std::vector< GetTradesResponseInner > > binance::spot::rest_api::MarketApi::historical_trades ( const HistoricalTradesParams & params) const
nodiscard

Old trade lookup.

GET /api/v3/historicalTrades.

Get older trades.

Weight(IP): 25

Security Type: NONE

Notes: Data Source: Database

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

◆ async_historical_trades()

template<class CompletionToken>
auto binance::spot::rest_api::MarketApi::async_historical_trades ( const HistoricalTradesParams & params,
CompletionToken && token ) const
inline

Asynchronous historical_trades().

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

◆ klines()

common::RestApiResponse< std::vector< std::vector< KlinesItemInner > > > binance::spot::rest_api::MarketApi::klines ( const KlinesParams & params) const
nodiscard

Kline/Candlestick data.

GET /api/v3/klines.

Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

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/rest-api/market#klines

◆ async_klines()

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

Asynchronous klines().

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

◆ reference_price()

common::RestApiResponse< ReferencePriceResponse > binance::spot::rest_api::MarketApi::reference_price ( const ReferencePriceParams & params) const
nodiscard

Query Reference Price.

GET /api/v3/referencePrice.

Query the reference price for a symbol.

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/rest-api/market#reference-price

◆ async_reference_price()

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

Asynchronous reference_price().

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

◆ reference_price_calculation()

common::RestApiResponse< ReferencePriceCalculationResponse > binance::spot::rest_api::MarketApi::reference_price_calculation ( const ReferencePriceCalculationParams & params) const
nodiscard

Query Reference Price Calculation.

GET /api/v3/referencePrice/calculation.

Describes how reference price is calculated for a given symbol.

Weight(IP): 2

Security Type: NONE

Notes: Data Source: Memory

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

◆ async_reference_price_calculation()

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

Asynchronous reference_price_calculation().

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

◆ ticker()

common::RestApiResponse< TickerResponse > binance::spot::rest_api::MarketApi::ticker ( const TickerParams & params = {}) const
nodiscard

Rolling window price change statistics.

GET /api/v3/ticker.

Note: This endpoint differs from GET /api/v3/ticker/24hr.

The statistical time range of this endpoint can be up to 59999ms longer than the requested windowSize.

openTime starts at the beginning of a minute, while the end time is the current time. Therefore, the actual interval can be up to 59999ms longer than the requested window.

For example, if closeTime is 1641287867099 (January 04, 2022 09:17:47:099 UTC) and windowSize is 1d, then openTime is 1641201420000 (January 3, 2022, 09:17:00 UTC).

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

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

◆ async_ticker()

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

Asynchronous ticker().

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

◆ ticker24hr()

common::RestApiResponse< Ticker24hrResponse > binance::spot::rest_api::MarketApi::ticker24hr ( const Ticker24hrParams & params = {}) const
nodiscard

24hr ticker price change statistics

GET /api/v3/ticker/24hr.

24 hour rolling window price change statistics. Careful when accessing this with no symbol.

Weight:

  • Parameter | Symbols Provided | Weight
  • symbol | 1 | 2
  • symbol | symbol parameter is omitted | 80
  • symbols | 1-20 | 2
  • symbols | 21-100 | 40
  • symbols | 101 or more | 80
  • symbols | symbols parameter is omitted | 80

Security Type: NONE

Notes: Data Source: Memory

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

◆ async_ticker24hr()

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

Asynchronous ticker24hr().

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

◆ ticker_book_ticker()

common::RestApiResponse< TickerBookTickerResponse > binance::spot::rest_api::MarketApi::ticker_book_ticker ( const TickerBookTickerParams & params = {}) const
nodiscard

Symbol order book ticker.

GET /api/v3/ticker/bookTicker.

Best price/qty on the order book for a symbol or symbols.

Weight: |Parameter|Symbols Provided|Weight| |—|—|—| |symbol| 1 |2| | |omitted| 4| |symbols| Any |4|

Security Type: NONE

Notes: Data Source: Memory

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

◆ async_ticker_book_ticker()

template<class CompletionToken>
auto binance::spot::rest_api::MarketApi::async_ticker_book_ticker ( const TickerBookTickerParams & params,
CompletionToken && token ) const
inline

Asynchronous ticker_book_ticker().

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

◆ ticker_price()

common::RestApiResponse< TickerPriceResponse > binance::spot::rest_api::MarketApi::ticker_price ( const TickerPriceParams & params = {}) const
nodiscard

Symbol price ticker.

GET /api/v3/ticker/price.

Latest price for a symbol or symbols.

Weight: |Parameter|Symbols Provided|Weight| |—|—|—| |symbol| 1 |2| | |omitted| 4| |symbols| Any |4|

Security Type: NONE

Notes: Data Source: Memory

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

◆ async_ticker_price()

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

Asynchronous ticker_price().

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

◆ ticker_trading_day()

common::RestApiResponse< TickerTradingDayResponse > binance::spot::rest_api::MarketApi::ticker_trading_day ( const TickerTradingDayParams & params = {}) const
nodiscard

Trading Day Ticker.

GET /api/v3/ticker/tradingDay.

Price change statistics for a trading day.

Weight: 4 for each requested symbol. 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/rest-api/market#ticker-trading-day

◆ async_ticker_trading_day()

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

Asynchronous ticker_trading_day().

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

◆ ui_klines()

common::RestApiResponse< std::vector< std::vector< KlinesItemInner > > > binance::spot::rest_api::MarketApi::ui_klines ( const UiKlinesParams & params) const
nodiscard

UIKlines.

GET /api/v3/uiKlines.

The 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/rest-api/market#ui-klines

◆ async_ui_klines()

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

Asynchronous ui_klines().

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