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

A connection to the DerivativesTradingOptions 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< std::vector< IndexPriceStreamsResponseInner > > index_price_streams (const IndexPriceStreamsParams &params={}) const
 Index Price Streams.
common::WebsocketStream< KlineCandlestickStreamsResponse > kline_candlestick_streams (const KlineCandlestickStreamsParams &params) const
 Kline/Candlestick Streams.
common::WebsocketStream< NewSymbolInfoResponse > new_symbol_info (const NewSymbolInfoParams &params={}) const
 New Symbol Info.
common::WebsocketStream< std::vector< OpenInterestResponseInner > > open_interest (const OpenInterestParams &params) const
 Open Interest.
common::WebsocketStream< std::vector< OptionMarkPriceResponseInner > > option_mark_price (const OptionMarkPriceParams &params) const
 Option Mark Price.
common::WebsocketStream< DiffBookDepthStreamsResponse > diff_book_depth_streams (const DiffBookDepthStreamsParams &params) const
 Diff Book Depth Streams.
common::WebsocketStream< Hour24TickerResponse > hour24_ticker (const Hour24TickerParams &params) const
 24-hour TICKER
common::WebsocketStream< IndividualSymbolBookTickerStreamsResponse > individual_symbol_book_ticker_streams (const IndividualSymbolBookTickerStreamsParams &params) const
 Individual Symbol Book Ticker Streams.
common::WebsocketStream< PartialBookDepthStreamsResponse > partial_book_depth_streams (const PartialBookDepthStreamsParams &params) const
 Partial Book Depth Streams.
common::WebsocketStream< TradeStreamsResponse > trade_streams (const TradeStreamsParams &params) const
 Trade Streams.

Friends

class WebsocketStreams

Detailed Description

A connection to the DerivativesTradingOptions 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_options::websocket_streams::WebsocketStreamsConnection::configuration ( ) const
inlinenodiscardnoexcept

◆ disconnect()

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

◆ async_disconnect()

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

◆ is_connected()

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

◆ ping_server()

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

Sends a ping frame on every open connection.

◆ on_event()

template<class F>
common::Subscription binance::derivatives_trading_options::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_options::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_options::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_options::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_options::websocket_streams::WebsocketStreamsConnection::is_subscribed ( const std::string & stream) const
inlinenodiscard

◆ async_wait_subscribed()

template<class CompletionToken>
auto binance::derivatives_trading_options::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_options::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_options::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.

◆ index_price_streams()

common::WebsocketStream< std::vector< IndexPriceStreamsResponseInner > > binance::derivatives_trading_options::websocket_streams::WebsocketStreamsConnection::index_price_streams ( const IndexPriceStreamsParams & params = {}) const
inlinenodiscard

Index Price Streams.

!index@arr.

Underlying(e.g ETHUSDT) index stream.

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/market#index-price-streams

◆ kline_candlestick_streams()

common::WebsocketStream< KlineCandlestickStreamsResponse > binance::derivatives_trading_options::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 1000 milliseconds (if existing).

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/market#kline-candlestick-streams

◆ new_symbol_info()

common::WebsocketStream< NewSymbolInfoResponse > binance::derivatives_trading_options::websocket_streams::WebsocketStreamsConnection::new_symbol_info ( const NewSymbolInfoParams & params = {}) const
inlinenodiscard

New Symbol Info.

!optionSymbol.

New symbol listing stream.

Update Speed: 50ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/market#new-symbol-info

◆ open_interest()

common::WebsocketStream< std::vector< OpenInterestResponseInner > > binance::derivatives_trading_options::websocket_streams::WebsocketStreamsConnection::open_interest ( const OpenInterestParams & params) const
inlinenodiscard

Open Interest.

<underlying>@optionOpenInterest@<expirationDate>.

Option open interest for specific underlying asset on specific expiration date. E.g.ethusdt@optionOpenInterest@221125

Update Speed: 60s

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/market#open-interest

◆ option_mark_price()

common::WebsocketStream< std::vector< OptionMarkPriceResponseInner > > binance::derivatives_trading_options::websocket_streams::WebsocketStreamsConnection::option_mark_price ( const OptionMarkPriceParams & params) const
inlinenodiscard

Option Mark Price.

<underlying>@optionMarkPrice.

The mark price for all option symbols on specific underlying asset. E.g.btcusdt@optionMarkPrice

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/market#option-mark-price

◆ diff_book_depth_streams()

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

Diff Book Depth Streams.

<symbol>@depth@<updateSpeed>.

Bids and asks, pushed every 500 milliseconds, 100 milliseconds (if existing)

Update Speed: 100ms or 500ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/public#diff-book-depth-streams

◆ hour24_ticker()

common::WebsocketStream< Hour24TickerResponse > binance::derivatives_trading_options::websocket_streams::WebsocketStreamsConnection::hour24_ticker ( const Hour24TickerParams & params) const
inlinenodiscard

24-hour TICKER

<symbol>@optionTicker<expirationDate>.

24hr ticker info for all symbols. Only symbols whose ticker info changed will be sent.

Update Speed: 1000ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/public#hour24-ticker

◆ individual_symbol_book_ticker_streams()

common::WebsocketStream< IndividualSymbolBookTickerStreamsResponse > binance::derivatives_trading_options::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.

Update Speed: Real-Time

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/public#individual-symbol-book-ticker-streams

◆ partial_book_depth_streams()

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

Partial Book Depth Streams.

<symbol>@depth<level>@<updateSpeed>.

Top <levels> bids and asks. Valid <levels> are 5, 10, 20.

Update Speed: 100ms or 500ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/public#partial-book-depth-streams

◆ trade_streams()

common::WebsocketStream< TradeStreamsResponse > binance::derivatives_trading_options::websocket_streams::WebsocketStreamsConnection::trade_streams ( const TradeStreamsParams & params) const
inlinenodiscard

Trade Streams.

<symbol>@optionTrade.

The Trade Streams push raw trade information for specific symbol or underlying asset. E.g.btcusdt@optionTrade

Update Speed: 50ms

See https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-options/api/ws-streams/public#trade-streams

◆ WebsocketStreams

friend class WebsocketStreams
friend