Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
Loading...
Searching...
No Matches
binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection Class Reference

A connection to the DerivativesTradingCoinFutures WebSocket streams, returned connected by WebsocketStreams::connect(). More...

#include <websocket_streams.hpp>

Public Member Functions

const common::WebsocketStreamsConfig & configuration () const noexcept
void disconnect ()
template<class CompletionToken>
auto async_disconnect (CompletionToken &&token)
bool is_connected () const
void ping_server ()
 Sends a ping frame on every open connection.
template<class F>
common::Subscription on_event (F &&callback)
 Registers a lifecycle callback (common::WebsocketEvent).
common::WebsocketStreamHandle stream (std::string name, std::optional< common::StreamId > id={}, std::optional< std::string > url_path={})
 Subscribes to a stream by its name, for streams the SDK does not wrap yet, and returns a handle for its callbacks (payloads as boost::json::value).
void subscribe (const std::vector< std::string > &streams, std::optional< common::StreamId > id={}, const std::optional< std::string > &url_path={})
 Subscribes to raw stream names. Messages are delivered to handles from stream().
void unsubscribe (const std::vector< std::string > &streams, std::optional< common::StreamId > id={}, const std::optional< std::string > &url_path={})
bool is_subscribed (const std::string &stream) const
template<class CompletionToken>
auto async_wait_subscribed (std::string stream, std::optional< std::string > url_path, CompletionToken &&token)
 Completes once the server has acknowledged the subscription of stream; see common::WebsocketStreams::async_wait_subscribed.
void wait_subscribed (std::string stream, std::optional< std::string > url_path={}, std::optional< std::chrono::milliseconds > timeout={})
common::WebsocketStream< UserDataStreamEventsResponse > user_data (std::string listen_key, std::optional< common::StreamId > id={}) const
 User data stream of listen_key, as returned by start_user_data_stream() of the REST API.
common::WebsocketStream< AggregateTradeStreamsResponse > aggregate_trade_streams (const AggregateTradeStreamsParams &params) const
 Aggregate Trade Streams.
common::WebsocketStream< AllBookTickersStreamResponse > all_book_tickers_stream (const AllBookTickersStreamParams &params={}) const
 All Book Tickers Stream.
common::WebsocketStream< AllMarketLiquidationOrderStreamsResponse > all_market_liquidation_order_streams (const AllMarketLiquidationOrderStreamsParams &params={}) const
 All Market Liquidation Order Streams.
common::WebsocketStream< std::vector< AllMarketMiniTickersStreamResponseInner > > all_market_mini_tickers_stream (const AllMarketMiniTickersStreamParams &params={}) const
 All Market Mini Tickers Stream.
common::WebsocketStream< std::vector< AllMarketTickersStreamsResponseInner > > all_market_tickers_streams (const AllMarketTickersStreamsParams &params={}) const
 All Market Tickers Streams.
common::WebsocketStream< ContinuousContractKlineCandlestickStreamsResponse > continuous_contract_kline_candlestick_streams (const ContinuousContractKlineCandlestickStreamsParams &params) const
 Continuous Contract Kline/Candlestick Streams.
common::WebsocketStream< ContractInfoStreamResponse > contract_info_stream (const ContractInfoStreamParams &params={}) const
 Contract Info Stream.
common::WebsocketStream< DiffBookDepthStreamsResponse > diff_book_depth_streams (const DiffBookDepthStreamsParams &params) const
 Diff.
common::WebsocketStream< IndexKlineCandlestickStreamsResponse > index_kline_candlestick_streams (const IndexKlineCandlestickStreamsParams &params) const
 Index Kline/Candlestick Streams.
common::WebsocketStream< IndexPriceStreamResponse > index_price_stream (const IndexPriceStreamParams &params) const
 Index Price Stream.
common::WebsocketStream< IndividualSymbolBookTickerStreamsResponse > individual_symbol_book_ticker_streams (const IndividualSymbolBookTickerStreamsParams &params) const
 Individual Symbol Book Ticker Streams.
common::WebsocketStream< IndividualSymbolMiniTickerStreamResponse > individual_symbol_mini_ticker_stream (const IndividualSymbolMiniTickerStreamParams &params) const
 Individual Symbol Mini Ticker Stream.
common::WebsocketStream< IndividualSymbolTickerStreamsResponse > individual_symbol_ticker_streams (const IndividualSymbolTickerStreamsParams &params) const
 Individual Symbol Ticker Streams.
