futu_core/qot_right_gate/
model.rs1use super::constants::{
2 QOT_MARKET_CC_SECURITY, SECURITY_TYPE_CRYPTO, SECURITY_TYPE_DRVT, SECURITY_TYPE_FUTURE,
3 SECURITY_TYPE_INDEX,
4};
5
6#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
7pub struct SecurityRightClass {
8 pub sec_type: i32,
9 pub mkt_id: u32,
10 pub option_code_like: bool,
11}
12
13impl SecurityRightClass {
14 pub(super) fn is_option(self) -> bool {
15 self.sec_type == SECURITY_TYPE_DRVT || self.option_code_like
16 }
17
18 pub(super) fn is_future(self, public_market: i32) -> bool {
19 self.sec_type == SECURITY_TYPE_FUTURE
20 || (public_market == 11 && (60..=109).contains(&self.mkt_id))
21 }
22
23 pub(super) fn is_hk_future(self) -> bool {
24 self.sec_type == SECURITY_TYPE_FUTURE && matches!(self.mkt_id, 5 | 6 | 110..=119)
28 }
29
30 pub(super) fn is_us_security(self, public_market: i32) -> bool {
31 matches!(self.mkt_id, 10..=29 | 1200..=1249)
32 || (public_market == 11 && !self.is_future(public_market) && !self.is_option())
33 }
34
35 pub(super) fn is_us_otc(self) -> bool {
36 self.mkt_id == 13
39 }
40
41 pub(super) fn is_index(self) -> bool {
42 self.sec_type == SECURITY_TYPE_INDEX
43 }
44
45 pub(super) fn is_crypto(self, public_market: i32) -> bool {
46 self.sec_type == SECURITY_TYPE_CRYPTO
47 || public_market == QOT_MARKET_CC_SECURITY
48 || (360..=459).contains(&self.mkt_id)
49 }
50
51 pub(super) fn is_sh_market(self, public_market: i32) -> bool {
52 matches!(self.mkt_id, 30 | 32 | 33 | 34 | 36..=40) || public_market == 21
53 }
54
55 pub(super) fn is_sz_market(self, public_market: i32) -> bool {
56 matches!(self.mkt_id, 31 | 35) || public_market == 22
57 }
58
59 pub(super) fn is_sg_future(self) -> bool {
60 self.sec_type == SECURITY_TYPE_FUTURE && (160..=179).contains(&self.mkt_id)
61 }
62
63 pub(super) fn is_jp_future(self) -> bool {
64 self.sec_type == SECURITY_TYPE_FUTURE && (185..=194).contains(&self.mkt_id)
65 }
66
67 pub(super) fn is_sg_security_market(self, public_market: i32) -> bool {
68 (180..=184).contains(&self.mkt_id)
71 || (public_market == 31
72 && self.sec_type != SECURITY_TYPE_FUTURE
73 && self.sec_type != SECURITY_TYPE_DRVT)
74 }
75
76 pub(super) fn is_my_security_market(self, public_market: i32) -> bool {
77 (1350..=1399).contains(&self.mkt_id)
80 || (public_market == 61
81 && self.sec_type != SECURITY_TYPE_FUTURE
82 && self.sec_type != SECURITY_TYPE_DRVT)
83 }
84
85 pub(super) fn is_jp_security_market(self, public_market: i32) -> bool {
86 (830..=849).contains(&self.mkt_id)
90 || (public_market == 41
91 && self.sec_type != SECURITY_TYPE_FUTURE
92 && self.sec_type != SECURITY_TYPE_DRVT
93 && !self.is_jp_future()
94 && !(800..=829).contains(&self.mkt_id))
95 }
96}
97
98#[derive(Debug, Clone, Copy, PartialEq, Eq)]
99pub struct QotSubRightSecurity<'a> {
100 pub market: i32,
101 pub code: &'a str,
102 pub security: SecurityRightClass,
103}
104
105#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
106pub struct QotRightSnapshot {
107 pub hk_qot_right: i32,
108 pub us_qot_right: i32,
109 pub sh_qot_right: i32,
110 pub sz_qot_right: i32,
111 pub hk_option_qot_right: i32,
112 pub hk_future_qot_right: i32,
113 pub hk_option_orderbook_depth: Option<u32>,
114 pub hk_future_orderbook_depth: Option<u32>,
115 pub us_option_qot_right: i32,
116 pub us_index_qot_right: i32,
117 pub us_otc_qot_right: i32,
118 pub us_cme_future_qot_right: i32,
119 pub us_cbot_future_qot_right: i32,
120 pub us_nymex_future_qot_right: i32,
121 pub us_comex_future_qot_right: i32,
122 pub us_cboe_future_qot_right: i32,
123 pub sg_future_qot_right: i32,
124 pub jp_future_qot_right: i32,
125 pub sg_stock_qot_right: i32,
126 pub my_stock_qot_right: i32,
127 pub jp_stock_qot_right: i32,
128 pub cc_qot_right: i32,
129 pub cc_pt_orderbook_qot_right: i32,
130 pub event_contract_qot_right: i32,
131 pub us_lv2_arca_qot_right: bool,
132 pub us_lv2_nyse_qot_right: bool,
133 pub us_lv2_nasdaq_totalview_qot_right: bool,
134}