ib 3.0.0

A Rust client to the Interactive Brokers HTTP REST API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
/* 
 * Client Portal Web API
 *
 * Client Poral Web API
 *
 * OpenAPI spec version: 1.0.0
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */

/// Order : contains all the order related info

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct Order {
  /// account id
  #[serde(rename = "acct")]
  acct: Option<String>,
  /// back-ground color
  #[serde(rename = "bgColor")]
  bg_color: Option<String>,
  #[serde(rename = "companyName")]
  company_name: Option<String>,
  #[serde(rename = "conid")]
  conid: Option<i32>,
  #[serde(rename = "description1")]
  description1: Option<String>,
  #[serde(rename = "fgColor")]
  fg_color: Option<String>,
  #[serde(rename = "filledQuantity")]
  filled_quantity: Option<String>,
  /// for example NASDAQ.NMS
  #[serde(rename = "listingExchange")]
  listing_exchange: Option<String>,
  #[serde(rename = "orderDesc")]
  order_desc: Option<String>,
  #[serde(rename = "orderId")]
  order_id: Option<i32>,
  /// User defined string used to identify the order. Value is set using \"cOID\" field while placing an order.
  #[serde(rename = "order_ref")]
  order_ref: Option<String>,
  /// for example Limit
  #[serde(rename = "origOrderType")]
  orig_order_type: Option<String>,
  /// Only exists in child order of bracket
  #[serde(rename = "parentId")]
  parent_id: Option<i32>,
  #[serde(rename = "price")]
  price: Option<f32>,
  #[serde(rename = "remainingQuantity")]
  remaining_quantity: Option<String>,
  /// for example STK
  #[serde(rename = "secType")]
  sec_type: Option<String>,
  /// BUY or SELL
  #[serde(rename = "side")]
  side: Option<String>,
  /// * PendingSubmit - Indicates the order was sent, but confirmation has not been received that it has been received by the destination.                   Occurs most commonly if an exchange is closed. * PendingCancel - Indicates that a request has been sent to cancel an order but confirmation has not been received of its cancellation. * PreSubmitted - Indicates that a simulated order type has been accepted by the IBKR system and that this order has yet to be elected.                  The order is held in the IBKR system until the election criteria are met. At that time the order is transmitted to the order destination as specified. * Submitted - Indicates that the order has been accepted at the order destination and is working. * Cancelled - Indicates that the balance of the order has been confirmed cancelled by the IB system.               This could occur unexpectedly when IB or the destination has rejected the order. * Filled - Indicates that the order has been completely filled. * Inactive - Indicates the order is not working, for instance if the order was invalid and triggered an error message,              or if the order was to short a security and shares have not yet been located. 
  #[serde(rename = "status")]
  status: Option<String>,
  /// for example FB
  #[serde(rename = "ticker")]
  ticker: Option<String>
}

impl Order {
  /// contains all the order related info
  pub fn new() -> Order {
    Order {
      acct: None,
      bg_color: None,
      company_name: None,
      conid: None,
      description1: None,
      fg_color: None,
      filled_quantity: None,
      listing_exchange: None,
      order_desc: None,
      order_id: None,
      order_ref: None,
      orig_order_type: None,
      parent_id: None,
      price: None,
      remaining_quantity: None,
      sec_type: None,
      side: None,
      status: None,
      ticker: None
    }
  }

  pub fn set_acct(&mut self, acct: String) {
    self.acct = Some(acct);
  }

  pub fn with_acct(mut self, acct: String) -> Order {
    self.acct = Some(acct);
    self
  }

  pub fn acct(&self) -> Option<&String> {
    self.acct.as_ref()
  }

  pub fn reset_acct(&mut self) {
    self.acct = None;
  }

  pub fn set_bg_color(&mut self, bg_color: String) {
    self.bg_color = Some(bg_color);
  }

  pub fn with_bg_color(mut self, bg_color: String) -> Order {
    self.bg_color = Some(bg_color);
    self
  }

  pub fn bg_color(&self) -> Option<&String> {
    self.bg_color.as_ref()
  }

  pub fn reset_bg_color(&mut self) {
    self.bg_color = None;
  }

  pub fn set_company_name(&mut self, company_name: String) {
    self.company_name = Some(company_name);
  }

  pub fn with_company_name(mut self, company_name: String) -> Order {
    self.company_name = Some(company_name);
    self
  }

  pub fn company_name(&self) -> Option<&String> {
    self.company_name.as_ref()
  }

  pub fn reset_company_name(&mut self) {
    self.company_name = None;
  }

  pub fn set_conid(&mut self, conid: i32) {
    self.conid = Some(conid);
  }

  pub fn with_conid(mut self, conid: i32) -> Order {
    self.conid = Some(conid);
    self
  }

  pub fn conid(&self) -> Option<&i32> {
    self.conid.as_ref()
  }

  pub fn reset_conid(&mut self) {
    self.conid = None;
  }

  pub fn set_description1(&mut self, description1: String) {
    self.description1 = Some(description1);
  }

  pub fn with_description1(mut self, description1: String) -> Order {
    self.description1 = Some(description1);
    self
  }

  pub fn description1(&self) -> Option<&String> {
    self.description1.as_ref()
  }

  pub fn reset_description1(&mut self) {
    self.description1 = None;
  }

  pub fn set_fg_color(&mut self, fg_color: String) {
    self.fg_color = Some(fg_color);
  }

  pub fn with_fg_color(mut self, fg_color: String) -> Order {
    self.fg_color = Some(fg_color);
    self
  }

  pub fn fg_color(&self) -> Option<&String> {
    self.fg_color.as_ref()
  }

