Skip to main content

futu_core/
qot_price_reminder.rs

1//! Endpoint-local market subset for QOT price reminders.
2//!
3//! `Qot_GetPriceReminder.market` is declared as `Qot_Common.QotMarket`, but C++
4//! maps only a supported subset through `ReminderMarket_APIToNN` before sending
5//! the backend request. Keep this contract separate from generic QOT symbol
6//! parsing so unsupported markets such as AU/CA/FX do not leak into this
7//! endpoint.
8
9pub const PRICE_REMINDER_MARKET_VALID_VALUES: &str =
10    "HK=1, HK_FUTURE=2, US=11, CN/SH=21, SZ=22, SG=31, JP=41, MY=61, CC=91";
11
12#[must_use]
13pub fn is_price_reminder_market(value: i32) -> bool {
14    matches!(value, 1 | 2 | 11 | 21 | 22 | 31 | 41 | 61 | 91)
15}
16
17#[must_use]
18pub fn price_reminder_market_from_str_alias(raw: &str) -> Option<i32> {
19    let trimmed = raw.trim();
20    let value = if let Ok(value) = trimmed.parse::<i32>() {
21        value
22    } else {
23        crate::qot_symbol::qot_market_from_str_alias(trimmed)?
24    };
25    is_price_reminder_market(value).then_some(value)
26}