pub enum MarketDataMessage {
QuotesSuccess(SubscribeSuccessPayload),
Quotes(QuotesData),
OrderBookSuccess(SubscribeSuccessPayload),
OrderBook(OrderBookData),
LastTradesSuccess(SubscribeSuccessPayload),
LastTrades(LastTradesData),
LastCandleSuccess(SubscribeSuccessPayload),
LastCandle(LastCandleData),
ErrorResponse(MarketDataError),
Undefined,
}Expand description
A frame of the market data channel, told apart by its responseType.
The success variants confirm a subscription. The data variants carry the data. A value of
responseType this library does not know reads as MarketDataMessage::Undefined.
Error frames of the documented shape do not arrive as ErrorResponse. The docs show an error as
a frame with the responseType of the data (for example OrderBook) and an errors list. Such a frame
does not fit the data type, so the parser returns it as
IncomingMessage::Unknown with the raw text. The
ErrorResponse variant is for a frame that really has responseType = "ErrorResponse".
§Examples
use brokapi_bcs_protocol::ws::models::MarketDataMessage;
let frame = r#"{"responseType":"LastTrades","ticker":"SBER","classCode":"TQBR","side":"BUY","price":300.15,"quantity":100}"#;
match serde_json::from_str::<MarketDataMessage>(frame)? {
MarketDataMessage::LastTrades(t) => assert_eq!(t.quantity, dec!(100.0)),
other => panic!("unexpected: {other:?}"),
}Variants§
QuotesSuccess(SubscribeSuccessPayload)
The subscription to quotes was accepted.
Quotes(QuotesData)
A quote update.
OrderBookSuccess(SubscribeSuccessPayload)
The subscription to the order book was accepted.
OrderBook(OrderBookData)
An order book update.
LastTradesSuccess(SubscribeSuccessPayload)
The subscription to the trades tape was accepted.
LastTrades(LastTradesData)
One trade of the tape.
LastCandleSuccess(SubscribeSuccessPayload)
The subscription to the last candle was accepted (responseType is CandleStickSuccess).
LastCandle(LastCandleData)
An update of the last candle (responseType is CandleStick).
ErrorResponse(MarketDataError)
An error frame with responseType = "ErrorResponse". See the note on the type.
Undefined
A responseType this library does not know.
Trait Implementations§
Source§impl Clone for MarketDataMessage
impl Clone for MarketDataMessage
Source§fn clone(&self) -> MarketDataMessage
fn clone(&self) -> MarketDataMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more