Skip to main content

futu_mcp/
qot_sdk_adapter.rs

1use futu_core::qot_symbol::ParsedQotSymbol;
2use futu_qot::types::{KLType, QotMarket, RehabType, Security, SubType};
3
4/// Compatibility-shell boundary: core owns public symbol parsing, while MCP
5/// still needs the legacy SDK `Security` DTO until command execution is fully
6/// raw/domain-backed.
7pub(crate) fn security_from_parsed_symbol(parsed: ParsedQotSymbol) -> Security {
8    Security::new(QotMarket::from_i32(parsed.market), parsed.code)
9}
10
11/// Compatibility-shell boundary for old futu-qot APIs that still accept
12/// `QotMarket` instead of a raw market id.
13pub(crate) fn qot_market_from_id(market: i32) -> QotMarket {
14    QotMarket::from_i32(market)
15}
16
17/// Compatibility-shell boundary for fixed quote-read subscriptions.
18pub(crate) fn basic_sub_type() -> SubType {
19    SubType::Basic
20}
21
22/// Compatibility-shell boundary for fixed order-book subscriptions.
23pub(crate) fn order_book_sub_type(odd_lot: bool) -> SubType {
24    if odd_lot {
25        SubType::OrderBookOdd
26    } else {
27        SubType::OrderBook
28    }
29}
30
31/// Compatibility-shell boundary for fixed ticker subscriptions.
32pub(crate) fn ticker_sub_type() -> SubType {
33    SubType::Ticker
34}
35
36/// Compatibility-shell boundary for fixed real-time minute subscriptions.
37pub(crate) fn rt_sub_type() -> SubType {
38    SubType::RT
39}
40
41/// Compatibility-shell boundary for fixed broker-queue subscriptions.
42pub(crate) fn broker_sub_type() -> SubType {
43    SubType::Broker
44}
45
46/// Compatibility-shell boundary for old futu-qot APIs that still accept
47/// `KLType` instead of a raw kline type id.
48pub(crate) fn kl_type_from_public_id(kl_type: i32) -> Option<KLType> {
49    KLType::from_public_i32(kl_type)
50}
51
52/// Compatibility-shell boundary for shared surface rehab IDs.
53pub(crate) const fn rehab_type_from_id(rehab_type: i32) -> Option<RehabType> {
54    match rehab_type {
55        0 => Some(RehabType::None),
56        1 => Some(RehabType::Forward),
57        2 => Some(RehabType::Backward),
58        _ => None,
59    }
60}