Skip to main content

fixer_fix/fix41/
order_cancel_request.rs

1// Code generated by fixer-gen. DO NOT EDIT.
2#![allow(clippy::new_without_default)]
3#![allow(clippy::needless_pass_by_value)]
4#![allow(clippy::too_many_arguments)]
5#![allow(unused_imports)]
6
7use fixer::message::Message;
8use fixer::fix_string::FIXString;
9use fixer::errors::MessageRejectErrorEnum;
10use fixer::session::session_id::SessionID;
11
12use rust_decimal::Decimal;
13
14
15use crate::field;
16use crate::tag;
17
18/// `OrderCancelRequest` is the `fix41` `OrderCancelRequest` type, `MsgType` = F.
19pub struct OrderCancelRequest {
20    pub message: Message,
21}
22
23impl OrderCancelRequest {
24    /// Creates a new `OrderCancelRequest` with required fields.
25    pub fn new(orig_cl_ord_id: field::OrigClOrdIDField, cl_ord_id: field::ClOrdIDField, symbol: field::SymbolField, side: field::SideField) -> Self {
26        let mut msg = Message::new();
27        msg.header.set_field(tag::MSG_TYPE, FIXString::from("F".to_string()));
28
29        msg.body.set_field(tag::ORIG_CL_ORD_ID, orig_cl_ord_id.0);
30
31        msg.body.set_field(tag::CL_ORD_ID, cl_ord_id.0);
32
33        msg.body.set_field(tag::SYMBOL, symbol.0);
34
35        msg.body.set_field(tag::SIDE, side.0);
36
37        Self { message: msg }
38    }
39
40    /// Creates a `OrderCancelRequest` from an existing `Message`.
41    pub fn from_message(msg: Message) -> Self {
42        Self { message: msg }
43    }
44
45    /// Returns the underlying `Message`.
46    pub fn to_message(self) -> Message {
47        self.message
48    }
49
50
51
52
53    /// Sets `CashOrderQty`, Tag 152.
54    pub fn set_cash_order_qty(&mut self, val: Decimal, scale: i32) {
55        self.message.body.set_field(tag::CASH_ORDER_QTY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
56    }
57
58    /// Gets `CashOrderQty`, Tag 152.
59    pub fn get_cash_order_qty(&self) -> Result<Decimal, MessageRejectErrorEnum> {
60        let mut fld = field::CashOrderQtyField::new(Decimal::ZERO, 0);
61        self.message.body.get_field(tag::CASH_ORDER_QTY, &mut fld.0)?;
62        Ok(fld.value())
63    }
64
65
66    /// Returns true if `CashOrderQty` is present, Tag 152.
67    pub fn has_cash_order_qty(&self) -> bool {
68        self.message.body.has(tag::CASH_ORDER_QTY)
69    }
70
71
72
73
74    /// Sets `ClOrdID`, Tag 11.
75    pub fn set_cl_ord_id(&mut self, v: String) {
76        self.message.body.set_field(tag::CL_ORD_ID, FIXString::from(v));
77    }
78
79    /// Gets `ClOrdID`, Tag 11.
80    pub fn get_cl_ord_id(&self) -> Result<String, MessageRejectErrorEnum> {
81        let mut fld = field::ClOrdIDField::new(String::new());
82        self.message.body.get_field(tag::CL_ORD_ID, &mut fld.0)?;
83        Ok(fld.value().to_string())
84    }
85
86
87    /// Returns true if `ClOrdID` is present, Tag 11.
88    pub fn has_cl_ord_id(&self) -> bool {
89        self.message.body.has(tag::CL_ORD_ID)
90    }
91
92
93
94
95    /// Sets `ClientID`, Tag 109.
96    pub fn set_client_id(&mut self, v: String) {
97        self.message.body.set_field(tag::CLIENT_ID, FIXString::from(v));
98    }
99
100    /// Gets `ClientID`, Tag 109.
101    pub fn get_client_id(&self) -> Result<String, MessageRejectErrorEnum> {
102        let mut fld = field::ClientIDField::new(String::new());
103        self.message.body.get_field(tag::CLIENT_ID, &mut fld.0)?;
104        Ok(fld.value().to_string())
105    }
106
107
108    /// Returns true if `ClientID` is present, Tag 109.
109    pub fn has_client_id(&self) -> bool {
110        self.message.body.has(tag::CLIENT_ID)
111    }
112
113
114
115
116    /// Sets `ExecBroker`, Tag 76.
117    pub fn set_exec_broker(&mut self, v: String) {
118        self.message.body.set_field(tag::EXEC_BROKER, FIXString::from(v));
119    }
120
121    /// Gets `ExecBroker`, Tag 76.
122    pub fn get_exec_broker(&self) -> Result<String, MessageRejectErrorEnum> {
123        let mut fld = field::ExecBrokerField::new(String::new());
124        self.message.body.get_field(tag::EXEC_BROKER, &mut fld.0)?;
125        Ok(fld.value().to_string())
126    }
127
128
129    /// Returns true if `ExecBroker` is present, Tag 76.
130    pub fn has_exec_broker(&self) -> bool {
131        self.message.body.has(tag::EXEC_BROKER)
132    }
133
134
135
136
137    /// Sets `IDSource`, Tag 22.
138    pub fn set_id_source(&mut self, v: String) {
139        self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
140    }
141
142    /// Gets `IDSource`, Tag 22.
143    pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
144        let mut fld = field::IDSourceField::new(String::new());
145        self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
146        Ok(fld.value().to_string())
147    }
148
149
150    /// Returns true if `IDSource` is present, Tag 22.
151    pub fn has_id_source(&self) -> bool {
152        self.message.body.has(tag::ID_SOURCE)
153    }
154
155
156
157
158    /// Sets `Issuer`, Tag 106.
159    pub fn set_issuer(&mut self, v: String) {
160        self.message.body.set_field(tag::ISSUER, FIXString::from(v));
161    }
162
163    /// Gets `Issuer`, Tag 106.
164    pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
165        let mut fld = field::IssuerField::new(String::new());
166        self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
167        Ok(fld.value().to_string())
168    }
169
170
171    /// Returns true if `Issuer` is present, Tag 106.
172    pub fn has_issuer(&self) -> bool {
173        self.message.body.has(tag::ISSUER)
174    }
175
176
177
178
179    /// Sets `ListID`, Tag 66.
180    pub fn set_list_id(&mut self, v: String) {
181        self.message.body.set_field(tag::LIST_ID, FIXString::from(v));
182    }
183
184    /// Gets `ListID`, Tag 66.
185    pub fn get_list_id(&self) -> Result<String, MessageRejectErrorEnum> {
186        let mut fld = field::ListIDField::new(String::new());
187        self.message.body.get_field(tag::LIST_ID, &mut fld.0)?;
188        Ok(fld.value().to_string())
189    }
190
191
192    /// Returns true if `ListID` is present, Tag 66.
193    pub fn has_list_id(&self) -> bool {
194        self.message.body.has(tag::LIST_ID)
195    }
196
197
198
199
200    /// Sets `MaturityDay`, Tag 205.
201    pub fn set_maturity_day(&mut self, v: isize) {
202        self.message.body.set_field(tag::MATURITY_DAY, fixer::fix_int::FIXInt::from(v));
203    }
204
205    /// Gets `MaturityDay`, Tag 205.
206    pub fn get_maturity_day(&self) -> Result<isize, MessageRejectErrorEnum> {
207        let mut fld = field::MaturityDayField::new(0);
208        self.message.body.get_field(tag::MATURITY_DAY, &mut fld.0)?;
209        Ok(fld.value())
210    }
211
212
213    /// Returns true if `MaturityDay` is present, Tag 205.
214    pub fn has_maturity_day(&self) -> bool {
215        self.message.body.has(tag::MATURITY_DAY)
216    }
217
218
219
220
221    /// Sets `MaturityMonthYear`, Tag 200.
222    pub fn set_maturity_month_year(&mut self, v: String) {
223        self.message.body.set_field(tag::MATURITY_MONTH_YEAR, FIXString::from(v));
224    }
225
226    /// Gets `MaturityMonthYear`, Tag 200.
227    pub fn get_maturity_month_year(&self) -> Result<String, MessageRejectErrorEnum> {
228        let mut fld = field::MaturityMonthYearField::new(String::new());
229        self.message.body.get_field(tag::MATURITY_MONTH_YEAR, &mut fld.0)?;
230        Ok(fld.value().to_string())
231    }
232
233
234    /// Returns true if `MaturityMonthYear` is present, Tag 200.
235    pub fn has_maturity_month_year(&self) -> bool {
236        self.message.body.has(tag::MATURITY_MONTH_YEAR)
237    }
238
239
240
241
242    /// Sets `OptAttribute`, Tag 206.
243    pub fn set_opt_attribute(&mut self, v: String) {
244        self.message.body.set_field(tag::OPT_ATTRIBUTE, FIXString::from(v));
245    }
246
247    /// Gets `OptAttribute`, Tag 206.
248    pub fn get_opt_attribute(&self) -> Result<String, MessageRejectErrorEnum> {
249        let mut fld = field::OptAttributeField::new(String::new());
250        self.message.body.get_field(tag::OPT_ATTRIBUTE, &mut fld.0)?;
251        Ok(fld.value().to_string())
252    }
253
254
255    /// Returns true if `OptAttribute` is present, Tag 206.
256    pub fn has_opt_attribute(&self) -> bool {
257        self.message.body.has(tag::OPT_ATTRIBUTE)
258    }
259
260
261
262
263    /// Sets `OrderID`, Tag 37.
264    pub fn set_order_id(&mut self, v: String) {
265        self.message.body.set_field(tag::ORDER_ID, FIXString::from(v));
266    }
267
268    /// Gets `OrderID`, Tag 37.
269    pub fn get_order_id(&self) -> Result<String, MessageRejectErrorEnum> {
270        let mut fld = field::OrderIDField::new(String::new());
271        self.message.body.get_field(tag::ORDER_ID, &mut fld.0)?;
272        Ok(fld.value().to_string())
273    }
274
275
276    /// Returns true if `OrderID` is present, Tag 37.
277    pub fn has_order_id(&self) -> bool {
278        self.message.body.has(tag::ORDER_ID)
279    }
280
281
282
283
284    /// Sets `OrderQty`, Tag 38.
285    pub fn set_order_qty(&mut self, val: Decimal, scale: i32) {
286        self.message.body.set_field(tag::ORDER_QTY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
287    }
288
289    /// Gets `OrderQty`, Tag 38.
290    pub fn get_order_qty(&self) -> Result<Decimal, MessageRejectErrorEnum> {
291        let mut fld = field::OrderQtyField::new(Decimal::ZERO, 0);
292        self.message.body.get_field(tag::ORDER_QTY, &mut fld.0)?;
293        Ok(fld.value())
294    }
295
296
297    /// Returns true if `OrderQty` is present, Tag 38.
298    pub fn has_order_qty(&self) -> bool {
299        self.message.body.has(tag::ORDER_QTY)
300    }
301
302
303
304
305    /// Sets `OrigClOrdID`, Tag 41.
306    pub fn set_orig_cl_ord_id(&mut self, v: String) {
307        self.message.body.set_field(tag::ORIG_CL_ORD_ID, FIXString::from(v));
308    }
309
310    /// Gets `OrigClOrdID`, Tag 41.
311    pub fn get_orig_cl_ord_id(&self) -> Result<String, MessageRejectErrorEnum> {
312        let mut fld = field::OrigClOrdIDField::new(String::new());
313        self.message.body.get_field(tag::ORIG_CL_ORD_ID, &mut fld.0)?;
314        Ok(fld.value().to_string())
315    }
316
317
318    /// Returns true if `OrigClOrdID` is present, Tag 41.
319    pub fn has_orig_cl_ord_id(&self) -> bool {
320        self.message.body.has(tag::ORIG_CL_ORD_ID)
321    }
322
323
324
325
326    /// Sets `PutOrCall`, Tag 201.
327    pub fn set_put_or_call(&mut self, v: isize) {
328        self.message.body.set_field(tag::PUT_OR_CALL, fixer::fix_int::FIXInt::from(v));
329    }
330
331    /// Gets `PutOrCall`, Tag 201.
332    pub fn get_put_or_call(&self) -> Result<isize, MessageRejectErrorEnum> {
333        let mut fld = field::PutOrCallField::new(0);
334        self.message.body.get_field(tag::PUT_OR_CALL, &mut fld.0)?;
335        Ok(fld.value())
336    }
337
338
339    /// Returns true if `PutOrCall` is present, Tag 201.
340    pub fn has_put_or_call(&self) -> bool {
341        self.message.body.has(tag::PUT_OR_CALL)
342    }
343
344
345
346
347    /// Sets `SecurityDesc`, Tag 107.
348    pub fn set_security_desc(&mut self, v: String) {
349        self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
350    }
351
352    /// Gets `SecurityDesc`, Tag 107.
353    pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
354        let mut fld = field::SecurityDescField::new(String::new());
355        self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
356        Ok(fld.value().to_string())
357    }
358
359
360    /// Returns true if `SecurityDesc` is present, Tag 107.
361    pub fn has_security_desc(&self) -> bool {
362        self.message.body.has(tag::SECURITY_DESC)
363    }
364
365
366
367
368    /// Sets `SecurityExchange`, Tag 207.
369    pub fn set_security_exchange(&mut self, v: String) {
370        self.message.body.set_field(tag::SECURITY_EXCHANGE, FIXString::from(v));
371    }
372
373    /// Gets `SecurityExchange`, Tag 207.
374    pub fn get_security_exchange(&self) -> Result<String, MessageRejectErrorEnum> {
375        let mut fld = field::SecurityExchangeField::new(String::new());
376        self.message.body.get_field(tag::SECURITY_EXCHANGE, &mut fld.0)?;
377        Ok(fld.value().to_string())
378    }
379
380
381    /// Returns true if `SecurityExchange` is present, Tag 207.
382    pub fn has_security_exchange(&self) -> bool {
383        self.message.body.has(tag::SECURITY_EXCHANGE)
384    }
385
386
387
388
389    /// Sets `SecurityID`, Tag 48.
390    pub fn set_security_id(&mut self, v: String) {
391        self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
392    }
393
394    /// Gets `SecurityID`, Tag 48.
395    pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
396        let mut fld = field::SecurityIDField::new(String::new());
397        self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
398        Ok(fld.value().to_string())
399    }
400
401
402    /// Returns true if `SecurityID` is present, Tag 48.
403    pub fn has_security_id(&self) -> bool {
404        self.message.body.has(tag::SECURITY_ID)
405    }
406
407
408
409
410    /// Sets `SecurityType`, Tag 167.
411    pub fn set_security_type(&mut self, v: String) {
412        self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
413    }
414
415    /// Gets `SecurityType`, Tag 167.
416    pub fn get_security_type(&self) -> Result<String, MessageRejectErrorEnum> {
417        let mut fld = field::SecurityTypeField::new(String::new());
418        self.message.body.get_field(tag::SECURITY_TYPE, &mut fld.0)?;
419        Ok(fld.value().to_string())
420    }
421
422
423    /// Returns true if `SecurityType` is present, Tag 167.
424    pub fn has_security_type(&self) -> bool {
425        self.message.body.has(tag::SECURITY_TYPE)
426    }
427
428
429
430
431    /// Sets `Side`, Tag 54.
432    pub fn set_side(&mut self, v: String) {
433        self.message.body.set_field(tag::SIDE, FIXString::from(v));
434    }
435
436    /// Gets `Side`, Tag 54.
437    pub fn get_side(&self) -> Result<String, MessageRejectErrorEnum> {
438        let mut fld = field::SideField::new(String::new());
439        self.message.body.get_field(tag::SIDE, &mut fld.0)?;
440        Ok(fld.value().to_string())
441    }
442
443
444    /// Returns true if `Side` is present, Tag 54.
445    pub fn has_side(&self) -> bool {
446        self.message.body.has(tag::SIDE)
447    }
448
449
450
451
452    /// Sets `StrikePrice`, Tag 202.
453    pub fn set_strike_price(&mut self, val: Decimal, scale: i32) {
454        self.message.body.set_field(tag::STRIKE_PRICE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
455    }
456
457    /// Gets `StrikePrice`, Tag 202.
458    pub fn get_strike_price(&self) -> Result<Decimal, MessageRejectErrorEnum> {
459        let mut fld = field::StrikePriceField::new(Decimal::ZERO, 0);
460        self.message.body.get_field(tag::STRIKE_PRICE, &mut fld.0)?;
461        Ok(fld.value())
462    }
463
464
465    /// Returns true if `StrikePrice` is present, Tag 202.
466    pub fn has_strike_price(&self) -> bool {
467        self.message.body.has(tag::STRIKE_PRICE)
468    }
469
470
471
472
473    /// Sets `Symbol`, Tag 55.
474    pub fn set_symbol(&mut self, v: String) {
475        self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
476    }
477
478    /// Gets `Symbol`, Tag 55.
479    pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
480        let mut fld = field::SymbolField::new(String::new());
481        self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
482        Ok(fld.value().to_string())
483    }
484
485
486    /// Returns true if `Symbol` is present, Tag 55.
487    pub fn has_symbol(&self) -> bool {
488        self.message.body.has(tag::SYMBOL)
489    }
490
491
492
493
494    /// Sets `SymbolSfx`, Tag 65.
495    pub fn set_symbol_sfx(&mut self, v: String) {
496        self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
497    }
498
499    /// Gets `SymbolSfx`, Tag 65.
500    pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
501        let mut fld = field::SymbolSfxField::new(String::new());
502        self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
503        Ok(fld.value().to_string())
504    }
505
506
507    /// Returns true if `SymbolSfx` is present, Tag 65.
508    pub fn has_symbol_sfx(&self) -> bool {
509        self.message.body.has(tag::SYMBOL_SFX)
510    }
511
512
513
514
515    /// Sets `Text`, Tag 58.
516    pub fn set_text(&mut self, v: String) {
517        self.message.body.set_field(tag::TEXT, FIXString::from(v));
518    }
519
520    /// Gets `Text`, Tag 58.
521    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
522        let mut fld = field::TextField::new(String::new());
523        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
524        Ok(fld.value().to_string())
525    }
526
527
528    /// Returns true if `Text` is present, Tag 58.
529    pub fn has_text(&self) -> bool {
530        self.message.body.has(tag::TEXT)
531    }
532
533
534}
535
536/// `RouteOut` is the callback type for routing `OrderCancelRequest` messages.
537pub type RouteOut = fn(msg: OrderCancelRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
538
539/// Route type returned by the `route` function.
540pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
541
542/// Returns the begin string, message type, and route function for `OrderCancelRequest`.
543pub fn route(router: RouteOut) -> Route {
544    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
545        router(OrderCancelRequest::from_message(msg.clone()), session_id)
546    };
547    ("FIX.4.1", "F", Box::new(r))
548}