common::WebsocketStream< KlineCandlestickStreamsResponse > kline_candlestick_streams (const KlineCandlestickStreamsParams &params) const
 Kline/Candlestick Streams.
common::WebsocketStream< MarkPriceKlineCandlestickStreamsResponse > mark_price_kline_candlestick_streams (const MarkPriceKlineCandlestickStreamsParams &params) const
 Mark Price Kline/Candlestick Streams.
common::WebsocketStream< std::vector< MarkPriceOfAllSymbolsOfAPairResponseInner > > mark_price_of_all_symbols_of_a_pair (const MarkPriceOfAllSymbolsOfAPairParams &params) const
 Mark Price of All Symbols of a Pair.
common::WebsocketStream< MarkPriceStreamResponse > mark_price_stream (const MarkPriceStreamParams &params) const
 Mark Price Stream.
common::WebsocketStream< MarketLiquidationOrderStreamsResponse > market_liquidation_order_streams (const MarketLiquidationOrderStreamsParams &params) const
 Market Liquidation Order Streams.
common::WebsocketStream< PartialBookDepthStreamsResponse > partial_book_depth_streams (const PartialBookDepthStreamsParams &params) const
 Partial Book Depth Streams.

Friends

class WebsocketStreams

Detailed Description

A connection to the DerivativesTradingCoinFutures WebSocket streams, returned connected by WebsocketStreams::connect().

Cheap to copy: copies share one common::WebsocketStreams (connection pool and executor), which reconnects, renews its connections and resubscribes until disconnect().

Member Function Documentation

◆ configuration()

const common::WebsocketStreamsConfig & binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::configuration ( ) const
inlinenodiscardnoexcept

◆ disconnect()

void binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::disconnect ( )
inline

◆ async_disconnect()

template<class CompletionToken>
auto binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::async_disconnect ( CompletionToken && token)
inline

◆ is_connected()

bool binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::is_connected ( ) const
inlinenodiscard

◆ ping_server()

void binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::ping_server ( )
inline

Sends a ping frame on every open connection.

◆ on_event()

template<class F>
common::Subscription binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::on_event ( F && callback)
inline

Registers a lifecycle callback (common::WebsocketEvent).

Destroying the returned subscription removes it.

◆ stream()

common::WebsocketStreamHandle binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::stream ( std::string name,
std::optional< common::StreamId > id = {},
std::optional< std::string > url_path = {} )
inlinenodiscard

Subscribes to a stream by its name, for streams the SDK does not wrap yet, and returns a handle for its callbacks (payloads as boost::json::value).

Data arriving before the first callback is added is kept for it (up to 1000 messages).

◆ subscribe()

void binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::subscribe ( const std::vector< std::string > & streams,
std::optional< common::StreamId > id = {},
const std::optional< std::string > & url_path = {} )
inline

Subscribes to raw stream names. Messages are delivered to handles from stream().

◆ unsubscribe()

void binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::unsubscribe ( const std::vector< std::string > & streams,
std::optional< common::StreamId > id = {},
const std::optional< std::string > & url_path = {} )
inline

◆ is_subscribed()

bool binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::is_subscribed ( const std::string & stream) const
inlinenodiscard

◆ async_wait_subscribed()

template<class CompletionToken>
auto binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::async_wait_subscribed ( std::string stream,
std::optional< std::string > url_path,
CompletionToken && token )
inline

Completes once the server has acknowledged the subscription of stream; see common::WebsocketStreams::async_wait_subscribed.

◆ wait_subscribed()

void binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::wait_subscribed ( std::string stream,
std::optional< std::string > url_path = {},
std::optional< std::chrono::milliseconds > timeout = {} )
inline

◆ user_data()

common::WebsocketStream< UserDataStreamEventsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::user_data ( std::string listen_key,
std::optional< common::StreamId > id = {} ) const
inlinenodiscard

User data stream of listen_key, as returned by start_user_data_stream() of the REST API.

◆ aggregate_trade_streams()

common::WebsocketStream< AggregateTradeStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::aggregate_trade_streams ( const AggregateTradeStreamsParams & params) const
inlinenodiscard

Aggregate Trade Streams.

<symbol>@aggTrade.

The Aggregate Trade Streams push market trade information that is aggregated for fills with same price and taking side every 100 milliseconds.

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 100ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#aggregate-trade-streams

◆ all_book_tickers_stream()

common::WebsocketStream< AllBookTickersStreamResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::all_book_tickers_stream ( const AllBookTickersStreamParams & params = {}) const
inlinenodiscard

All Book Tickers Stream.

