Skip to main content

StockSubscription

Struct StockSubscription 

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

Channel to subscribe to.

§symbols: Symbols

One or many symbols.

§intraday_odd_lot: bool

true: 盤中零股, false: 股票 (default).

Implementations§

Source§

impl StockSubscription

Source

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.

Source

pub fn with_odd_lot(self, odd_lot: bool) -> StockSubscription

Set the odd-lot 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).

Keys are used by SubscriptionManager to bookkeep server-id mapping and unsubscribe lookup. Each batch symbol owns its own row.

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 intradayOddLot: true when set.

Source

pub fn to_subscribe_request(&self) -> Value

Full subscribe request envelope.

Trait Implementations§

Source§

impl Clone for StockSubscription

Source§

fn clone(&self) -> StockSubscription

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 StockSubscription

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