Skip to main content

FutOptSubscription

Struct FutOptSubscription 

Source
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: FutOptChannel

Channel to subscribe to.

§symbols: Symbols

One or many contract symbols.

§after_hours: bool

true: 盤後 (after-hours), false: 一般盤 (regular, default).

Implementations§

Source§

impl FutOptSubscription

Source

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.

Source

pub fn with_after_hours(self, after_hours: bool) -> FutOptSubscription

Set the after-hours session flag (applies to every symbol in a batch).

Source

pub fn keys(&self) -> Vec<String>

Generate one local key per symbol (length 1 for Single, N for Many).

Source

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.

Source

pub fn to_subscribe_request(&self) -> Value

Full subscribe request envelope.

Trait Implementations§

Source§

impl Clone for FutOptSubscription

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for FutOptSubscription

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V