pub struct StockSubscription {
pub channel: Channel,
pub symbols: Symbols,
pub intraday_odd_lot: bool,
}Expand description
Stock-specific subscription parameters.
Accepts either a single symbol or a batch via impl Into<Symbols>.
Supports intradayOddLot for odd-lot sessions.
§Example
use marketdata_core::models::Channel;
use marketdata_core::websocket::channels::StockSubscription;
// Single symbol
let sub = StockSubscription::new(Channel::Trades, "2330");
assert_eq!(sub.keys(), vec!["trades:2330".to_string()]);
// Batch — one frame, N internal entries
let batch = StockSubscription::new(Channel::Trades, vec!["2330", "2454"]);
assert_eq!(batch.keys(), vec!["trades:2330".to_string(), "trades:2454".to_string()]);
// Odd-lot session (modifier applies to every symbol)
let odd = StockSubscription::new(Channel::Trades, "2330").with_odd_lot(true);
assert_eq!(odd.keys(), vec!["trades:2330:oddlot".to_string()]);Fields§
§channel: ChannelChannel to subscribe to.
symbols: SymbolsOne or many symbols.
intraday_odd_lot: booltrue: 盤中零股, false: 股票 (default).
Implementations§
Source§impl StockSubscription
impl StockSubscription
Sourcepub fn new(channel: Channel, symbols: impl Into<Symbols>) -> StockSubscription
pub fn new(channel: Channel, symbols: impl Into<Symbols>) -> StockSubscription
Create a stock subscription. Accepts &str, String, Vec<String>,
array literals (["A", "B"]), and slices — see Symbols for
the full set of From impls.
The input runs through Symbols::normalized before being stored,
so duplicate symbols collapse to one subscription and whitespace-
only differences are squashed.
Sourcepub fn with_odd_lot(self, odd_lot: bool) -> StockSubscription
pub fn with_odd_lot(self, odd_lot: bool) -> StockSubscription
Set the odd-lot session flag (applies to every symbol in a batch).
Sourcepub fn keys(&self) -> Vec<String>
pub fn keys(&self) -> Vec<String>
Generate one local key per symbol (length 1 for Single, N for Many).
Keys are used by SubscriptionManager to bookkeep server-id mapping
and unsubscribe lookup. Each batch symbol owns its own row.
Sourcepub fn to_subscribe_data(&self) -> Value
pub fn to_subscribe_data(&self) -> Value
Wire-format data field for the subscribe message.
Routes to {"channel": ..., "symbol": ...} for Single or
{"channel": ..., "symbols": [...]} for Many. Adds
intradayOddLot: true when set.
Sourcepub fn to_subscribe_request(&self) -> Value
pub fn to_subscribe_request(&self) -> Value
Full subscribe request envelope.
Trait Implementations§
Source§impl Clone for StockSubscription
impl Clone for StockSubscription
Source§fn clone(&self) -> StockSubscription
fn clone(&self) -> StockSubscription
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more