1#![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
18pub struct OrderCancelRequest {
20 pub message: Message,
21}
22
23impl OrderCancelRequest {
24 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 pub fn from_message(msg: Message) -> Self {
42 Self { message: msg }
43 }
44
45 pub fn to_message(self) -> Message {
47 self.message
48 }
49
50
51
52
53 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 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 pub fn has_cash_order_qty(&self) -> bool {
68 self.message.body.has(tag::CASH_ORDER_QTY)
69 }
70
71
72
73
74 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 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 pub fn has_cl_ord_id(&self) -> bool {
89 self.message.body.has(tag::CL_ORD_ID)
90 }
91
92
93
94
95 pub fn set_client_id(&mut self, v: String) {
97 self.message.body.set_field(tag::CLIENT_ID, FIXString::from(v));
98 }
99
100 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 pub fn has_client_id(&self) -> bool {
110 self.message.body.has(tag::CLIENT_ID)
111 }
112
113
114
115
116 pub fn set_exec_broker(&mut self, v: String) {
118 self.message.body.set_field(tag::EXEC_BROKER, FIXString::from(v));
119 }
120
121 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 pub fn has_exec_broker(&self) -> bool {
131 self.message.body.has(tag::EXEC_BROKER)
132 }
133
134
135
136
137 pub fn set_id_source(&mut self, v: String) {
139 self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
140 }
141
142 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 pub fn has_id_source(&self) -> bool {
152 self.message.body.has(tag::ID_SOURCE)
153 }
154
155
156
157
158 pub fn set_issuer(&mut self, v: String) {
160 self.message.body.set_field(tag::ISSUER, FIXString::from(v));
161 }
162
163 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 pub fn has_issuer(&self) -> bool {
173 self.message.body.has(tag::ISSUER)
174 }
175
176
177
178
179 pub fn set_list_id(&mut self, v: String) {
181 self.message.body.set_field(tag::LIST_ID, FIXString::from(v));
182 }
183
184 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 pub fn has_list_id(&self) -> bool {
194 self.message.body.has(tag::LIST_ID)
195 }
196
197
198
199
200 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 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 pub fn has_maturity_day(&self) -> bool {
215 self.message.body.has(tag::MATURITY_DAY)
216 }
217
218
219
220
221 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 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 pub fn has_maturity_month_year(&self) -> bool {
236 self.message.body.has(tag::MATURITY_MONTH_YEAR)
237 }
238
239
240
241
242 pub fn set_opt_attribute(&mut self, v: String) {
244 self.message.body.set_field(tag::OPT_ATTRIBUTE, FIXString::from(v));
245 }
246
247 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 pub fn has_opt_attribute(&self) -> bool {
257 self.message.body.has(tag::OPT_ATTRIBUTE)
258 }
259
260
261
262
263 pub fn set_order_id(&mut self, v: String) {
265 self.message.body.set_field(tag::ORDER_ID, FIXString::from(v));
266 }
267
268 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 pub fn has_order_id(&self) -> bool {
278 self.message.body.has(tag::ORDER_ID)
279 }
280
281
282
283
284 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 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 pub fn has_order_qty(&self) -> bool {
299 self.message.body.has(tag::ORDER_QTY)
300 }
301
302
303
304
305 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 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 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 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 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 pub fn has_put_or_call(&self) -> bool {
341 self.message.body.has(tag::PUT_OR_CALL)
342 }
343
344
345
346
347 pub fn set_security_desc(&mut self, v: String) {
349 self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
350 }
351
352 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 pub fn has_security_desc(&self) -> bool {
362 self.message.body.has(tag::SECURITY_DESC)
363 }
364
365
366
367
368 pub fn set_security_exchange(&mut self, v: String) {
370 self.message.body.set_field(tag::SECURITY_EXCHANGE, FIXString::from(v));
371 }
372
373 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 pub fn has_security_exchange(&self) -> bool {
383 self.message.body.has(tag::SECURITY_EXCHANGE)
384 }
385
386
387
388
389 pub fn set_security_id(&mut self, v: String) {
391 self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
392 }
393
394 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 pub fn has_security_id(&self) -> bool {
404 self.message.body.has(tag::SECURITY_ID)
405 }
406
407
408
409
410 pub fn set_security_type(&mut self, v: String) {
412 self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
413 }
414
415 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 pub fn has_security_type(&self) -> bool {
425 self.message.body.has(tag::SECURITY_TYPE)
426 }
427
428
429
430
431 pub fn set_side(&mut self, v: String) {
433 self.message.body.set_field(tag::SIDE, FIXString::from(v));
434 }
435
436 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 pub fn has_side(&self) -> bool {
446 self.message.body.has(tag::SIDE)
447 }
448
449
450
451
452 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 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 pub fn has_strike_price(&self) -> bool {
467 self.message.body.has(tag::STRIKE_PRICE)
468 }
469
470
471
472
473 pub fn set_symbol(&mut self, v: String) {
475 self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
476 }
477
478 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 pub fn has_symbol(&self) -> bool {
488 self.message.body.has(tag::SYMBOL)
489 }
490
491
492
493
494 pub fn set_symbol_sfx(&mut self, v: String) {
496 self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
497 }
498
499 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 pub fn has_symbol_sfx(&self) -> bool {
509 self.message.body.has(tag::SYMBOL_SFX)
510 }
511
512
513
514
515 pub fn set_text(&mut self, v: String) {
517 self.message.body.set_field(tag::TEXT, FIXString::from(v));
518 }
519
520 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 pub fn has_text(&self) -> bool {
530 self.message.body.has(tag::TEXT)
531 }
532
533
534}
535
536pub type RouteOut = fn(msg: OrderCancelRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
538
539pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
541
542pub 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}