Skip to main content

fixer_fix/fix40/
allocation.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 jiff::Timestamp;
16
17use crate::field;
18use crate::tag;
19
20/// `Allocation` is the `fix40` `Allocation` type, `MsgType` = J.
21pub struct Allocation {
22    pub message: Message,
23}
24
25impl Allocation {
26    /// Creates a new `Allocation` with required fields.
27    pub fn new(alloc_id: field::AllocIDField, alloc_trans_type: field::AllocTransTypeField, no_orders: field::NoOrdersField, side: field::SideField, symbol: field::SymbolField, shares: field::SharesField, avg_px: field::AvgPxField, trade_date: field::TradeDateField, no_allocs: field::NoAllocsField) -> Self {
28        let mut msg = Message::new();
29        msg.header.set_field(tag::MSG_TYPE, FIXString::from("J".to_string()));
30
31        msg.body.set_field(tag::ALLOC_ID, alloc_id.0);
32
33        msg.body.set_field(tag::ALLOC_TRANS_TYPE, alloc_trans_type.0);
34
35        msg.body.set_field(tag::NO_ORDERS, no_orders.0);
36
37        msg.body.set_field(tag::SIDE, side.0);
38
39        msg.body.set_field(tag::SYMBOL, symbol.0);
40
41        msg.body.set_field(tag::SHARES, shares.0);
42
43        msg.body.set_field(tag::AVG_PX, avg_px.0);
44
45        msg.body.set_field(tag::TRADE_DATE, trade_date.0);
46
47        msg.body.set_field(tag::NO_ALLOCS, no_allocs.0);
48
49        Self { message: msg }
50    }
51
52    /// Creates a `Allocation` from an existing `Message`.
53    pub fn from_message(msg: Message) -> Self {
54        Self { message: msg }
55    }
56
57    /// Returns the underlying `Message`.
58    pub fn to_message(self) -> Message {
59        self.message
60    }
61
62
63
64
65    /// Sets `AllocID`, Tag 70.
66    pub fn set_alloc_id(&mut self, v: String) {
67        self.message.body.set_field(tag::ALLOC_ID, FIXString::from(v));
68    }
69
70    /// Gets `AllocID`, Tag 70.
71    pub fn get_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
72        let mut fld = field::AllocIDField::new(String::new());
73        self.message.body.get_field(tag::ALLOC_ID, &mut fld.0)?;
74        Ok(fld.value().to_string())
75    }
76
77
78    /// Returns true if `AllocID` is present, Tag 70.
79    pub fn has_alloc_id(&self) -> bool {
80        self.message.body.has(tag::ALLOC_ID)
81    }
82
83
84
85
86    /// Sets `AllocTransType`, Tag 71.
87    pub fn set_alloc_trans_type(&mut self, v: String) {
88        self.message.body.set_field(tag::ALLOC_TRANS_TYPE, FIXString::from(v));
89    }
90
91    /// Gets `AllocTransType`, Tag 71.
92    pub fn get_alloc_trans_type(&self) -> Result<String, MessageRejectErrorEnum> {
93        let mut fld = field::AllocTransTypeField::new(String::new());
94        self.message.body.get_field(tag::ALLOC_TRANS_TYPE, &mut fld.0)?;
95        Ok(fld.value().to_string())
96    }
97
98
99    /// Returns true if `AllocTransType` is present, Tag 71.
100    pub fn has_alloc_trans_type(&self) -> bool {
101        self.message.body.has(tag::ALLOC_TRANS_TYPE)
102    }
103
104
105
106
107    /// Sets `AvgPrxPrecision`, Tag 74.
108    pub fn set_avg_prx_precision(&mut self, v: isize) {
109        self.message.body.set_field(tag::AVG_PRX_PRECISION, fixer::fix_int::FIXInt::from(v));
110    }
111
112    /// Gets `AvgPrxPrecision`, Tag 74.
113    pub fn get_avg_prx_precision(&self) -> Result<isize, MessageRejectErrorEnum> {
114        let mut fld = field::AvgPrxPrecisionField::new(0);
115        self.message.body.get_field(tag::AVG_PRX_PRECISION, &mut fld.0)?;
116        Ok(fld.value())
117    }
118
119
120    /// Returns true if `AvgPrxPrecision` is present, Tag 74.
121    pub fn has_avg_prx_precision(&self) -> bool {
122        self.message.body.has(tag::AVG_PRX_PRECISION)
123    }
124
125
126
127
128    /// Sets `AvgPx`, Tag 6.
129    pub fn set_avg_px(&mut self, val: Decimal, scale: i32) {
130        self.message.body.set_field(tag::AVG_PX, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
131    }
132
133    /// Gets `AvgPx`, Tag 6.
134    pub fn get_avg_px(&self) -> Result<Decimal, MessageRejectErrorEnum> {
135        let mut fld = field::AvgPxField::new(Decimal::ZERO, 0);
136        self.message.body.get_field(tag::AVG_PX, &mut fld.0)?;
137        Ok(fld.value())
138    }
139
140
141    /// Returns true if `AvgPx` is present, Tag 6.
142    pub fn has_avg_px(&self) -> bool {
143        self.message.body.has(tag::AVG_PX)
144    }
145
146
147
148
149    /// Sets `Currency`, Tag 15.
150    pub fn set_currency(&mut self, v: String) {
151        self.message.body.set_field(tag::CURRENCY, FIXString::from(v));
152    }
153
154    /// Gets `Currency`, Tag 15.
155    pub fn get_currency(&self) -> Result<String, MessageRejectErrorEnum> {
156        let mut fld = field::CurrencyField::new(String::new());
157        self.message.body.get_field(tag::CURRENCY, &mut fld.0)?;
158        Ok(fld.value().to_string())
159    }
160
161
162    /// Returns true if `Currency` is present, Tag 15.
163    pub fn has_currency(&self) -> bool {
164        self.message.body.has(tag::CURRENCY)
165    }
166
167
168
169
170    /// Sets `FutSettDate`, Tag 64.
171    pub fn set_fut_sett_date(&mut self, v: String) {
172        self.message.body.set_field(tag::FUT_SETT_DATE, FIXString::from(v));
173    }
174
175    /// Gets `FutSettDate`, Tag 64.
176    pub fn get_fut_sett_date(&self) -> Result<String, MessageRejectErrorEnum> {
177        let mut fld = field::FutSettDateField::new(String::new());
178        self.message.body.get_field(tag::FUT_SETT_DATE, &mut fld.0)?;
179        Ok(fld.value().to_string())
180    }
181
182
183    /// Returns true if `FutSettDate` is present, Tag 64.
184    pub fn has_fut_sett_date(&self) -> bool {
185        self.message.body.has(tag::FUT_SETT_DATE)
186    }
187
188
189
190
191    /// Sets `IDSource`, Tag 22.
192    pub fn set_id_source(&mut self, v: String) {
193        self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
194    }
195
196    /// Gets `IDSource`, Tag 22.
197    pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
198        let mut fld = field::IDSourceField::new(String::new());
199        self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
200        Ok(fld.value().to_string())
201    }
202
203
204    /// Returns true if `IDSource` is present, Tag 22.
205    pub fn has_id_source(&self) -> bool {
206        self.message.body.has(tag::ID_SOURCE)
207    }
208
209
210
211
212    /// Sets `Issuer`, Tag 106.
213    pub fn set_issuer(&mut self, v: String) {
214        self.message.body.set_field(tag::ISSUER, FIXString::from(v));
215    }
216
217    /// Gets `Issuer`, Tag 106.
218    pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
219        let mut fld = field::IssuerField::new(String::new());
220        self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
221        Ok(fld.value().to_string())
222    }
223
224
225    /// Returns true if `Issuer` is present, Tag 106.
226    pub fn has_issuer(&self) -> bool {
227        self.message.body.has(tag::ISSUER)
228    }
229
230
231
232
233    /// Sets `NetMoney`, Tag 118.
234    pub fn set_net_money(&mut self, val: Decimal, scale: i32) {
235        self.message.body.set_field(tag::NET_MONEY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
236    }
237
238    /// Gets `NetMoney`, Tag 118.
239    pub fn get_net_money(&self) -> Result<Decimal, MessageRejectErrorEnum> {
240        let mut fld = field::NetMoneyField::new(Decimal::ZERO, 0);
241        self.message.body.get_field(tag::NET_MONEY, &mut fld.0)?;
242        Ok(fld.value())
243    }
244
245
246    /// Returns true if `NetMoney` is present, Tag 118.
247    pub fn has_net_money(&self) -> bool {
248        self.message.body.has(tag::NET_MONEY)
249    }
250
251
252
253
254    /// Sets `NoAllocs`, Tag 78.
255    pub fn set_no_allocs(&mut self, v: isize) {
256        self.message.body.set_field(tag::NO_ALLOCS, fixer::fix_int::FIXInt::from(v));
257    }
258
259    /// Gets `NoAllocs`, Tag 78.
260    pub fn get_no_allocs(&self) -> Result<isize, MessageRejectErrorEnum> {
261        let mut fld = field::NoAllocsField::new(0);
262        self.message.body.get_field(tag::NO_ALLOCS, &mut fld.0)?;
263        Ok(fld.value())
264    }
265
266
267    /// Returns true if `NoAllocs` is present, Tag 78.
268    pub fn has_no_allocs(&self) -> bool {
269        self.message.body.has(tag::NO_ALLOCS)
270    }
271
272
273
274
275    /// Sets `NoExecs`, Tag 124.
276    pub fn set_no_execs(&mut self, v: isize) {
277        self.message.body.set_field(tag::NO_EXECS, fixer::fix_int::FIXInt::from(v));
278    }
279
280    /// Gets `NoExecs`, Tag 124.
281    pub fn get_no_execs(&self) -> Result<isize, MessageRejectErrorEnum> {
282        let mut fld = field::NoExecsField::new(0);
283        self.message.body.get_field(tag::NO_EXECS, &mut fld.0)?;
284        Ok(fld.value())
285    }
286
287
288    /// Returns true if `NoExecs` is present, Tag 124.
289    pub fn has_no_execs(&self) -> bool {
290        self.message.body.has(tag::NO_EXECS)
291    }
292
293
294
295
296    /// Sets `NoMiscFees`, Tag 136.
297    pub fn set_no_misc_fees(&mut self, v: isize) {
298        self.message.body.set_field(tag::NO_MISC_FEES, fixer::fix_int::FIXInt::from(v));
299    }
300
301    /// Gets `NoMiscFees`, Tag 136.
302    pub fn get_no_misc_fees(&self) -> Result<isize, MessageRejectErrorEnum> {
303        let mut fld = field::NoMiscFeesField::new(0);
304        self.message.body.get_field(tag::NO_MISC_FEES, &mut fld.0)?;
305        Ok(fld.value())
306    }
307
308
309    /// Returns true if `NoMiscFees` is present, Tag 136.
310    pub fn has_no_misc_fees(&self) -> bool {
311        self.message.body.has(tag::NO_MISC_FEES)
312    }
313
314
315
316
317    /// Sets `NoOrders`, Tag 73.
318    pub fn set_no_orders(&mut self, v: isize) {
319        self.message.body.set_field(tag::NO_ORDERS, fixer::fix_int::FIXInt::from(v));
320    }
321
322    /// Gets `NoOrders`, Tag 73.
323    pub fn get_no_orders(&self) -> Result<isize, MessageRejectErrorEnum> {
324        let mut fld = field::NoOrdersField::new(0);
325        self.message.body.get_field(tag::NO_ORDERS, &mut fld.0)?;
326        Ok(fld.value())
327    }
328
329
330    /// Returns true if `NoOrders` is present, Tag 73.
331    pub fn has_no_orders(&self) -> bool {
332        self.message.body.has(tag::NO_ORDERS)
333    }
334
335
336
337
338    /// Sets `OpenClose`, Tag 77.
339    pub fn set_open_close(&mut self, v: String) {
340        self.message.body.set_field(tag::OPEN_CLOSE, FIXString::from(v));
341    }
342
343    /// Gets `OpenClose`, Tag 77.
344    pub fn get_open_close(&self) -> Result<String, MessageRejectErrorEnum> {
345        let mut fld = field::OpenCloseField::new(String::new());
346        self.message.body.get_field(tag::OPEN_CLOSE, &mut fld.0)?;
347        Ok(fld.value().to_string())
348    }
349
350
351    /// Returns true if `OpenClose` is present, Tag 77.
352    pub fn has_open_close(&self) -> bool {
353        self.message.body.has(tag::OPEN_CLOSE)
354    }
355
356
357
358
359    /// Sets `RefAllocID`, Tag 72.
360    pub fn set_ref_alloc_id(&mut self, v: String) {
361        self.message.body.set_field(tag::REF_ALLOC_ID, FIXString::from(v));
362    }
363
364    /// Gets `RefAllocID`, Tag 72.
365    pub fn get_ref_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
366        let mut fld = field::RefAllocIDField::new(String::new());
367        self.message.body.get_field(tag::REF_ALLOC_ID, &mut fld.0)?;
368        Ok(fld.value().to_string())
369    }
370
371
372    /// Returns true if `RefAllocID` is present, Tag 72.
373    pub fn has_ref_alloc_id(&self) -> bool {
374        self.message.body.has(tag::REF_ALLOC_ID)
375    }
376
377
378
379
380    /// Sets `SecurityDesc`, Tag 107.
381    pub fn set_security_desc(&mut self, v: String) {
382        self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
383    }
384
385    /// Gets `SecurityDesc`, Tag 107.
386    pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
387        let mut fld = field::SecurityDescField::new(String::new());
388        self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
389        Ok(fld.value().to_string())
390    }
391
392
393    /// Returns true if `SecurityDesc` is present, Tag 107.
394    pub fn has_security_desc(&self) -> bool {
395        self.message.body.has(tag::SECURITY_DESC)
396    }
397
398
399
400
401    /// Sets `SecurityID`, Tag 48.
402    pub fn set_security_id(&mut self, v: String) {
403        self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
404    }
405
406    /// Gets `SecurityID`, Tag 48.
407    pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
408        let mut fld = field::SecurityIDField::new(String::new());
409        self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
410        Ok(fld.value().to_string())
411    }
412
413
414    /// Returns true if `SecurityID` is present, Tag 48.
415    pub fn has_security_id(&self) -> bool {
416        self.message.body.has(tag::SECURITY_ID)
417    }
418
419
420
421
422    /// Sets `SettlCurrAmt`, Tag 119.
423    pub fn set_settl_curr_amt(&mut self, val: Decimal, scale: i32) {
424        self.message.body.set_field(tag::SETTL_CURR_AMT, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
425    }
426
427    /// Gets `SettlCurrAmt`, Tag 119.
428    pub fn get_settl_curr_amt(&self) -> Result<Decimal, MessageRejectErrorEnum> {
429        let mut fld = field::SettlCurrAmtField::new(Decimal::ZERO, 0);
430        self.message.body.get_field(tag::SETTL_CURR_AMT, &mut fld.0)?;
431        Ok(fld.value())
432    }
433
434
435    /// Returns true if `SettlCurrAmt` is present, Tag 119.
436    pub fn has_settl_curr_amt(&self) -> bool {
437        self.message.body.has(tag::SETTL_CURR_AMT)
438    }
439
440
441
442
443    /// Sets `SettlCurrency`, Tag 120.
444    pub fn set_settl_currency(&mut self, v: String) {
445        self.message.body.set_field(tag::SETTL_CURRENCY, FIXString::from(v));
446    }
447
448    /// Gets `SettlCurrency`, Tag 120.
449    pub fn get_settl_currency(&self) -> Result<String, MessageRejectErrorEnum> {
450        let mut fld = field::SettlCurrencyField::new(String::new());
451        self.message.body.get_field(tag::SETTL_CURRENCY, &mut fld.0)?;
452        Ok(fld.value().to_string())
453    }
454
455
456    /// Returns true if `SettlCurrency` is present, Tag 120.
457    pub fn has_settl_currency(&self) -> bool {
458        self.message.body.has(tag::SETTL_CURRENCY)
459    }
460
461
462
463
464    /// Sets `SettlmntTyp`, Tag 63.
465    pub fn set_settlmnt_typ(&mut self, v: String) {
466        self.message.body.set_field(tag::SETTLMNT_TYP, FIXString::from(v));
467    }
468
469    /// Gets `SettlmntTyp`, Tag 63.
470    pub fn get_settlmnt_typ(&self) -> Result<String, MessageRejectErrorEnum> {
471        let mut fld = field::SettlmntTypField::new(String::new());
472        self.message.body.get_field(tag::SETTLMNT_TYP, &mut fld.0)?;
473        Ok(fld.value().to_string())
474    }
475
476
477    /// Returns true if `SettlmntTyp` is present, Tag 63.
478    pub fn has_settlmnt_typ(&self) -> bool {
479        self.message.body.has(tag::SETTLMNT_TYP)
480    }
481
482
483
484
485    /// Sets `Shares`, Tag 53.
486    pub fn set_shares(&mut self, val: Decimal, scale: i32) {
487        self.message.body.set_field(tag::SHARES, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
488    }
489
490    /// Gets `Shares`, Tag 53.
491    pub fn get_shares(&self) -> Result<Decimal, MessageRejectErrorEnum> {
492        let mut fld = field::SharesField::new(Decimal::ZERO, 0);
493        self.message.body.get_field(tag::SHARES, &mut fld.0)?;
494        Ok(fld.value())
495    }
496
497
498    /// Returns true if `Shares` is present, Tag 53.
499    pub fn has_shares(&self) -> bool {
500        self.message.body.has(tag::SHARES)
501    }
502
503
504
505
506    /// Sets `Side`, Tag 54.
507    pub fn set_side(&mut self, v: String) {
508        self.message.body.set_field(tag::SIDE, FIXString::from(v));
509    }
510
511    /// Gets `Side`, Tag 54.
512    pub fn get_side(&self) -> Result<String, MessageRejectErrorEnum> {
513        let mut fld = field::SideField::new(String::new());
514        self.message.body.get_field(tag::SIDE, &mut fld.0)?;
515        Ok(fld.value().to_string())
516    }
517
518
519    /// Returns true if `Side` is present, Tag 54.
520    pub fn has_side(&self) -> bool {
521        self.message.body.has(tag::SIDE)
522    }
523
524
525
526
527    /// Sets `Symbol`, Tag 55.
528    pub fn set_symbol(&mut self, v: String) {
529        self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
530    }
531
532    /// Gets `Symbol`, Tag 55.
533    pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
534        let mut fld = field::SymbolField::new(String::new());
535        self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
536        Ok(fld.value().to_string())
537    }
538
539
540    /// Returns true if `Symbol` is present, Tag 55.
541    pub fn has_symbol(&self) -> bool {
542        self.message.body.has(tag::SYMBOL)
543    }
544
545
546
547
548    /// Sets `SymbolSfx`, Tag 65.
549    pub fn set_symbol_sfx(&mut self, v: String) {
550        self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
551    }
552
553    /// Gets `SymbolSfx`, Tag 65.
554    pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
555        let mut fld = field::SymbolSfxField::new(String::new());
556        self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
557        Ok(fld.value().to_string())
558    }
559
560
561    /// Returns true if `SymbolSfx` is present, Tag 65.
562    pub fn has_symbol_sfx(&self) -> bool {
563        self.message.body.has(tag::SYMBOL_SFX)
564    }
565
566
567
568
569    /// Sets `Text`, Tag 58.
570    pub fn set_text(&mut self, v: String) {
571        self.message.body.set_field(tag::TEXT, FIXString::from(v));
572    }
573
574    /// Gets `Text`, Tag 58.
575    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
576        let mut fld = field::TextField::new(String::new());
577        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
578        Ok(fld.value().to_string())
579    }
580
581
582    /// Returns true if `Text` is present, Tag 58.
583    pub fn has_text(&self) -> bool {
584        self.message.body.has(tag::TEXT)
585    }
586
587
588
589
590    /// Sets `TradeDate`, Tag 75.
591    pub fn set_trade_date(&mut self, v: String) {
592        self.message.body.set_field(tag::TRADE_DATE, FIXString::from(v));
593    }
594
595    /// Gets `TradeDate`, Tag 75.
596    pub fn get_trade_date(&self) -> Result<String, MessageRejectErrorEnum> {
597        let mut fld = field::TradeDateField::new(String::new());
598        self.message.body.get_field(tag::TRADE_DATE, &mut fld.0)?;
599        Ok(fld.value().to_string())
600    }
601
602
603    /// Returns true if `TradeDate` is present, Tag 75.
604    pub fn has_trade_date(&self) -> bool {
605        self.message.body.has(tag::TRADE_DATE)
606    }
607
608
609
610
611    /// Sets `TransactTime`, Tag 60.
612    pub fn set_transact_time(&mut self, v: Timestamp) {
613        self.message.body.set_field(tag::TRANSACT_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
614            time: v,
615            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
616        });
617    }
618
619    /// Gets `TransactTime`, Tag 60.
620    pub fn get_transact_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
621        let mut fld = field::TransactTimeField::new(Timestamp::UNIX_EPOCH);
622        self.message.body.get_field(tag::TRANSACT_TIME, &mut fld.0)?;
623        Ok(fld.value())
624    }
625
626
627    /// Returns true if `TransactTime` is present, Tag 60.
628    pub fn has_transact_time(&self) -> bool {
629        self.message.body.has(tag::TRANSACT_TIME)
630    }
631
632
633}
634
635/// `RouteOut` is the callback type for routing `Allocation` messages.
636pub type RouteOut = fn(msg: Allocation, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
637
638/// Route type returned by the `route` function.
639pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
640
641/// Returns the begin string, message type, and route function for `Allocation`.
642pub fn route(router: RouteOut) -> Route {
643    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
644        router(Allocation::from_message(msg.clone()), session_id)
645    };
646    ("FIX.4.0", "J", Box::new(r))
647}