!bookTicker.

Pushes any update to the best bid or ask's price or quantity in real-time for all symbols.

After CM migration, this stream pushes the merged UM + CM universe (subscribable on both fstream and dstream); each payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: Real-time

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#all-book-tickers-stream

◆ all_market_liquidation_order_streams()

common::WebsocketStream< AllMarketLiquidationOrderStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::all_market_liquidation_order_streams ( const AllMarketLiquidationOrderStreamsParams & params = {}) const
inlinenodiscard

All Market Liquidation Order Streams.

!forceOrder@arr.

The All Liquidation Order Snapshot Streams push force liquidation order information for all symbols in the market. For each symbol,only the latest one liquidation order within 1000ms will be pushed as the snapshot. If no liquidation happens in the interval of 1000ms, no stream will be pushed.

After CM migration, this stream pushes the merged UM + CM universe (subscribable on both fstream and dstream); each payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#all-market-liquidation-order-streams

◆ all_market_mini_tickers_stream()

common::WebsocketStream< std::vector< AllMarketMiniTickersStreamResponseInner > > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::all_market_mini_tickers_stream ( const AllMarketMiniTickersStreamParams & params = {}) const
inlinenodiscard

All Market Mini Tickers Stream.

!miniTicker@arr.

24hr rolling window mini-ticker statistics for all symbols. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before. Note that only tickers that have changed will be present in the array.

After CM migration, this stream pushes the merged UM + CM universe (subscribable on both fstream and dstream); each payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#all-market-mini-tickers-stream

◆ all_market_tickers_streams()

common::WebsocketStream< std::vector< AllMarketTickersStreamsResponseInner > > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::all_market_tickers_streams ( const AllMarketTickersStreamsParams & params = {}) const
inlinenodiscard

All Market Tickers Streams.

!ticker@arr.

24hr rolling window ticker statistics for all symbols. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before. Note that only tickers that have changed will be present in the array.

After CM migration, this stream pushes the merged UM + CM universe (subscribable on both fstream and dstream); each payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#all-market-tickers-streams

◆ continuous_contract_kline_candlestick_streams()

common::WebsocketStream< ContinuousContractKlineCandlestickStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::continuous_contract_kline_candlestick_streams ( const ContinuousContractKlineCandlestickStreamsParams & params) const
inlinenodiscard

Continuous Contract Kline/Candlestick Streams.

<pair>_<contractType>@continuousKline_<interval>.

Kline update every second

After CM migration, both fstream and dstream may subscribe to either UM or CM symbols on this stream.

Update Speed: 250ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#continuous-contract-kline-candlestick-streams

◆ contract_info_stream()

common::WebsocketStream< ContractInfoStreamResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::contract_info_stream ( const ContractInfoStreamParams & params = {}) const
inlinenodiscard

Contract Info Stream.

!contractInfo.

ContractInfo stream pushes when contract info updates(listing/settlement/contract bracket update). bks field only shows up when bracket gets updated.

After CM migration, this stream pushes the merged UM + CM universe (subscribable on both fstream and dstream); each payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: Real-time

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#contract-info-stream

◆ diff_book_depth_streams()

common::WebsocketStream< DiffBookDepthStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::diff_book_depth_streams ( const DiffBookDepthStreamsParams & params) const
inlinenodiscard

Diff.

Book Depth Streams

<symbol>@depth@<updateSpeed>.

Bids and asks, pushed every 250 milliseconds, 500 milliseconds, or 100 milliseconds

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 250ms or 500ms or 100ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#diff-book-depth-streams

◆ index_kline_candlestick_streams()

common::WebsocketStream< IndexKlineCandlestickStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::index_kline_candlestick_streams ( const IndexKlineCandlestickStreamsParams & params) const
inlinenodiscard

Index Kline/Candlestick Streams.

<pair>@indexPriceKline_<interval>.

Index Kline/Candlestick Streams

After CM migration, both fstream and dstream may subscribe to CM symbols on this stream.

Update Speed: 250ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#index-kline-candlestick-streams

◆ index_price_stream()

common::WebsocketStream< IndexPriceStreamResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::index_price_stream ( const IndexPriceStreamParams & params) const
inlinenodiscard

Index Price Stream.

<pair>@indexPrice@<updateSpeed>.

Index Price Stream

Update Speed: 3000ms OR 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#index-price-stream

◆ individual_symbol_book_ticker_streams()

common::WebsocketStream< IndividualSymbolBookTickerStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::individual_symbol_book_ticker_streams ( const IndividualSymbolBookTickerStreamsParams & params) const
inlinenodiscard

