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