Skip to main content

futu_core/
qot_plate_market.rs

1//! Endpoint-local QOT market subset shared by PlateSet public surfaces.
2//!
3//! `Qot_GetPlateSet` accepts `Qot_Common.QotMarket`, while C++ rejects
4//! `QotMarket_Unknown` before resolving the market/set pair through
5//! `GetPlateSetID`. Keep Rust's user-input allow-list in one core contract so
6//! CLI/MCP do not maintain drifting copies.
7
8pub const QOT_PLATE_MARKET_VALID_VALUES: &str =
9    "HK=1, HK_FUTURE=2, US=11, CN/SH=21, SZ=22, SG=31, JP=41, MY=61, CC=91";
10
11#[must_use]
12pub fn is_plate_market(value: i32) -> bool {
13    matches!(value, 1 | 2 | 11 | 21 | 22 | 31 | 41 | 61 | 91)
14}
15
16#[must_use]
17pub fn plate_market_from_str_alias(raw: &str) -> Option<i32> {
18    let trimmed = raw.trim();
19    let value = if let Ok(value) = trimmed.parse::<i32>() {
20        value
21    } else {
22        crate::qot_symbol::qot_market_from_str_alias(trimmed)?
23    };
24    is_plate_market(value).then_some(value)
25}