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
/* 
 * Client Portal Web API
 *
 * Production version of the Client Portal Web API
 *
 * OpenAPI spec version: 1.0.0
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */


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

#[derive(Debug, Serialize, Deserialize)]
pub struct OrderRequest {
  /// acctId is optional. It should be one of the accounts returned by /iserver/accounts. If not passed, the first one in the list is selected. 
  #[serde(rename = "acctId")]
  acct_id: Option<String>,
  /// conid is the identifier of the security you want to trade, you can find the conid with /iserver/secdef/search. 
  #[serde(rename = "conid")]
  conid: Option<i32>,
  /// conid:type for example 265598:STK
  #[serde(rename = "secType")]
  sec_type: Option<String>,
  /// cOID: Is the customer identifier. Can be some arbitrary string. e.g \"my-fb-order\". 
  #[serde(rename = "cOID")]
  c_oid: Option<String>,
  /// orderType can be one of MKT (Market), LMT (Limit), STP (Stop) or STP_LIMIT (stop limit) 
  #[serde(rename = "orderType")]
  order_type: Option<String>,
  /// listingExchange is optional. By default we use \"SMART\" routing. Possible values are available via this end point: /v1/portal/iserver/contract/{{conid}}/info, see valid_exchange: e.g: SMART,AMEX,NYSE, CBOE,ISE,CHX,ARCA,ISLAND,DRCTEDGE,BEX,BATS,EDGEA,CSFBALGO,JE FFALGO,BYX,IEX,FOXRIVER,TPLUS1,NYSENAT,PSX 
  #[serde(rename = "listingExchange")]
  listing_exchange: Option<String>,
  /// set to true if the order can be executed outside regular trading hours. 
  #[serde(rename = "outsideRTH")]
  outside_rth: Option<bool>,
  /// optional if order is MKT, for LMT, this is the limit price. For STP this is the stop price. 
  #[serde(rename = "price")]
  price: Option<f32>,
  /// SELL or BUY
  #[serde(rename = "side")]
  side: Option<String>,
  /// 
  #[serde(rename = "ticker")]
  ticker: Option<String>,
  /// GTC (Good Till Cancel) or DAY. DAY orders are automatically cancelled at the end of the Day or Trading hours. 
  #[serde(rename = "tif")]
  tif: Option<String>,
  /// for example QuickTrade
  #[serde(rename = "referrer")]
  referrer: Option<String>,
  /// usually integer, for some special cases can be float numbers
  #[serde(rename = "quantity")]
  quantity: Option<f32>
}

impl OrderRequest {
  pub fn new() -> OrderRequest {
    OrderRequest {
      acct_id: None,
      conid: None,
      sec_type: None,
      c_oid: None,
      order_type: None,
      listing_exchange: None,
      outside_rth: None,
      price: None,
      side: None,
      ticker: None,
      tif: None,
      referrer: None,
      quantity: None
    }
  }

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

  pub fn with_acct_id(mut self, acct_id: String) -> OrderRequest {
    self.acct_id = Some(acct_id);
    self
  }

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

  pub fn reset_acct_id(&mut self) {
    self.acct_id = None;
  }

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

  pub fn with_conid(mut self, conid: i32) -> OrderRequest {
    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_sec_type(&mut self, sec_type: String) {
    self.sec_type = Some(sec_type);
  }

  pub fn with_sec_type(mut self, sec_type: String) -> OrderRequest {
    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_c_oid(&mut self, c_oid: String) {
    self.c_oid = Some(c_oid);
  }

  pub fn with_c_oid(mut self, c_oid: String) -> OrderRequest {
    self.c_oid = Some(c_oid);
    self
  }

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

  pub fn reset_c_oid(&mut self) {
    self.c_oid = None;
  }

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

  pub fn with_order_type(mut self, order_type: String) -> OrderRequest {
    self.order_type = Some(order_type);
    self
  }

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

  pub fn reset_order_type(&mut self) {
    self.order_type = 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) -> OrderRequest {
    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_outside_rth(&mut self, outside_rth: bool) {
    self.outside_rth = Some(outside_rth);
  }

  pub fn with_outside_rth(mut self, outside_rth: bool) -> OrderRequest {
    self.outside_rth = Some(outside_rth);
    self
  }

  pub fn outside_rth(&self) -> Option<&bool> {
    self.outside_rth.as_ref()
  }

  pub fn reset_outside_rth(&mut self) {
    self.outside_rth = None;
  }

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

  pub fn with_price(mut self, price: f32) -> OrderRequest {
    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_side(&mut self, side: String) {
    self.side = Some(side);
  }

  pub fn with_side(mut self, side: String) -> OrderRequest {
    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_ticker(&mut self, ticker: String) {
    self.ticker = Some(ticker);
  }

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

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

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

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

  pub fn with_tif(mut self, tif: String) -> OrderRequest {
    self.tif = Some(tif);
    self
  }

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

  pub fn reset_tif(&mut self) {
    self.tif = None;
  }

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

  pub fn with_referrer(mut self, referrer: String) -> OrderRequest {
    self.referrer = Some(referrer);
    self
  }

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

  pub fn reset_referrer(&mut self) {
    self.referrer = None;
  }

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

  pub fn with_quantity(mut self, quantity: f32) -> OrderRequest {
    self.quantity = Some(quantity);
    self
  }

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

  pub fn reset_quantity(&mut self) {
    self.quantity = None;
  }

}