nautilus_interactive_brokers/python/
enums.rs1use pyo3::prelude::*;
13
14use crate::common::enums::{
15 IbAction, IbArticleType, IbAuctionStrategy, IbAuctionType, IbBondIdentifierKind,
16 IbBuilderTimeInForce, IbComboLegOpenClose, IbConditionConjunction, IbConditionKind,
17 IbExerciseAction, IbFundAssetType, IbFundDistributionPolicyIndicator, IbHistoricalBarSize,
18 IbHistoricalTickType, IbHistoricalWhatToShow, IbLegAction, IbLiquidity, IbOcaType,
19 IbOptionRight, IbOrderOpenClose, IbOrderOrigin, IbOrderStatus, IbOrderType, IbRealtimeBarSize,
20 IbRealtimeWhatToShow, IbReferencePriceType, IbRiskAversion, IbRule80A, IbSecurityType,
21 IbShortSaleSlot, IbTickType, IbTimeInForce, IbTradingHours, IbTriggerMethod,
22 IbTwapStrategyType, IbVolatilityType,
23};
24
25#[pymethods]
26#[pyo3_stub_gen::derive::gen_stub_pymethods]
27impl IbAction {
28 #[pyo3(name = "as_str")]
29 fn py_as_str(&self) -> String {
30 self.to_string()
31 }
32}
33
34#[pymethods]
35#[pyo3_stub_gen::derive::gen_stub_pymethods]
36impl IbOrderStatus {
37 #[pyo3(name = "as_str")]
38 fn py_as_str(&self) -> String {
39 self.to_string()
40 }
41}
42
43#[pymethods]
44#[pyo3_stub_gen::derive::gen_stub_pymethods]
45impl IbOrderType {
46 #[pyo3(name = "as_str")]
47 fn py_as_str(&self) -> &'static str {
48 self.as_str()
49 }
50}
51
52#[pymethods]
53#[pyo3_stub_gen::derive::gen_stub_pymethods]
54impl IbTimeInForce {
55 #[pyo3(name = "as_str")]
56 fn py_as_str(&self) -> String {
57 self.to_string()
58 }
59}
60
61#[pymethods]
62#[pyo3_stub_gen::derive::gen_stub_pymethods]
63impl IbBuilderTimeInForce {
64 #[pyo3(name = "as_str")]
65 fn py_as_str(&self) -> &'static str {
66 self.as_str()
67 }
68}
69
70#[pymethods]
71#[pyo3_stub_gen::derive::gen_stub_pymethods]
72impl IbSecurityType {
73 #[pyo3(name = "as_str")]
74 fn py_as_str(&self) -> &'static str {
75 self.as_str()
76 }
77}
78
79#[pymethods]
80#[pyo3_stub_gen::derive::gen_stub_pymethods]
81impl IbOptionRight {
82 #[pyo3(name = "as_str")]
83 fn py_as_str(&self) -> &'static str {
84 self.as_str()
85 }
86}
87
88#[pymethods]
89#[pyo3_stub_gen::derive::gen_stub_pymethods]
90impl IbHistoricalTickType {
91 #[pyo3(name = "as_str")]
92 fn py_as_str(&self) -> &'static str {
93 self.as_str()
94 }
95}
96
97#[pymethods]
98#[pyo3_stub_gen::derive::gen_stub_pymethods]
99impl IbTradingHours {
100 #[pyo3(name = "use_rth")]
101 fn py_use_rth(&self) -> bool {
102 self.use_rth()
103 }
104}
105
106#[pymethods]
107#[pyo3_stub_gen::derive::gen_stub_pymethods]
108impl IbHistoricalBarSize {
109 #[pyo3(name = "as_str")]
110 fn py_as_str(&self) -> String {
111 self.to_string()
112 }
113}
114
115#[pymethods]
116#[pyo3_stub_gen::derive::gen_stub_pymethods]
117impl IbHistoricalWhatToShow {
118 #[pyo3(name = "as_str")]
119 fn py_as_str(&self) -> &'static str {
120 self.as_str()
121 }
122}
123
124#[pymethods]
125#[pyo3_stub_gen::derive::gen_stub_pymethods]
126impl IbRealtimeBarSize {
127 #[pyo3(name = "as_str")]
128 fn py_as_str(&self) -> String {
129 self.to_string()
130 }
131}
132
133#[pymethods]
134#[pyo3_stub_gen::derive::gen_stub_pymethods]
135impl IbRealtimeWhatToShow {
136 #[pyo3(name = "as_str")]
137 fn py_as_str(&self) -> &'static str {
138 self.as_str()
139 }
140}
141
142#[pymethods]
143#[pyo3_stub_gen::derive::gen_stub_pymethods]
144impl IbConditionKind {
145 #[pyo3(name = "as_str")]
146 fn py_as_str(&self) -> &'static str {
147 self.as_str()
148 }
149}
150
151#[pymethods]
152#[pyo3_stub_gen::derive::gen_stub_pymethods]
153impl IbConditionConjunction {
154 #[pyo3(name = "as_str")]
155 fn py_as_str(&self) -> &'static str {
156 self.as_str()
157 }
158
159 #[pyo3(name = "is_conjunction")]
160 fn py_is_conjunction(&self) -> bool {
161 self.is_conjunction()
162 }
163}
164
165#[pymethods]
166#[pyo3_stub_gen::derive::gen_stub_pymethods]
167impl IbComboLegOpenClose {
168 #[pyo3(name = "as_i32")]
169 fn py_as_i32(&self) -> i32 {
170 self.as_i32()
171 }
172}
173
174#[pymethods]
175#[pyo3_stub_gen::derive::gen_stub_pymethods]
176impl IbTriggerMethod {
177 #[pyo3(name = "as_i32")]
178 fn py_as_i32(&self) -> i32 {
179 self.as_i32()
180 }
181}
182
183#[pymethods]
184#[pyo3_stub_gen::derive::gen_stub_pymethods]
185impl IbOcaType {
186 #[pyo3(name = "as_i32")]
187 fn py_as_i32(&self) -> i32 {
188 self.as_i32()
189 }
190}
191
192#[pymethods]
193#[pyo3_stub_gen::derive::gen_stub_pymethods]
194impl IbLiquidity {
195 #[pyo3(name = "as_i32")]
196 fn py_as_i32(&self) -> i32 {
197 self.as_i32()
198 }
199}
200
201macro_rules! py_i32_enum {
202 ($ty:ty) => {
203 #[pymethods]
204 #[pyo3_stub_gen::derive::gen_stub_pymethods]
205 impl $ty {
206 #[pyo3(name = "as_i32")]
207 fn py_as_i32(&self) -> i32 {
208 self.as_i32()
209 }
210 }
211 };
212}
213
214macro_rules! py_str_enum {
215 ($ty:ty) => {
216 #[pymethods]
217 #[pyo3_stub_gen::derive::gen_stub_pymethods]
218 impl $ty {
219 #[pyo3(name = "as_str")]
220 fn py_as_str(&self) -> String {
221 self.to_string()
222 }
223 }
224 };
225}
226
227py_i32_enum!(IbTickType);
228
229py_i32_enum!(IbOrderOrigin);
230py_i32_enum!(IbShortSaleSlot);
231py_i32_enum!(IbVolatilityType);
232py_i32_enum!(IbReferencePriceType);
233py_i32_enum!(IbAuctionStrategy);
234py_i32_enum!(IbExerciseAction);
235py_i32_enum!(IbArticleType);
236py_i32_enum!(IbAuctionType);
237
238py_str_enum!(IbRule80A);
239py_str_enum!(IbOrderOpenClose);
240py_str_enum!(IbTwapStrategyType);
241py_str_enum!(IbRiskAversion);
242py_str_enum!(IbLegAction);
243py_str_enum!(IbFundDistributionPolicyIndicator);
244py_str_enum!(IbFundAssetType);
245py_str_enum!(IbBondIdentifierKind);