Individual Symbol Book Ticker Streams.

<symbol>@bookTicker.

Pushes any update to the best bid or ask's price or quantity in real-time for a specified symbol.

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: Real-time

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#individual-symbol-book-ticker-streams

◆ individual_symbol_mini_ticker_stream()

common::WebsocketStream< IndividualSymbolMiniTickerStreamResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::individual_symbol_mini_ticker_stream ( const IndividualSymbolMiniTickerStreamParams & params) const
inlinenodiscard

Individual Symbol Mini Ticker Stream.

<symbol>@miniTicker.

24hr rolling window mini-ticker statistics for a single symbol. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before.

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 500ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#individual-symbol-mini-ticker-stream

◆ individual_symbol_ticker_streams()

common::WebsocketStream< IndividualSymbolTickerStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::individual_symbol_ticker_streams ( const IndividualSymbolTickerStreamsParams & params) const
inlinenodiscard

Individual Symbol Ticker Streams.

<symbol>@ticker.

24hr rolling window ticker statistics for a single symbol. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before.

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 500ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#individual-symbol-ticker-streams

◆ kline_candlestick_streams()

common::WebsocketStream< KlineCandlestickStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::kline_candlestick_streams ( const KlineCandlestickStreamsParams & params) const
inlinenodiscard

Kline/Candlestick Streams.

<symbol>@kline_<interval>.

The Kline/Candlestick Stream push updates to the current klines/candlestick every 250 milliseconds (if existing).

After CM migration, both fstream and dstream may subscribe to either UM or CM symbols on this stream.

Update Speed: 250ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#kline-candlestick-streams

◆ mark_price_kline_candlestick_streams()

common::WebsocketStream< MarkPriceKlineCandlestickStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::mark_price_kline_candlestick_streams ( const MarkPriceKlineCandlestickStreamsParams & params) const
inlinenodiscard

Mark Price Kline/Candlestick Streams.

<symbol>@markPriceKline_<interval>.

Mark Price Kline/Candlestick Streams

After CM migration, both fstream and dstream may subscribe to CM symbols on this stream.

Update Speed: 250ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#mark-price-kline-candlestick-streams

◆ mark_price_of_all_symbols_of_a_pair()

common::WebsocketStream< std::vector< MarkPriceOfAllSymbolsOfAPairResponseInner > > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::mark_price_of_all_symbols_of_a_pair ( const MarkPriceOfAllSymbolsOfAPairParams & params) const
inlinenodiscard

Mark Price of All Symbols of a Pair.

<pair>@markPrice@<updateSpeed>.

Mark Price of All Symbols of a Pair

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM); both fstream and dstream may subscribe to either UM or CM symbols on this stream.

Update Speed: 3000ms OR 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#mark-price-of-all-symbols-of-apair

◆ mark_price_stream()

common::WebsocketStream< MarkPriceStreamResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::mark_price_stream ( const MarkPriceStreamParams & params) const
inlinenodiscard

Mark Price Stream.

<symbol>@markPrice@<updateSpeed>.

Mark price update stream

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM); both fstream and dstream may subscribe to either UM or CM symbols on this stream.

Update Speed: 3000ms OR 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#mark-price-stream

◆ market_liquidation_order_streams()

common::WebsocketStream< MarketLiquidationOrderStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::market_liquidation_order_streams ( const MarketLiquidationOrderStreamsParams & params) const
inlinenodiscard

Market Liquidation Order Streams.

<symbol>@forceOrder.

The Liquidation Order Snapshot Streams push force liquidation order information for specific symbol. For each symbol,only the latest one liquidation order within 1000ms will be pushed as the snapshot. If no liquidation happens in the interval of 1000ms, no stream will be pushed.

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#market-liquidation-order-streams

◆ partial_book_depth_streams()

common::WebsocketStream< PartialBookDepthStreamsResponse > binance::derivatives_trading_coin_futures::websocket_streams::WebsocketStreamsConnection::partial_book_depth_streams ( const PartialBookDepthStreamsParams & params) const
inlinenodiscard

Partial Book Depth Streams.

<symbol>@depth<levels>@<updateSpeed>.

Top levels bids and asks.

After CM migration, the payload is appended with a new st field (1 = UM, 2 = CM).

Update Speed: 250ms, 500ms or 100ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-coin-m-futures/api/ws-streams/~#partial-book-depth-streams

◆ WebsocketStreams

friend class WebsocketStreams
friend