Skip to main content

CachedSecurityInfo

Struct CachedSecurityInfo 

Source
pub struct CachedSecurityInfo {
Show 17 fields pub stock_id: u64, pub market: i32, pub mkt_id: u32, pub code: String, pub name: String, pub lot_size: i32, pub sec_type: i32, pub list_time: String, pub warrnt_stock_owner: u64, pub delisting: bool, pub exch_type: i32, pub no_search: bool, pub future_origin_id: u64, pub zhuli_id: u64, pub source: SecurityInfoSource, pub exchange: String, pub listed_exchange: String,
}
Expand description

股票静态信息

v1.4.106 codex F5: 加 Default impl 让 caller 可用 CachedSecurityInfo { stock_id: ..., market: ..., ..Default::default() }. 现有显式 callsite 不动, 新加 callsite 可省冗余字段.

Fields§

§stock_id: u64§market: i32

FTAPI QotMarket 值 (1=HK_Security, 11=US_Security, 21=CNSH, 22=CNSZ 等)

由 bridge.rs market_code_to_qot_market() 从 backend market_code (NN_QuoteMktID) 映射而来; 用于构造 cache key "{market}_{code}"

§mkt_id: u32

Backend 原始 NN_QuoteMktID (market_code), 保留子交易所精度

用于 cache-first 路由决策: 比如 CME Group 子交易所 (60=NYMEX, 70=COMEX, 80=CBOT, 90=CME, 100=CBOE) 都被 market_code_to_qot_market() 统一压到 FTAPI QotMarket=11 (US_Security), 但 mkt_id 保留原始 range, 使 derive_security_type / us_futures_sub_exchange 等能做 O(1) 范围 判别, 替代 CLAUDE.md 坑 #35 的 code-pattern 启发式. SQLite 历史行无此 字段时读为 0 (默认 Unknown), 下次 upsert 自动修正.

§code: String§name: String§lot_size: i32§sec_type: i32§list_time: String§warrnt_stock_owner: u64

窝轮所属正股 ID, 0 表示无

§delisting: bool

是否已退市

§exch_type: i32

交易所类型 (ExchType)

§no_search: bool

不可搜索标记 (对齐 C++ no_search 字段)

§future_origin_id: u64

v1.4.106 codex F5: 期货主连合约关联 stock_id.

主连合约 (e.g. HSImain, NQmain) 此字段非 0, 指向真实月份合约 stock_id (CMD 6747 拉真实 code 用); 普通合约此字段为 0.

来源: backend stock_list_sync CSStockItem.origin_id (proto field 41). PlaceOrder F5 用 info.future_origin_id != 0 判 NeedPullFutureContractInfo (对齐 C++ Ndt_Qot_SecInfo::nFutureOriginID + APIServer_Trd_PlaceOrder .cpp:36-42 NeedPullFutureContractInfo).

SQLite 历史行无此列时默认 0, 下次 stock_list sync (CMD 6746) 重新写入.

§zhuli_id: u64

v1.4.106 codex F5: 期货主力合约 stock_id.

主连合约持有此字段, 指向当前主力合约 stock_id (流动性最大). PlaceOrder F5 在收到 CMD 6747 响应后用此字段反查真实 code 再下单.

来源: backend CSStockItem.zhuli_id (proto field 40). 普通合约 0.

§source: SecurityInfoSource

v1.4.106 codex 1148 F7 (P2): 数据来源 / 完整度标记。详见 SecurityInfoSource doc。默认 OnDemandBasic 以保守对待历史 caller 漏标场景 (能漏标的就是没填全字段, 当 partial 处理最安全)。

§exchange: String

v1.4.110 final E.5 P2#6: 交易所字符串 (proto CSStockItem.exchange field 57).

数据驱动 (pitfall #35 C++ 数据驱动 vs Rust 启发式): trade handler derive_exchange_str 优先用此字段, 缺失时 fallback 到 code prefix / pattern match heuristic. 取值例: “SEHK”, “NASDAQ”, “NYSE”, “SSE”, “SZSE”, “HKEX”.

§listed_exchange: String

v1.4.110 final E.5 P2#6: 上市交易所 (proto CSStockItem.listed_exchange field 74).

通常等同 exchange, dual-listed ADR / 双重主要上市等场景下可能不同.

Implementations§

Source§

impl CachedSecurityInfo

Source

pub fn needs_mkt_id_refresh(&self) -> bool

v1.4.89 P2-A: 判断 cache row 是否需要后台 mkt_id refresh.

场景: SQLite 历史行 (v1.4.77 Phase D 之前 upsert) 没有 mkt_id 字段, 读取时默认为 0. 这导致 cache-first 路由走 heuristic fallback (坑 #35).

true 即需要 refresh; 如果 mkt_id == 0 && market != 0, 是历史行 (有基本 market 但缺 sub-exchange 精度).

使用: StaticDataCache::mark_stale_mkt_id 在 get 时 opportunistic mark stale, 背景 worker 批量 CMD 20106 refresh.

Source

pub fn is_complete(&self) -> bool

v1.4.106 codex 1148 F7: 是否含完整静态字段 (基于 source). 调用方需要 list_time / warrnt_stock_owner / exch_type 等字段时, 应先 check 此 flag, false 时触发 backend 完整 refresh 或返 partial marker。

Trait Implementations§

Source§

impl Clone for CachedSecurityInfo

Source§

fn clone(&self) -> CachedSecurityInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CachedSecurityInfo

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CachedSecurityInfo

Source§

fn default() -> CachedSecurityInfo

Returns the “default value” for a type. 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more