pub struct FutOptSubscription {
pub channel: FutOptChannel,
pub symbols: Symbols,
pub after_hours: bool,
}Expand description
FutOpt-specific subscription parameters.
Supports afterHours for after-hours sessions (盤後).
§Example
use marketdata_core::models::futopt::FutOptChannel;
use marketdata_core::websocket::channels::FutOptSubscription;
// Single contract
let sub = FutOptSubscription::new(FutOptChannel::Trades, "TXFC4");
assert_eq!(sub.keys(), vec!["trades:TXFC4".to_string()]);
// Batch
let batch = FutOptSubscription::new(FutOptChannel::Trades, vec!["TXFC4", "MXFC4"]);
assert_eq!(batch.keys(), vec!["trades:TXFC4".to_string(), "trades:MXFC4".to_string()]);
// After-hours session
let ah = FutOptSubscription::new(FutOptChannel::Trades, "TXFC4").with_after_hours(true);
assert_eq!(ah.keys(), vec!["trades:TXFC4:afterhours".to_string()]);Fields§
§channel: FutOptChannelChannel to subscribe to.
symbols: SymbolsOne or many contract symbols.
after_hours: booltrue: 盤後 (after-hours), false: 一般盤 (regular, default).
Implementations§
Source§impl FutOptSubscription
impl FutOptSubscription
Sourcepub fn new(
channel: FutOptChannel,
symbols: impl Into<Symbols>,
) -> FutOptSubscription
pub fn new( channel: FutOptChannel, symbols: impl Into<Symbols>, ) -> FutOptSubscription
Create a FutOpt subscription. Accepts the same input shapes as
StockSubscription::new.
The input runs through Symbols::normalized before being stored,
so duplicate symbols collapse to one subscription.
Sourcepub fn with_after_hours(self, after_hours: bool) -> FutOptSubscription
pub fn with_after_hours(self, after_hours: bool) -> FutOptSubscription
Set the after-hours 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).
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
afterHours: 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 FutOptSubscription
impl Clone for FutOptSubscription
Source§fn clone(&self) -> FutOptSubscription
fn clone(&self) -> FutOptSubscription
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FutOptSubscription
impl RefUnwindSafe for FutOptSubscription
impl Send for FutOptSubscription
impl Sync for FutOptSubscription
impl Unpin for FutOptSubscription
impl UnsafeUnpin for FutOptSubscription
impl UnwindSafe for FutOptSubscription
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more