  pub fn reset_fg_color(&mut self) {
    self.fg_color = None;
  }

  pub fn set_filled_quantity(&mut self, filled_quantity: String) {
    self.filled_quantity = Some(filled_quantity);
  }

  pub fn with_filled_quantity(mut self, filled_quantity: String) -> Order {
    self.filled_quantity = Some(filled_quantity);
    self
  }

  pub fn filled_quantity(&self) -> Option<&String> {
    self.filled_quantity.as_ref()
  }

  pub fn reset_filled_quantity(&mut self) {
    self.filled_quantity = None;
  }

  pub fn set_listing_exchange(&mut self, listing_exchange: String) {
    self.listing_exchange = Some(listing_exchange);
  }

  pub fn with_listing_exchange(mut self, listing_exchange: String) -> Order {
    self.listing_exchange = Some(listing_exchange);
    self
  }

  pub fn listing_exchange(&self) -> Option<&String> {
    self.listing_exchange.as_ref()
  }

  pub fn reset_listing_exchange(&mut self) {
    self.listing_exchange = None;
  }

  pub fn set_order_desc(&mut self, order_desc: String) {
    self.order_desc = Some(order_desc);
  }

  pub fn with_order_desc(mut self, order_desc: String) -> Order {
    self.order_desc = Some(order_desc);
    self
  }

  pub fn order_desc(&self) -> Option<&String> {
    self.order_desc.as_ref()
  }

  pub fn reset_order_desc(&mut self) {
    self.order_desc = None;
  }

  pub fn set_order_id(&mut self, order_id: i32) {
    self.order_id = Some(order_id);
  }

  pub fn with_order_id(mut self, order_id: i32) -> Order {
    self.order_id = Some(order_id);
    self
  }

  pub fn order_id(&self) -> Option<&i32> {
    self.order_id.as_ref()
  }

  pub fn reset_order_id(&mut self) {
    self.order_id = None;
  }

  pub fn set_order_ref(&mut self, order_ref: String) {
    self.order_ref = Some(order_ref);
  }

  pub fn with_order_ref(mut self, order_ref: String) -> Order {
    self.order_ref = Some(order_ref);
    self
  }

  pub fn order_ref(&self) -> Option<&String> {
    self.order_ref.as_ref()
  }

  pub fn reset_order_ref(&mut self) {
    self.order_ref = None;
  }

  pub fn set_orig_order_type(&mut self, orig_order_type: String) {
    self.orig_order_type = Some(orig_order_type);
  }

  pub fn with_orig_order_type(mut self, orig_order_type: String) -> Order {
    self.orig_order_type = Some(orig_order_type);
    self
  }

  pub fn orig_order_type(&self) -> Option<&String> {
    self.orig_order_type.as_ref()
  }

  pub fn reset_orig_order_type(&mut self) {
    self.orig_order_type = None;
  }

  pub fn set_parent_id(&mut self, parent_id: i32) {
    self.parent_id = Some(parent_id);
  }

  pub fn with_parent_id(mut self, parent_id: i32) -> Order {
    self.parent_id = Some(parent_id);
    self
  }

  pub fn parent_id(&self) -> Option<&i32> {
    self.parent_id.as_ref()
  }

  pub fn reset_parent_id(&mut self) {
    self.parent_id = None;
  }

  pub fn set_price(&mut self, price: f32) {
    self.price = Some(price);
  }

  pub fn with_price(mut self, price: f32) -> Order {
    self.price = Some(price);
    self
  }

  pub fn price(&self) -> Option<&f32> {
    self.price.as_ref()
  }

  pub fn reset_price(&mut self) {
    self.price = None;
  }

  pub fn set_remaining_quantity(&mut self, remaining_quantity: String) {
    self.remaining_quantity = Some(remaining_quantity);
  }

  pub fn with_remaining_quantity(mut self, remaining_quantity: String) -> Order {
    self.remaining_quantity = Some(remaining_quantity);
    self
  }

  pub fn remaining_quantity(&self) -> Option<&String> {
    self.remaining_quantity.as_ref()
  }

  pub fn reset_remaining_quantity(&mut self) {
    self.remaining_quantity = None;
  }

  pub fn set_sec_type(&mut self, sec_type: String) {
    self.sec_type = Some(sec_type);
  }

  pub fn with_sec_type(mut self, sec_type: String) -> Order {
    self.sec_type = Some(sec_type);
    self
  }

  pub fn sec_type(&self) -> Option<&String> {
    self.sec_type.as_ref()
  }

  pub fn reset_sec_type(&mut self) {
    self.sec_type = None;
  }

  pub fn set_side(&mut self, side: String) {
    self.side = Some(side);
  }

  pub fn with_side(mut self, side: String) -> Order {
    self.side = Some(side);
    self
  }

  pub fn side(&self) -> Option<&String> {
    self.side.as_ref()
  }

  pub fn reset_side(&mut self) {
    self.side = None;
  }

  pub fn set_status(&mut self, status: String) {
    self.status = Some(status);
  }

  pub fn with_status(mut self, status: String) -> Order {
    self.status = Some(status);
    self
  }

  pub fn status(&self) -> Option<&String> {
    self.status.as_ref()
  }

  pub fn reset_status(&mut self) {
    self.status = None;
  }

  pub fn set_ticker(&mut self, ticker: String) {
    self.ticker = Some(ticker);
  }

  pub fn with_ticker(mut self, ticker: String) -> Order {
    self.ticker = Some(ticker);
    self
  }

  pub fn ticker(&self) -> Option<&String> {
    self.ticker.as_ref()
  }

  pub fn reset_ticker(&mut self) {
    self.ticker = None;
  }

}