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 NewOrderSingle {
22 pub message: Message,
23}
24
25impl NewOrderSingle {
26 pub fn new(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("D".to_string()));
30
31 msg.body.set_field(tag::CL_ORD_ID, cl_ord_id.0);
32
33 msg.body.set_field(tag::HANDL_INST, handl_inst.0);
34
35 msg.body.set_field(tag::SYMBOL, symbol.0);
36
37 msg.body.set_field(tag::SIDE, side.0);
38
39 msg.body.set_field(tag::ORDER_QTY, order_qty.0);
40
41 msg.body.set_field(tag::ORD_TYPE, ord_type.0);
42
43 Self { message: msg }
44 }
45
46 pub fn from_message(msg: Message) -> Self {
48 Self { message: msg }
49 }
50
51 pub fn to_message(self) -> Message {
53 self.message
54 }
55
56
57
58
59 pub fn set_account(&mut self, v: String) {
61 self.message.body.set_field(tag::ACCOUNT, FIXString::from(v));
62 }
63
64 pub fn get_account(&self) -> Result<String, MessageRejectErrorEnum> {
66 let mut fld = field::AccountField::new(String::new());
67 self.message.body.get_field(tag::ACCOUNT, &mut fld.0)?;
68 Ok(fld.value().to_string())
69 }
70
71
72 pub fn has_account(&self) -> bool {
74 self.message.body.has(tag::ACCOUNT)
75 }
76
77
78
79
80 pub fn set_cl_ord_id(&mut self, v: String) {
82 self.message.body.set_field(tag::CL_ORD_ID, FIXString::from(v));
83 }
84
85 pub fn get_cl_ord_id(&self) -> Result<String, MessageRejectErrorEnum> {
87 let mut fld = field::ClOrdIDField::new(String::new());
88 self.message.body.get_field(tag::CL_ORD_ID, &mut fld.0)?;
89 Ok(fld.value().to_string())
90 }
91
92
93 pub fn has_cl_ord_id(&self) -> bool {
95 self.message.body.has(tag::CL_ORD_ID)
96 }
97
98
99
100
101 pub fn set_client_id(&mut self, v: String) {
103 self.message.body.set_field(tag::CLIENT_ID, FIXString::from(v));
104 }
105
106 pub fn get_client_id(&self) -> Result<String, MessageRejectErrorEnum> {
108 let mut fld = field::ClientIDField::new(String::new());
109 self.message.body.get_field(tag::CLIENT_ID, &mut fld.0)?;
110 Ok(fld.value().to_string())
111 }
112
113
114 pub fn has_client_id(&self) -> bool {
116 self.message.body.has(tag::CLIENT_ID)
117 }
118
119
120
121
122 pub fn set_comm_type(&mut self, v: String) {
124 self.message.body.set_field(tag::COMM_TYPE, FIXString::from(v));
125 }
126
127 pub fn get_comm_type(&self) -> Result<String, MessageRejectErrorEnum> {
129 let mut fld = field::CommTypeField::new(String::new());
130 self.message.body.get_field(tag::COMM_TYPE, &mut fld.0)?;
131 Ok(fld.value().to_string())
132 }
133
134
135 pub fn has_comm_type(&self) -> bool {
137 self.message.body.has(tag::COMM_TYPE)
138 }
139
140
141
142
143 pub fn set_commission(&mut self, val: Decimal, scale: i32) {
145 self.message.body.set_field(tag::COMMISSION, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
146 }
147
148 pub fn get_commission(&self) -> Result<Decimal, MessageRejectErrorEnum> {
150 let mut fld = field::CommissionField::new(Decimal::ZERO, 0);
151 self.message.body.get_field(tag::COMMISSION, &mut fld.0)?;
152 Ok(fld.value())
153 }
154
155
156 pub fn has_commission(&self) -> bool {
158 self.message.body.has(tag::COMMISSION)
159 }
160
161
162
163
164 pub fn set_currency(&mut self, v: String) {
166 self.message.body.set_field(tag::CURRENCY, FIXString::from(v));
167 }
168
169 pub fn get_currency(&self) -> Result<String, MessageRejectErrorEnum> {
171 let mut fld = field::CurrencyField::new(String::new());
172 self.message.body.get_field(tag::CURRENCY, &mut fld.0)?;
173 Ok(fld.value().to_string())
174 }
175
176
177 pub fn has_currency(&self) -> bool {
179 self.message.body.has(tag::CURRENCY)
180 }
181
182
183
184
185 pub fn set_ex_destination(&mut self, v: String) {
187 self.message.body.set_field(tag::EX_DESTINATION, FIXString::from(v));
188 }
189
190 pub fn get_ex_destination(&self) -> Result<String, MessageRejectErrorEnum> {
192 let mut fld = field::ExDestinationField::new(String::new());
193 self.message.body.get_field(tag::EX_DESTINATION, &mut fld.0)?;
194 Ok(fld.value().to_string())
195 }
196
197
198 pub fn has_ex_destination(&self) -> bool {
200 self.message.body.has(tag::EX_DESTINATION)
201 }
202
203
204
205
206 pub fn set_exec_broker(&mut self, v: String) {
208 self.message.body.set_field(tag::EXEC_BROKER, FIXString::from(v));
209 }
210
211 pub fn get_exec_broker(&self) -> Result<String, MessageRejectErrorEnum> {
213 let mut fld = field::ExecBrokerField::new(String::new());
214 self.message.body.get_field(tag::EXEC_BROKER, &mut fld.0)?;
215 Ok(fld.value().to_string())
216 }
217
218
219 pub fn has_exec_broker(&self) -> bool {
221 self.message.body.has(tag::EXEC_BROKER)
222 }
223
224
225
226
227 pub fn set_exec_inst(&mut self, v: String) {
229 self.message.body.set_field(tag::EXEC_INST, FIXString::from(v));
230 }
231
232 pub fn get_exec_inst(&self) -> Result<String, MessageRejectErrorEnum> {
234 let mut fld = field::ExecInstField::new(String::new());
235 self.message.body.get_field(tag::EXEC_INST, &mut fld.0)?;
236 Ok(fld.value().to_string())
237 }
238
239
240 pub fn has_exec_inst(&self) -> bool {
242 self.message.body.has(tag::EXEC_INST)
243 }
244
245
246
247
248 pub fn set_expire_time(&mut self, v: Timestamp) {
250 self.message.body.set_field(tag::EXPIRE_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
251 time: v,
252 precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
253 });
254 }
255
256 pub fn get_expire_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
258 let mut fld = field::ExpireTimeField::new(Timestamp::UNIX_EPOCH);
259 self.message.body.get_field(tag::EXPIRE_TIME, &mut fld.0)?;
260 Ok(fld.value())
261 }
262
263
264 pub fn has_expire_time(&self) -> bool {
266 self.message.body.has(tag::EXPIRE_TIME)
267 }
268
269
270
271
272 pub fn set_forex_req(&mut self, v: bool) {
274 self.message.body.set_field(tag::FOREX_REQ, fixer::fix_boolean::FIXBoolean::from(v));
275 }
276
277 pub fn get_forex_req(&self) -> Result<bool, MessageRejectErrorEnum> {
279 let mut fld = field::ForexReqField::new(false);
280 self.message.body.get_field(tag::FOREX_REQ, &mut fld.0)?;
281 Ok(fld.value())
282 }
283
284
285 pub fn has_forex_req(&self) -> bool {
287 self.message.body.has(tag::FOREX_REQ)
288 }
289
290
291
292
293 pub fn set_fut_sett_date(&mut self, v: String) {
295 self.message.body.set_field(tag::FUT_SETT_DATE, FIXString::from(v));
296 }
297
298 pub fn get_fut_sett_date(&self) -> Result<String, MessageRejectErrorEnum> {
300 let mut fld = field::FutSettDateField::new(String::new());
301 self.message.body.get_field(tag::FUT_SETT_DATE, &mut fld.0)?;
302 Ok(fld.value().to_string())
303 }
304
305
306 pub fn has_fut_sett_date(&self) -> bool {
308 self.message.body.has(tag::FUT_SETT_DATE)
309 }
310
311
312
313
314 pub fn set_handl_inst(&mut self, v: String) {
316 self.message.body.set_field(tag::HANDL_INST, FIXString::from(v));
317 }
318
319 pub fn get_handl_inst(&self) -> Result<String, MessageRejectErrorEnum> {
321 let mut fld = field::HandlInstField::new(String::new());
322 self.message.body.get_field(tag::HANDL_INST, &mut fld.0)?;
323 Ok(fld.value().to_string())
324 }
325
326
327 pub fn has_handl_inst(&self) -> bool {
329 self.message.body.has(tag::HANDL_INST)
330 }
331
332
333
334
335 pub fn set_id_source(&mut self, v: String) {
337 self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
338 }
339
340 pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
342 let mut fld = field::IDSourceField::new(String::new());
343 self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
344 Ok(fld.value().to_string())
345 }
346
347
348 pub fn has_id_source(&self) -> bool {
350 self.message.body.has(tag::ID_SOURCE)
351 }
352
353
354
355
356 pub fn set_io_iid(&mut self, v: String) {
358 self.message.body.set_field(tag::IO_IID, FIXString::from(v));
359 }
360
361 pub fn get_io_iid(&self) -> Result<String, MessageRejectErrorEnum> {
363 let mut fld = field::IOIidField::new(String::new());
364 self.message.body.get_field(tag::IO_IID, &mut fld.0)?;
365 Ok(fld.value().to_string())
366 }
367
368
369 pub fn has_io_iid(&self) -> bool {
371 self.message.body.has(tag::IO_IID)
372 }
373
374
375
376
377 pub fn set_issuer(&mut self, v: String) {
379 self.message.body.set_field(tag::ISSUER, FIXString::from(v));
380 }
381
382 pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
384 let mut fld = field::IssuerField::new(String::new());
385 self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
386 Ok(fld.value().to_string())
387 }
388
389
390 pub fn has_issuer(&self) -> bool {
392 self.message.body.has(tag::ISSUER)
393 }
394
395
396
397
398 pub fn set_locate_reqd(&mut self, v: bool) {
400 self.message.body.set_field(tag::LOCATE_REQD, fixer::fix_boolean::FIXBoolean::from(v));
401 }
402
403 pub fn get_locate_reqd(&self) -> Result<bool, MessageRejectErrorEnum> {
405 let mut fld = field::LocateReqdField::new(false);
406 self.message.body.get_field(tag::LOCATE_REQD, &mut fld.0)?;
407 Ok(fld.value())
408 }
409
410
411 pub fn has_locate_reqd(&self) -> bool {
413 self.message.body.has(tag::LOCATE_REQD)
414 }
415
416
417
418
419 pub fn set_max_floor(&mut self, val: Decimal, scale: i32) {
421 self.message.body.set_field(tag::MAX_FLOOR, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
422 }
423
424 pub fn get_max_floor(&self) -> Result<Decimal, MessageRejectErrorEnum> {
426 let mut fld = field::MaxFloorField::new(Decimal::ZERO, 0);
427 self.message.body.get_field(tag::MAX_FLOOR, &mut fld.0)?;
428 Ok(fld.value())
429 }
430
431
432 pub fn has_max_floor(&self) -> bool {
434 self.message.body.has(tag::MAX_FLOOR)
435 }
436
437
438
439
440 pub fn set_min_qty(&mut self, val: Decimal, scale: i32) {
442 self.message.body.set_field(tag::MIN_QTY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
443 }
444
445 pub fn get_min_qty(&self) -> Result<Decimal, MessageRejectErrorEnum> {
447 let mut fld = field::MinQtyField::new(Decimal::ZERO, 0);
448 self.message.body.get_field(tag::MIN_QTY, &mut fld.0)?;
449 Ok(fld.value())
450 }
451
452
453 pub fn has_min_qty(&self) -> bool {
455 self.message.body.has(tag::MIN_QTY)
456 }
457
458
459
460
461 pub fn set_ord_type(&mut self, v: String) {
463 self.message.body.set_field(tag::ORD_TYPE, FIXString::from(v));
464 }
465
466 pub fn get_ord_type(&self) -> Result<String, MessageRejectErrorEnum> {
468 let mut fld = field::OrdTypeField::new(String::new());
469 self.message.body.get_field(tag::ORD_TYPE, &mut fld.0)?;
470 Ok(fld.value().to_string())
471 }
472
473
474 pub fn has_ord_type(&self) -> bool {
476 self.message.body.has(tag::ORD_TYPE)
477 }
478
479
480
481
482 pub fn set_order_qty(&mut self, val: Decimal, scale: i32) {
484 self.message.body.set_field(tag::ORDER_QTY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
485 }
486
487 pub fn get_order_qty(&self) -> Result<Decimal, MessageRejectErrorEnum> {
489 let mut fld = field::OrderQtyField::new(Decimal::ZERO, 0);
490 self.message.body.get_field(tag::ORDER_QTY, &mut fld.0)?;
491 Ok(fld.value())
492 }
493
494
495 pub fn has_order_qty(&self) -> bool {
497 self.message.body.has(tag::ORDER_QTY)
498 }
499
500
501
502
503 pub fn set_prev_close_px(&mut self, val: Decimal, scale: i32) {
505 self.message.body.set_field(tag::PREV_CLOSE_PX, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
506 }
507
508 pub fn get_prev_close_px(&self) -> Result<Decimal, MessageRejectErrorEnum> {
510 let mut fld = field::PrevClosePxField::new(Decimal::ZERO, 0);
511 self.message.body.get_field(tag::PREV_CLOSE_PX, &mut fld.0)?;
512 Ok(fld.value())
513 }
514
515
516 pub fn has_prev_close_px(&self) -> bool {
518 self.message.body.has(tag::PREV_CLOSE_PX)
519 }
520
521
522
523
524 pub fn set_price(&mut self, val: Decimal, scale: i32) {
526 self.message.body.set_field(tag::PRICE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
527 }
528
529 pub fn get_price(&self) -> Result<Decimal, MessageRejectErrorEnum> {
531 let mut fld = field::PriceField::new(Decimal::ZERO, 0);
532 self.message.body.get_field(tag::PRICE, &mut fld.0)?;
533 Ok(fld.value())
534 }
535
536
537 pub fn has_price(&self) -> bool {
539 self.message.body.has(tag::PRICE)
540 }
541
542
543
544
545 pub fn set_process_code(&mut self, v: String) {
547 self.message.body.set_field(tag::PROCESS_CODE, FIXString::from(v));
548 }
549
550 pub fn get_process_code(&self) -> Result<String, MessageRejectErrorEnum> {
552 let mut fld = field::ProcessCodeField::new(String::new());
553 self.message.body.get_field(tag::PROCESS_CODE, &mut fld.0)?;
554 Ok(fld.value().to_string())
555 }
556
557
558 pub fn has_process_code(&self) -> bool {
560 self.message.body.has(tag::PROCESS_CODE)
561 }
562
563
564
565
566 pub fn set_quote_id(&mut self, v: String) {
568 self.message.body.set_field(tag::QUOTE_ID, FIXString::from(v));
569 }
570
571 pub fn get_quote_id(&self) -> Result<String, MessageRejectErrorEnum> {
573 let mut fld = field::QuoteIDField::new(String::new());
574 self.message.body.get_field(tag::QUOTE_ID, &mut fld.0)?;
575 Ok(fld.value().to_string())
576 }
577
578
579 pub fn has_quote_id(&self) -> bool {
581 self.message.body.has(tag::QUOTE_ID)
582 }
583
584
585
586
587 pub fn set_rule80_a(&mut self, v: String) {
589 self.message.body.set_field(tag::RULE80_A, FIXString::from(v));
590 }
591
592 pub fn get_rule80_a(&self) -> Result<String, MessageRejectErrorEnum> {
594 let mut fld = field::Rule80AField::new(String::new());
595 self.message.body.get_field(tag::RULE80_A, &mut fld.0)?;
596 Ok(fld.value().to_string())
597 }
598
599
600 pub fn has_rule80_a(&self) -> bool {
602 self.message.body.has(tag::RULE80_A)
603 }
604
605
606
607
608 pub fn set_security_desc(&mut self, v: String) {
610 self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
611 }
612
613 pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
615 let mut fld = field::SecurityDescField::new(String::new());
616 self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
617 Ok(fld.value().to_string())
618 }
619
620
621 pub fn has_security_desc(&self) -> bool {
623 self.message.body.has(tag::SECURITY_DESC)
624 }
625
626
627
628
629 pub fn set_security_id(&mut self, v: String) {
631 self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
632 }
633
634 pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
636 let mut fld = field::SecurityIDField::new(String::new());
637 self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
638 Ok(fld.value().to_string())
639 }
640
641
642 pub fn has_security_id(&self) -> bool {
644 self.message.body.has(tag::SECURITY_ID)
645 }
646
647
648
649
650 pub fn set_settl_currency(&mut self, v: String) {
652 self.message.body.set_field(tag::SETTL_CURRENCY, FIXString::from(v));
653 }
654
655 pub fn get_settl_currency(&self) -> Result<String, MessageRejectErrorEnum> {
657 let mut fld = field::SettlCurrencyField::new(String::new());
658 self.message.body.get_field(tag::SETTL_CURRENCY, &mut fld.0)?;
659 Ok(fld.value().to_string())
660 }
661
662
663 pub fn has_settl_currency(&self) -> bool {
665 self.message.body.has(tag::SETTL_CURRENCY)
666 }
667
668
669
670
671 pub fn set_settlmnt_typ(&mut self, v: String) {
673 self.message.body.set_field(tag::SETTLMNT_TYP, FIXString::from(v));
674 }
675
676 pub fn get_settlmnt_typ(&self) -> Result<String, MessageRejectErrorEnum> {
678 let mut fld = field::SettlmntTypField::new(String::new());
679 self.message.body.get_field(tag::SETTLMNT_TYP, &mut fld.0)?;
680 Ok(fld.value().to_string())
681 }
682
683
684 pub fn has_settlmnt_typ(&self) -> bool {
686 self.message.body.has(tag::SETTLMNT_TYP)
687 }
688
689
690
691
692 pub fn set_side(&mut self, v: String) {
694 self.message.body.set_field(tag::SIDE, FIXString::from(v));
695 }
696
697 pub fn get_side(&self) -> Result<String, MessageRejectErrorEnum> {
699 let mut fld = field::SideField::new(String::new());
700 self.message.body.get_field(tag::SIDE, &mut fld.0)?;
701 Ok(fld.value().to_string())
702 }
703
704
705 pub fn has_side(&self) -> bool {
707 self.message.body.has(tag::SIDE)
708 }
709
710
711
712
713 pub fn set_stop_px(&mut self, val: Decimal, scale: i32) {
715 self.message.body.set_field(tag::STOP_PX, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
716 }
717
718 pub fn get_stop_px(&self) -> Result<Decimal, MessageRejectErrorEnum> {
720 let mut fld = field::StopPxField::new(Decimal::ZERO, 0);
721 self.message.body.get_field(tag::STOP_PX, &mut fld.0)?;
722 Ok(fld.value())
723 }
724
725
726 pub fn has_stop_px(&self) -> bool {
728 self.message.body.has(tag::STOP_PX)
729 }
730
731
732
733
734 pub fn set_symbol(&mut self, v: String) {
736 self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
737 }
738
739 pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
741 let mut fld = field::SymbolField::new(String::new());
742 self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
743 Ok(fld.value().to_string())
744 }
745
746
747 pub fn has_symbol(&self) -> bool {
749 self.message.body.has(tag::SYMBOL)
750 }
751
752
753
754
755 pub fn set_symbol_sfx(&mut self, v: String) {
757 self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
758 }
759
760 pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
762 let mut fld = field::SymbolSfxField::new(String::new());
763 self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
764 Ok(fld.value().to_string())
765 }
766
767
768 pub fn has_symbol_sfx(&self) -> bool {
770 self.message.body.has(tag::SYMBOL_SFX)
771 }
772
773
774
775
776 pub fn set_text(&mut self, v: String) {
778 self.message.body.set_field(tag::TEXT, FIXString::from(v));
779 }
780
781 pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
783 let mut fld = field::TextField::new(String::new());
784 self.message.body.get_field(tag::TEXT, &mut fld.0)?;
785 Ok(fld.value().to_string())
786 }
787
788
789 pub fn has_text(&self) -> bool {
791 self.message.body.has(tag::TEXT)
792 }
793
794
795
796
797 pub fn set_time_in_force(&mut self, v: String) {
799 self.message.body.set_field(tag::TIME_IN_FORCE, FIXString::from(v));
800 }
801
802 pub fn get_time_in_force(&self) -> Result<String, MessageRejectErrorEnum> {
804 let mut fld = field::TimeInForceField::new(String::new());
805 self.message.body.get_field(tag::TIME_IN_FORCE, &mut fld.0)?;
806 Ok(fld.value().to_string())
807 }
808
809
810 pub fn has_time_in_force(&self) -> bool {
812 self.message.body.has(tag::TIME_IN_FORCE)
813 }
814
815
816}
817
818pub type RouteOut = fn(msg: NewOrderSingle, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
820
821pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
823
824pub fn route(router: RouteOut) -> Route {
826 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
827 router(NewOrderSingle::from_message(msg.clone()), session_id)
828 };
829 ("FIX.4.0", "D", Box::new(r))
830}