|
Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
|
A connection to the Spot 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. | |
| common::WebsocketStream< AggTradeResponse > | agg_trade (const AggTradeParams ¶ms) const |
| Aggregate Trade Streams. | |
| common::WebsocketStream< std::vector< AllMarketRollingWindowTickerResponseInner > > | all_market_rolling_window_ticker (const AllMarketRollingWindowTickerParams ¶ms) const |
| All Market Rolling Window Statistics Streams. | |
| common::WebsocketStream< std::vector< AllMiniTickerResponseInner > > | all_mini_ticker (const AllMiniTickerParams ¶ms={}) const |
| All Market Mini Tickers Stream. | |
| common::WebsocketStream< AvgPriceResponse > | avg_price (const AvgPriceParams ¶ms) const |
| Average Price. | |
| common::WebsocketStream< BlockTradeResponse > | block_trade (const BlockTradeParams ¶ms) const |
| Block Trade Streams. | |
| common::WebsocketStream< BookTickerResponse > | book_ticker (const BookTickerParams ¶ms) const |
| Individual Symbol Book Ticker Streams. | |
| common::WebsocketStream< DiffBookDepthResponse > | diff_book_depth (const DiffBookDepthParams ¶ms) const |
| Diff. | |
| common::WebsocketStream< KlineResponse > | kline (const KlineParams ¶ms) const |
| Kline/Candlestick Streams for UTC. | |
| common::WebsocketStream< KlineOffsetResponse > | kline_offset (const KlineOffsetParams ¶ms) const |
| Kline/Candlestick Streams with timezone offset. | |
| common::WebsocketStream< MiniTickerResponse > | mini_ticker (const MiniTickerParams ¶ms) const |
| Individual Symbol Mini Ticker Stream. | |
| common::WebsocketStream< PartialBookDepthResponse > | partial_book_depth (const PartialBookDepthParams ¶ms) const |
| Partial Book Depth Streams. | |
| common::WebsocketStream< ReferencePriceResponse > | reference_price (const ReferencePriceParams ¶ms) const |
| Reference Price Streams. | |
| common::WebsocketStream< RollingWindowTickerResponse > | rolling_window_ticker (const RollingWindowTickerParams ¶ms) const |
| Individual Symbol Rolling Window Statistics Streams. | |
| common::WebsocketStream< TickerResponse > | ticker (const TickerParams ¶ms) const |
| Individual Symbol Ticker Streams. | |
| common::WebsocketStream< TradeResponse > | trade (const TradeParams ¶ms) const |
| Trade Streams. | |
Friends | |
| class | WebsocketStreams |
A connection to the Spot 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().
|
inlinenodiscardnoexcept |
|
inline |
|
inline |
|
inlinenodiscard |
|
inline |
Sends a ping frame on every open connection.
|
inline |
Registers a lifecycle callback (common::WebsocketEvent).
Destroying the returned subscription removes it.
|
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).
|
inline |
Subscribes to raw stream names. Messages are delivered to handles from stream().
|
inline |
|
inlinenodiscard |
|
inline |
Completes once the server has acknowledged the subscription of stream; see common::WebsocketStreams::async_wait_subscribed.
|
inline |
|
inlinenodiscard |
User data stream of listen_key.
No method of this SDK creates a listen key for this product: subscribe with user_data_stream_subscribe() of the WebSocket API instead.
|
inlinenodiscard |
Aggregate Trade Streams.
<symbol>@aggTrade.
The Aggregate Trade Streams push trade information that is aggregated for a single taker order.
Update Speed: Real-time
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-streams/~#agg-trade
|
inlinenodiscard |
All Market Rolling Window Statistics Streams.
!ticker_<windowSize>@arr.
Rolling window ticker statistics for all market symbols, computed over multiple windows.
Note that only tickers that have changed will be present in the array.
Update Speed: 1000ms
|
inlinenodiscard |
All Market Mini Tickers Stream.
!miniTicker@arr.
24hr rolling window mini-ticker statistics for all symbols that changed in an array. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs. Note that only tickers that have changed will be present in the array.
Update Speed: 1000ms
|
inlinenodiscard |
Average Price.
<symbol>@avgPrice.
Average price streams push changes in the average price over a fixed time interval.
Update Speed: 1000ms
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-streams/~#avg-price
|
inlinenodiscard |
Block Trade Streams.
<symbol>@blockTrade.
Block Trade Streams push block trade information in real-time.
Update Speed: Real-time
|
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.
Multiple <symbol>@bookTicker streams can be subscribed to over one connection.
Update Speed: Real-time
|
inlinenodiscard |
Diff.
Depth Stream
<symbol>@depth@<updateSpeed>.
Order book price and quantity depth updates used to locally manage an order book.
Update Speed: 1000ms or 100ms
|
inlinenodiscard |
Kline/Candlestick Streams for UTC.
<symbol>@kline_<interval>.
The Kline/Candlestick Stream push updates to the current klines/candlestick every second in UTC+0 timezone
Update Speed: 1000ms for 1s, 2000ms for the other intervals
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-streams/~#kline
|
inlinenodiscard |
Kline/Candlestick Streams with timezone offset.
<symbol>@kline_<interval>@+08:00.
The Kline/Candlestick Stream push updates to the current klines/candlestick every second in UTC+8 timezone
Kline/Candlestick chart intervals:
Supported intervals: See Kline/Candlestick chart intervals
UTC+8 timezone offset:
Update Speed: 1000ms for 1s, 2000ms for the other intervals
|
inlinenodiscard |
Individual Symbol Mini Ticker Stream.
<symbol>@miniTicker.
24hr rolling window mini-ticker statistics. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs.
Update Speed: 1000ms
|
inlinenodiscard |
Partial Book Depth Streams.
<symbol>@depth<levels>@<updateSpeed>.
Top **<levels>** bids and asks, pushed every second. Valid **<levels>** are 5, 10, or 20.
Update Speed: 1000ms or 100ms
|
inlinenodiscard |
Reference Price Streams.
<symbol>@referencePrice.
Reference price stream for a symbol.
Update Speed: 1000ms
|
inlinenodiscard |
Individual Symbol Rolling Window Statistics Streams.
<symbol>@ticker_<windowSize>.
Rolling window ticker statistics for a single symbol, computed over multiple windows.
Note: This stream is different from the <symbol>@ticker stream. The open time "O" always starts on a minute, while the closing time "C" is the current time of the update. As such, the effective window might be up to 59999ms wider than <windowSize>.
Update Speed: 1000ms
|
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 for the previous 24hrs.
Update Speed: 1000ms
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-streams/~#ticker
|
inlinenodiscard |
Trade Streams.
<symbol>@trade.
The Trade Streams push raw trade information; each trade has a unique buyer and seller.
Update Speed: Real-time
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-streams/~#trade
|
friend |