Skip to main content

futucli/
qot_sdk_adapter.rs

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