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 jiff::Timestamp;
16
17use crate::field;
18use crate::tag;
19
20pub struct OrderCancelReplaceRequest {
22 pub message: Message,
23}
24
25impl OrderCancelReplaceRequest {
26 pub fn new(orig_cl_ord_id: field::OrigClOrdIDField, cl_ord_id: field::ClOrdIDField, handl_inst: field::HandlInstField, symbol: field::SymbolField, side: field::SideField, order_qty: field::OrderQtyField, ord_type: field::OrdTypeField) -> Self {
28 let mut msg = Message::new();
29 msg.header.set_field(tag::MSG_TYPE, FIXString::from("G".to_string()));
30
31 msg.body.set_field(tag::ORIG_CL_ORD_ID, orig_cl_ord_id.0);
32
33 msg.body.set_field(tag::CL_ORD_ID, cl_ord_id.0);
34
35 msg.body.set_field(tag::HANDL_INST, handl_inst.0);
36
37 msg.body.set_field(tag::SYMBOL, symbol.0);
38
39 msg.body.set_field(tag::SIDE, side.0);
40
41 msg.body.set_field(tag::ORDER_QTY, order_qty.0);
42
43 msg.body.set_field(tag::ORD_TYPE, ord_type.0);
44
45 Self { message: msg }
46 }
47
48 pub fn from_message(msg: Message) -> Self {
50 Self { message: msg }
51 }
52
53 pub fn to_message(self) -> Message {
55 self.message
56 }
57
58
59
60
61 pub fn set_account(&mut self, v: String) {
63 self.message.body.set_field(tag::ACCOUNT, FIXString::from(v));
64 }
65
66 pub fn get_account(&self) -> Result<String, MessageRejectErrorEnum> {
68 let mut fld = field::AccountField::new(String::new());
69 self.message.body.get_field(tag::ACCOUNT, &mut fld.0)?;
70 Ok(fld.value().to_string())
71 }
72
73
74 pub fn has_account(&self) -> bool {
76 self.message.body.has(tag::ACCOUNT)
77 }
78
79
80
81
82 pub fn set_cl_ord_id(&mut self, v: String) {
84 self.message.body.set_field(tag::CL_ORD_ID, FIXString::from(v));
85 }
86
87 pub fn get_cl_ord_id(&self) -> Result<String, MessageRejectErrorEnum> {
89 let mut fld = field::ClOrdIDField::new(String::new());
90 self.message.body.get_field(tag::CL_ORD_ID, &mut fld.0)?;
91 Ok(fld.value().to_string())
92 }
93
94
95 pub fn has_cl_ord_id(&self) -> bool {
97 self.message.body.has(tag::CL_ORD_ID)
98 }
99
100
101
102
103 pub fn set_client_id(&mut self, v: String) {
105 self.message.body.set_field(tag::CLIENT_ID, FIXString::from(v));
106 }
107
108 pub fn get_client_id(&self) -> Result<String, MessageRejectErrorEnum> {
110 let mut fld = field::ClientIDField::new(String::new());
111 self.message.body.get_field(tag::CLIENT_ID, &mut fld.0)?;
112 Ok(fld.value().to_string())
113 }
114
115
116 pub fn has_client_id(&self) -> bool {
118 self.message.body.has(tag::CLIENT_ID)
119 }
120
121
122
123
124 pub fn set_comm_type(&mut self, v: String) {
126 self.message.body.set_field(tag::COMM_TYPE, FIXString::from(v));
127 }
128
129 pub fn get_comm_type(&self) -> Result<String, MessageRejectErrorEnum> {
131 let mut fld = field::CommTypeField::new(String::new());
132 self.message.body.get_field(tag::COMM_TYPE, &mut fld.0)?;
133 Ok(fld.value().to_string())
134 }
135
136
137 pub fn has_comm_type(&self) -> bool {
139 self.message.body.has(tag::COMM_TYPE)
140 }
141
142
143
144
145 pub fn set_commission(&mut self, val: Decimal, scale: i32) {
147 self.message.body.set_field(tag::COMMISSION, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
148 }
149
150 pub fn get_commission(&self) -> Result<Decimal, MessageRejectErrorEnum> {
152 let mut fld = field::CommissionField::new(Decimal::ZERO, 0);
153 self.message.body.get_field(tag::COMMISSION, &mut fld.0)?;
154 Ok(fld.value())
155 }
156
157
158 pub fn has_commission(&self) -> bool {
160 self.message.body.has(tag::COMMISSION)
161 }
162
163
164
165
166 pub fn set_currency(&mut self, v: String) {
168 self.message.body.set_field(tag::CURRENCY, FIXString::from(v));
169 }
170
171 pub fn get_currency(&self) -> Result<String, MessageRejectErrorEnum> {
173 let mut fld = field::CurrencyField::new(String::new());
174 self.message.body.get_field(tag::CURRENCY, &mut fld.0)?;
175 Ok(fld.value().to_string())
176 }
177
178
179 pub fn has_currency(&self) -> bool {
181 self.message.body.has(tag::CURRENCY)
182 }
183
184
185
186
187 pub fn set_ex_destination(&mut self, v: String) {
189 self.message.body.set_field(tag::EX_DESTINATION, FIXString::from(v));
190 }
191
192 pub fn get_ex_destination(&self) -> Result<String, MessageRejectErrorEnum> {
194 let mut fld = field::ExDestinationField::new(String::new());
195 self.message.body.get_field(tag::EX_DESTINATION, &mut fld.0)?;
196 Ok(fld.value().to_string())
197 }
198
199
200 pub fn has_ex_destination(&self) -> bool {
202 self.message.body.has(tag::EX_DESTINATION)
203 }
204
205
206
207
208 pub fn set_exec_broker(&mut self, v: String) {
210 self.message.body.set_field(tag::EXEC_BROKER, FIXString::from(v));
211 }
212
213 pub fn get_exec_broker(&self) -> Result<String, MessageRejectErrorEnum> {
215 let mut fld = field::ExecBrokerField::new(String::new());
216 self.message.body.get_field(tag::EXEC_BROKER, &mut fld.0)?;
217 Ok(fld.value().to_string())
218 }
219
220
221 pub fn has_exec_broker(&self) -> bool {
223 self.message.body.has(tag::EXEC_BROKER)
224 }
225
226
227
228
229 pub fn set_exec_inst(&mut self, v: String) {
231 self.message.body.set_field(tag::EXEC_INST, FIXString::from(v));
232 }
233
234 pub fn get_exec_inst(&self) -> Result<String, MessageRejectErrorEnum> {
236 let mut fld = field::ExecInstField::new(String::new());
237 self.message.body.get_field(tag::EXEC_INST, &mut fld.0)?;
238 Ok(fld.value().to_string())
239 }
240
241
242 pub fn has_exec_inst(&self) -> bool {
244 self.message.body.has(tag::EXEC_INST)
245 }
246
247
248
249
250 pub fn set_expire_time(&mut self, v: Timestamp) {
252 self.message.body.set_field(tag::EXPIRE_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
253 time: v,
254 precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
255 });
256 }
257
258 pub fn get_expire_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
260 let mut fld = field::ExpireTimeField::new(Timestamp::UNIX_EPOCH);
261 self.message.body.get_field(tag::EXPIRE_TIME, &mut fld.0)?;
262 Ok(fld.value())
263 }
264
265
266 pub fn has_expire_time(&self) -> bool {
268 self.message.body.has(tag::EXPIRE_TIME)
269 }
270
271
272
273
274 pub fn set_forex_req(&mut self, v: bool) {
276 self.message.body.set_field(tag::FOREX_REQ, fixer::fix_boolean::FIXBoolean::from(v));
277 }
278
279 pub fn get_forex_req(&self) -> Result<bool, MessageRejectErrorEnum> {
281 let mut fld = field::ForexReqField::new(false);
282 self.message.body.get_field(tag::FOREX_REQ, &mut fld.0)?;
283 Ok(fld.value())
284 }
285
286
287 pub fn has_forex_req(&self) -> bool {
289 self.message.body.has(tag::FOREX_REQ)
290 }
291
292
293
294
295 pub fn set_fut_sett_date(&mut self, v: String) {
297 self.message.body.set_field(tag::FUT_SETT_DATE, FIXString::from(v));
298 }
299
300 pub fn get_fut_sett_date(&self) -> Result<String, MessageRejectErrorEnum> {
302 let mut fld = field::FutSettDateField::new(String::new());
303 self.message.body.get_field(tag::FUT_SETT_DATE, &mut fld.0)?;
304 Ok(fld.value().to_string())
305 }
306
307
308 pub fn has_fut_sett_date(&self) -> bool {
310 self.message.body.has(tag::FUT_SETT_DATE)
311 }
312
313
314
315
316 pub fn set_handl_inst(&mut self, v: String) {
318 self.message.body.set_field(tag::HANDL_INST, FIXString::from(v));
319 }
320
321 pub fn get_handl_inst(&self) -> Result<String, MessageRejectErrorEnum> {
323 let mut fld = field::HandlInstField::new(String::new());
324 self.message.body.get_field(tag::HANDL_INST, &mut fld.0)?;
325 Ok(fld.value().to_string())
326 }
327
328
329 pub fn has_handl_inst(&self) -> bool {
331 self.message.body.has(tag::HANDL_INST)
332 }
333
334
335
336
337 pub fn set_id_source(&mut self, v: String) {
339 self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
340 }
341
342 pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
344 let mut fld = field::IDSourceField::new(String::new());
345 self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
346 Ok(fld.value().to_string())
347 }
348
349
350 pub fn has_id_source(&self) -> bool {
352 self.message.body.has(tag::ID_SOURCE)
353 }
354
355
356
357
358 pub fn set_issuer(&mut self, v: String) {
360 self.message.body.set_field(tag::ISSUER, FIXString::from(v));
361 }
362
363 pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
365 let mut fld = field::IssuerField::new(String::new());
366 self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
367 Ok(fld.value().to_string())
368 }
369
370
371 pub fn has_issuer(&self) -> bool {
373 self.message.body.has(tag::ISSUER)
374 }
375
376
377
378
379 pub fn set_list_id(&mut self, v: String) {
381 self.message.body.set_field(tag::LIST_ID, FIXString::from(v));
382 }
383
384 pub fn get_list_id(&self) -> Result<String, MessageRejectErrorEnum> {
386 let mut fld = field::ListIDField::new(String::new());
387 self.message.body.get_field(tag::LIST_ID, &mut fld.0)?;
388 Ok(fld.value().to_string())
389 }
390
391
392 pub fn has_list_id(&self) -> bool {
394 self.message.body.has(tag::LIST_ID)
395 }
396
397
398
399
400 pub fn set_max_floor(&mut self, val: Decimal, scale: i32) {
402 self.message.body.set_field(tag::MAX_FLOOR, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
403 }
404
405 pub fn get_max_floor(&self) -> Result<Decimal, MessageRejectErrorEnum> {
407 let mut fld = field::MaxFloorField::new(Decimal::ZERO, 0);
408 self.message.body.get_field(tag::MAX_FLOOR, &mut fld.0)?;
409 Ok(fld.value())
410 }
411
412
413 pub fn has_max_floor(&self) -> bool {
415 self.message.body.has(tag::MAX_FLOOR)
416 }
417
418
419
420
421 pub fn set_min_qty(&mut self, val: Decimal, scale: i32) {
423 self.message.body.set_field(tag::MIN_QTY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
424 }
425
426 pub fn get_min_qty(&self) -> Result<Decimal, MessageRejectErrorEnum> {
428 let mut fld = field::MinQtyField::new(Decimal::ZERO, 0);
429 self.message.body.get_field(tag::MIN_QTY, &mut fld.0)?;
430 Ok(fld.value())
431 }
432
433
434 pub fn has_min_qty(&self) -> bool {
436 self.message.body.has(tag::MIN_QTY)
437 }
438
439
440
441
442 pub fn set_ord_type(&mut self, v: String) {
444 self.message.body.set_field(tag::ORD_TYPE, FIXString::from(v));
445 }
446
447 pub fn get_ord_type(&self) -> Result<String, MessageRejectErrorEnum> {
449 let mut fld = field::OrdTypeField::new(String::new());
450 self.message.body.get_field(tag::ORD_TYPE, &mut fld.0)?;
451 Ok(fld.value().to_string())
452 }
453
454
455 pub fn has_ord_type(&self) -> bool {
457 self.message.body.has(tag::ORD_TYPE)
458 }
459
460
461
462
463 pub fn set_order_id(&mut self, v: String) {
465 self.message.body.set_field(tag::ORDER_ID, FIXString::from(v));
466 }
467
468 pub fn get_order_id(&self) -> Result<String, MessageRejectErrorEnum> {
470 let mut fld = field::OrderIDField::new(String::new());
471 self.message.body.get_field(tag::ORDER_ID, &mut fld.0)?;
472 Ok(fld.value().to_string())
473 }
474
475
476 pub fn has_order_id(&self) -> bool {
478 self.message.body.has(tag::ORDER_ID)
479 }
480
481
482
483
484 pub fn set_order_qty(&mut self, val: Decimal, scale: i32) {
486 self.message.body.set_field(tag::ORDER_QTY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
487 }
488
489 pub fn get_order_qty(&self) -> Result<Decimal, MessageRejectErrorEnum> {
491 let mut fld = field::OrderQtyField::new(Decimal::ZERO, 0);
492 self.message.body.get_field(tag::ORDER_QTY, &mut fld.0)?;
493 Ok(fld.value())
494 }
495
496
497 pub fn has_order_qty(&self) -> bool {
499 self.message.body.has(tag::ORDER_QTY)
500 }
501
502
503
504
505 pub fn set_orig_cl_ord_id(&mut self, v: String) {
507 self.message.body.set_field(tag::ORIG_CL_ORD_ID, FIXString::from(v));
508 }
509
510 pub fn get_orig_cl_ord_id(&self) -> Result<String, MessageRejectErrorEnum> {
512 let mut fld = field::OrigClOrdIDField::new(String::new());
513 self.message.body.get_field(tag::ORIG_CL_ORD_ID, &mut fld.0)?;
514 Ok(fld.value().to_string())
515 }
516
517
518 pub fn has_orig_cl_ord_id(&self) -> bool {
520 self.message.body.has(tag::ORIG_CL_ORD_ID)
521 }
522
523
524
525
526 pub fn set_price(&mut self, val: Decimal, scale: i32) {
528 self.message.body.set_field(tag::PRICE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
529 }
530
531 pub fn get_price(&self) -> Result<Decimal, MessageRejectErrorEnum> {
533 let mut fld = field::PriceField::new(Decimal::ZERO, 0);
534 self.message.body.get_field(tag::PRICE, &mut fld.0)?;
535 Ok(fld.value())
536 }
537
538
539 pub fn has_price(&self) -> bool {
541 self.message.body.has(tag::PRICE)
542 }
543
544
545
546
547 pub fn set_rule80_a(&mut self, v: String) {
549 self.message.body.set_field(tag::RULE80_A, FIXString::from(v));
550 }
551
552 pub fn get_rule80_a(&self) -> Result<String, MessageRejectErrorEnum> {
554 let mut fld = field::Rule80AField::new(String::new());
555 self.message.body.get_field(tag::RULE80_A, &mut fld.0)?;
556 Ok(fld.value().to_string())
557 }
558
559
560 pub fn has_rule80_a(&self) -> bool {
562 self.message.body.has(tag::RULE80_A)
563 }
564
565
566
567
568 pub fn set_security_desc(&mut self, v: String) {
570 self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
571 }
572
573 pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
575 let mut fld = field::SecurityDescField::new(String::new());
576 self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
577 Ok(fld.value().to_string())
578 }
579
580
581 pub fn has_security_desc(&self) -> bool {
583 self.message.body.has(tag::SECURITY_DESC)
584 }
585
586
587
588
589 pub fn set_security_id(&mut self, v: String) {
591 self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
592 }
593
594 pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
596 let mut fld = field::SecurityIDField::new(String::new());
597 self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
598 Ok(fld.value().to_string())
599 }
600
601
602 pub fn has_security_id(&self) -> bool {
604 self.message.body.has(tag::SECURITY_ID)
605 }
606
607
608
609
610 pub fn set_settl_currency(&mut self, v: String) {
612 self.message.body.set_field(tag::SETTL_CURRENCY, FIXString::from(v));
613 }
614
615 pub fn get_settl_currency(&self) -> Result<String, MessageRejectErrorEnum> {
617 let mut fld = field::SettlCurrencyField::new(String::new());
618 self.message.body.get_field(tag::SETTL_CURRENCY, &mut fld.0)?;
619 Ok(fld.value().to_string())
620 }
621
622
623 pub fn has_settl_currency(&self) -> bool {
625 self.message.body.has(tag::SETTL_CURRENCY)
626 }
627
628
629
630
631 pub fn set_settlmnt_typ(&mut self, v: String) {
633 self.message.body.set_field(tag::SETTLMNT_TYP, FIXString::from(v));
634 }
635
636 pub fn get_settlmnt_typ(&self) -> Result<String, MessageRejectErrorEnum> {
638 let mut fld = field::SettlmntTypField::new(String::new());
639 self.message.body.get_field(tag::SETTLMNT_TYP, &mut fld.0)?;
640 Ok(fld.value().to_string())
641 }
642
643
644 pub fn has_settlmnt_typ(&self) -> bool {
646 self.message.body.has(tag::SETTLMNT_TYP)
647 }
648
649
650
651
652 pub fn set_side(&mut self, v: String) {
654 self.message.body.set_field(tag::SIDE, FIXString::from(v));
655 }
656
657 pub fn get_side(&self) -> Result<String, MessageRejectErrorEnum> {
659 let mut fld = field::SideField::new(String::new());
660 self.message.body.get_field(tag::SIDE, &mut fld.0)?;
661 Ok(fld.value().to_string())
662 }
663
664
665 pub fn has_side(&self) -> bool {
667 self.message.body.has(tag::SIDE)
668 }
669
670
671
672
673 pub fn set_stop_px(&mut self, val: Decimal, scale: i32) {
675 self.message.body.set_field(tag::STOP_PX, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
676 }
677
678 pub fn get_stop_px(&self) -> Result<Decimal, MessageRejectErrorEnum> {
680 let mut fld = field::StopPxField::new(Decimal::ZERO, 0);
681 self.message.body.get_field(tag::STOP_PX, &mut fld.0)?;
682 Ok(fld.value())
683 }
684
685
686 pub fn has_stop_px(&self) -> bool {
688 self.message.body.has(tag::STOP_PX)
689 }
690
691
692
693
694 pub fn set_symbol(&mut self, v: String) {
696 self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
697 }
698
699 pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
701 let mut fld = field::SymbolField::new(String::new());
702 self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
703 Ok(fld.value().to_string())
704 }
705
706
707 pub fn has_symbol(&self) -> bool {
709 self.message.body.has(tag::SYMBOL)
710 }
711
712
713
714
715 pub fn set_symbol_sfx(&mut self, v: String) {
717 self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
718 }
719
720 pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
722 let mut fld = field::SymbolSfxField::new(String::new());
723 self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
724 Ok(fld.value().to_string())
725 }
726
727
728 pub fn has_symbol_sfx(&self) -> bool {
730 self.message.body.has(tag::SYMBOL_SFX)
731 }
732
733
734
735
736 pub fn set_text(&mut self, v: String) {
738 self.message.body.set_field(tag::TEXT, FIXString::from(v));
739 }
740
741 pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
743 let mut fld = field::TextField::new(String::new());
744 self.message.body.get_field(tag::TEXT, &mut fld.0)?;
745 Ok(fld.value().to_string())
746 }
747
748
749 pub fn has_text(&self) -> bool {
751 self.message.body.has(tag::TEXT)
752 }
753
754
755
756
757 pub fn set_time_in_force(&mut self, v: String) {
759 self.message.body.set_field(tag::TIME_IN_FORCE, FIXString::from(v));
760 }
761
762 pub fn get_time_in_force(&self) -> Result<String, MessageRejectErrorEnum> {
764 let mut fld = field::TimeInForceField::new(String::new());
765 self.message.body.get_field(tag::TIME_IN_FORCE, &mut fld.0)?;
766 Ok(fld.value().to_string())
767 }
768
769
770 pub fn has_time_in_force(&self) -> bool {
772 self.message.body.has(tag::TIME_IN_FORCE)
773 }
774
775
776}
777
778pub type RouteOut = fn(msg: OrderCancelReplaceRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
780
781pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
783
784pub fn route(router: RouteOut) -> Route {
786 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
787 router(OrderCancelReplaceRequest::from_message(msg.clone()), session_id)
788 };
789 ("FIX.4.0", "G", Box::new(r))
790}