1#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{
5 Date, Decimal, GroupTable, Instances, InvalidValue, LazyKnownTags, MonthYear, MultipleValues,
6 RawMessage, Tag, UtcTimestamp,
7};
8
9use super::super::components::{Header, Trailer};
10use super::super::enums::{
11 CommType, CoveredOrUncovered, CustomerOrFirm, DiscretionInst, ExecInst, GTBookingInst,
12 HandlInst, IDSource, OpenClose, OrdType, ProcessCode, PutOrCall, Rule80A, SecurityType,
13 SettlmntTyp, Side, TimeInForce,
14};
15
16pub struct NewOrderSingle(RawMessage);
18
19impl NewOrderSingle {
20 pub const MSG_TYPE: &[u8] = b"D";
21
22 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
23 static TAGS: LazyKnownTags = LazyKnownTags::new(
24 &[
25 Tag(11), Tag(109), Tag(76), Tag(1), Tag(78), Tag(63), Tag(64), Tag(21), Tag(18),
26 Tag(110), Tag(111), Tag(100), Tag(386), Tag(81), Tag(55), Tag(65), Tag(48), Tag(22),
27 Tag(167), Tag(200), Tag(205), Tag(201), Tag(202), Tag(206), Tag(231), Tag(223),
28 Tag(207), Tag(106), Tag(348), Tag(349), Tag(107), Tag(350), Tag(351), Tag(140),
29 Tag(54), Tag(114), Tag(60), Tag(38), Tag(152), Tag(40), Tag(44), Tag(99), Tag(15),
30 Tag(376), Tag(377), Tag(23), Tag(117), Tag(59), Tag(168), Tag(432), Tag(126),
31 Tag(427), Tag(12), Tag(13), Tag(47), Tag(121), Tag(120), Tag(58), Tag(354),
32 Tag(355), Tag(193), Tag(192), Tag(77), Tag(203), Tag(204), Tag(210), Tag(211),
33 Tag(388), Tag(389), Tag(439), Tag(440),
34 ],
35 &[
36 Header::known_tags(), Trailer::known_tags(), NewOrderSingleAllocs::known_tags(),
37 NewOrderSingleTradingSessions::known_tags(),
38 ],
39 );
40 &TAGS
41 }
42
43 pub fn from_raw(raw: RawMessage) -> Self {
44 Self(raw)
45 }
46
47 pub fn raw(&self) -> &RawMessage {
48 &self.0
49 }
50
51 pub fn header(&self) -> Header<'_> {
52 Header(self.0.scope())
53 }
54
55 pub fn trailer(&self) -> Trailer<'_> {
56 Trailer(self.0.scope())
57 }
58
59 #[doc(alias = "ClOrdID")]
61 pub fn cl_ord_id(&self) -> Result<Option<&str>, InvalidValue> {
62 self.0.get_str(Tag(11))
63 }
64
65 #[doc(alias = "ClientID")]
67 pub fn client_id(&self) -> Result<Option<&str>, InvalidValue> {
68 self.0.get_str(Tag(109))
69 }
70
71 #[doc(alias = "ExecBroker")]
73 pub fn exec_broker(&self) -> Result<Option<&str>, InvalidValue> {
74 self.0.get_str(Tag(76))
75 }
76
77 #[doc(alias = "Account")]
79 pub fn account(&self) -> Result<Option<&str>, InvalidValue> {
80 self.0.get_str(Tag(1))
81 }
82
83 #[doc(alias = "NoAllocs")]
85 pub fn allocs(&self) -> Result<Instances<'_, NewOrderSingleAllocs<'_>>, InvalidValue> {
86 self.0.get_group(&NewOrderSingleAllocs::TABLE, &Self::known_tags().get()).map(Instances::from)
87 }
88
89 #[doc(alias = "SettlmntTyp")]
91 pub fn settlmnt_typ(&self) -> Result<Option<SettlmntTyp<'_>>, InvalidValue> {
92 Ok(self.0.get_str(Tag(63))?.map(SettlmntTyp::from_value))
93 }
94
95 #[doc(alias = "FutSettDate")]
97 pub fn fut_sett_date(&self) -> Result<Option<Date>, InvalidValue> {
98 self.0.get_date(Tag(64))
99 }
100
101 #[doc(alias = "HandlInst")]
103 pub fn handl_inst(&self) -> Result<Option<HandlInst<'_>>, InvalidValue> {
104 Ok(self.0.get_str(Tag(21))?.map(HandlInst::from_value))
105 }
106
107 #[doc(alias = "ExecInst")]
109 pub fn exec_inst(&self) -> Result<Option<MultipleValues<'_, ExecInst<'_>>>, InvalidValue> {
110 self.0.get_multiple_values(Tag(18))
111 }
112
113 #[doc(alias = "MinQty")]
115 pub fn min_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
116 self.0.get_decimal(Tag(110))
117 }
118
119 #[doc(alias = "MaxFloor")]
121 pub fn max_floor(&self) -> Result<Option<Decimal>, InvalidValue> {
122 self.0.get_decimal(Tag(111))
123 }
124
125 #[doc(alias = "ExDestination")]
127 pub fn ex_destination(&self) -> Result<Option<&str>, InvalidValue> {
128 self.0.get_str(Tag(100))
129 }
130
131 #[doc(alias = "NoTradingSessions")]
133 pub fn trading_sessions(&self) -> Result<Instances<'_, NewOrderSingleTradingSessions<'_>>, InvalidValue> {
134 self.0.get_group(&NewOrderSingleTradingSessions::TABLE, &Self::known_tags().get()).map(Instances::from)
135 }
136
137 #[doc(alias = "ProcessCode")]
139 pub fn process_code(&self) -> Result<Option<ProcessCode<'_>>, InvalidValue> {
140 Ok(self.0.get_str(Tag(81))?.map(ProcessCode::from_value))
141 }
142
143 #[doc(alias = "Symbol")]
145 pub fn symbol(&self) -> Result<Option<&str>, InvalidValue> {
146 self.0.get_str(Tag(55))
147 }
148
149 #[doc(alias = "SymbolSfx")]
151 pub fn symbol_sfx(&self) -> Result<Option<&str>, InvalidValue> {
152 self.0.get_str(Tag(65))
153 }
154
155 #[doc(alias = "SecurityID")]
157 pub fn security_id(&self) -> Result<Option<&str>, InvalidValue> {
158 self.0.get_str(Tag(48))
159 }
160
161 #[doc(alias = "IDSource")]
163 pub fn id_source(&self) -> Result<Option<IDSource<'_>>, InvalidValue> {
164 Ok(self.0.get_str(Tag(22))?.map(IDSource::from_value))
165 }
166
167 #[doc(alias = "SecurityType")]
169 pub fn security_type(&self) -> Result<Option<SecurityType<'_>>, InvalidValue> {
170 Ok(self.0.get_str(Tag(167))?.map(SecurityType::from_value))
171 }
172
173 #[doc(alias = "MaturityMonthYear")]
175 pub fn maturity_month_year(&self) -> Result<Option<MonthYear>, InvalidValue> {
176 self.0.get_month_year(Tag(200))
177 }
178
179 #[doc(alias = "MaturityDay")]
181 pub fn maturity_day(&self) -> Result<Option<i64>, InvalidValue> {
182 self.0.get_int(Tag(205))
183 }
184
185 #[doc(alias = "PutOrCall")]
187 pub fn put_or_call(&self) -> Result<Option<PutOrCall>, InvalidValue> {
188 Ok(self.0.get_int(Tag(201))?.map(PutOrCall::from_value))
189 }
190
191 #[doc(alias = "StrikePrice")]
193 pub fn strike_price(&self) -> Result<Option<Decimal>, InvalidValue> {
194 self.0.get_decimal(Tag(202))
195 }
196
197 #[doc(alias = "OptAttribute")]
199 pub fn opt_attribute(&self) -> Result<Option<&str>, InvalidValue> {
200 self.0.get_str(Tag(206))
201 }
202
203 #[doc(alias = "ContractMultiplier")]
205 pub fn contract_multiplier(&self) -> Result<Option<Decimal>, InvalidValue> {
206 self.0.get_decimal(Tag(231))
207 }
208
209 #[doc(alias = "CouponRate")]
211 pub fn coupon_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
212 self.0.get_decimal(Tag(223))
213 }
214
215 #[doc(alias = "SecurityExchange")]
217 pub fn security_exchange(&self) -> Result<Option<&str>, InvalidValue> {
218 self.0.get_str(Tag(207))
219 }
220
221 #[doc(alias = "Issuer")]
223 pub fn issuer(&self) -> Result<Option<&str>, InvalidValue> {
224 self.0.get_str(Tag(106))
225 }
226
227 #[doc(alias = "EncodedIssuerLen")]
229 pub fn encoded_issuer_len(&self) -> Result<Option<i64>, InvalidValue> {
230 self.0.get_int(Tag(348))
231 }
232
233 #[doc(alias = "EncodedIssuer")]
235 pub fn encoded_issuer(&self) -> Option<&[u8]> {
236 self.0.get(Tag(349))
237 }
238
239 #[doc(alias = "SecurityDesc")]
241 pub fn security_desc(&self) -> Result<Option<&str>, InvalidValue> {
242 self.0.get_str(Tag(107))
243 }
244
245 #[doc(alias = "EncodedSecurityDescLen")]
247 pub fn encoded_security_desc_len(&self) -> Result<Option<i64>, InvalidValue> {
248 self.0.get_int(Tag(350))
249 }
250
251 #[doc(alias = "EncodedSecurityDesc")]
253 pub fn encoded_security_desc(&self) -> Option<&[u8]> {
254 self.0.get(Tag(351))
255 }
256
257 #[doc(alias = "PrevClosePx")]
259 pub fn prev_close_px(&self) -> Result<Option<Decimal>, InvalidValue> {
260 self.0.get_decimal(Tag(140))
261 }
262
263 #[doc(alias = "Side")]
265 pub fn side(&self) -> Result<Option<Side<'_>>, InvalidValue> {
266 Ok(self.0.get_str(Tag(54))?.map(Side::from_value))
267 }
268
269 #[doc(alias = "LocateReqd")]
271 pub fn locate_reqd(&self) -> Result<Option<bool>, InvalidValue> {
272 self.0.get_bool(Tag(114))
273 }
274
275 #[doc(alias = "TransactTime")]
277 pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
278 self.0.get_utc_timestamp(Tag(60))
279 }
280
281 #[doc(alias = "OrderQty")]
283 pub fn order_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
284 self.0.get_decimal(Tag(38))
285 }
286
287 #[doc(alias = "CashOrderQty")]
289 pub fn cash_order_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
290 self.0.get_decimal(Tag(152))
291 }
292
293 #[doc(alias = "OrdType")]
295 pub fn ord_type(&self) -> Result<Option<OrdType<'_>>, InvalidValue> {
296 Ok(self.0.get_str(Tag(40))?.map(OrdType::from_value))
297 }
298
299 #[doc(alias = "Price")]
301 pub fn price(&self) -> Result<Option<Decimal>, InvalidValue> {
302 self.0.get_decimal(Tag(44))
303 }
304
305 #[doc(alias = "StopPx")]
307 pub fn stop_px(&self) -> Result<Option<Decimal>, InvalidValue> {
308 self.0.get_decimal(Tag(99))
309 }
310
311 #[doc(alias = "Currency")]
313 pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
314 self.0.get_str(Tag(15))
315 }
316
317 #[doc(alias = "ComplianceID")]
319 pub fn compliance_id(&self) -> Result<Option<&str>, InvalidValue> {
320 self.0.get_str(Tag(376))
321 }
322
323 #[doc(alias = "SolicitedFlag")]
325 pub fn solicited_flag(&self) -> Result<Option<bool>, InvalidValue> {
326 self.0.get_bool(Tag(377))
327 }
328
329 #[doc(alias = "IOIid")]
331 pub fn io_iid(&self) -> Result<Option<&str>, InvalidValue> {
332 self.0.get_str(Tag(23))
333 }
334
335 #[doc(alias = "QuoteID")]
337 pub fn quote_id(&self) -> Result<Option<&str>, InvalidValue> {
338 self.0.get_str(Tag(117))
339 }
340
341 #[doc(alias = "TimeInForce")]
343 pub fn time_in_force(&self) -> Result<Option<TimeInForce<'_>>, InvalidValue> {
344 Ok(self.0.get_str(Tag(59))?.map(TimeInForce::from_value))
345 }
346
347 #[doc(alias = "EffectiveTime")]
349 pub fn effective_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
350 self.0.get_utc_timestamp(Tag(168))
351 }
352
353 #[doc(alias = "ExpireDate")]
355 pub fn expire_date(&self) -> Result<Option<Date>, InvalidValue> {
356 self.0.get_date(Tag(432))
357 }
358
359 #[doc(alias = "ExpireTime")]
361 pub fn expire_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
362 self.0.get_utc_timestamp(Tag(126))
363 }
364
365 #[doc(alias = "GTBookingInst")]
367 pub fn gt_booking_inst(&self) -> Result<Option<GTBookingInst>, InvalidValue> {
368 Ok(self.0.get_int(Tag(427))?.map(GTBookingInst::from_value))
369 }
370
371 #[doc(alias = "Commission")]
373 pub fn commission(&self) -> Result<Option<Decimal>, InvalidValue> {
374 self.0.get_decimal(Tag(12))
375 }
376
377 #[doc(alias = "CommType")]
379 pub fn comm_type(&self) -> Result<Option<CommType<'_>>, InvalidValue> {
380 Ok(self.0.get_str(Tag(13))?.map(CommType::from_value))
381 }
382
383 #[doc(alias = "Rule80A")]
385 pub fn rule80_a(&self) -> Result<Option<Rule80A<'_>>, InvalidValue> {
386 Ok(self.0.get_str(Tag(47))?.map(Rule80A::from_value))
387 }
388
389 #[doc(alias = "ForexReq")]
391 pub fn forex_req(&self) -> Result<Option<bool>, InvalidValue> {
392 self.0.get_bool(Tag(121))
393 }
394
395 #[doc(alias = "SettlCurrency")]
397 pub fn settl_currency(&self) -> Result<Option<&str>, InvalidValue> {
398 self.0.get_str(Tag(120))
399 }
400
401 #[doc(alias = "Text")]
403 pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
404 self.0.get_str(Tag(58))
405 }
406
407 #[doc(alias = "EncodedTextLen")]
409 pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
410 self.0.get_int(Tag(354))
411 }
412
413 #[doc(alias = "EncodedText")]
415 pub fn encoded_text(&self) -> Option<&[u8]> {
416 self.0.get(Tag(355))
417 }
418
419 #[doc(alias = "FutSettDate2")]
421 pub fn fut_sett_date2(&self) -> Result<Option<Date>, InvalidValue> {
422 self.0.get_date(Tag(193))
423 }
424
425 #[doc(alias = "OrderQty2")]
427 pub fn order_qty2(&self) -> Result<Option<Decimal>, InvalidValue> {
428 self.0.get_decimal(Tag(192))
429 }
430
431 #[doc(alias = "OpenClose")]
433 pub fn open_close(&self) -> Result<Option<OpenClose<'_>>, InvalidValue> {
434 Ok(self.0.get_str(Tag(77))?.map(OpenClose::from_value))
435 }
436
437 #[doc(alias = "CoveredOrUncovered")]
439 pub fn covered_or_uncovered(&self) -> Result<Option<CoveredOrUncovered>, InvalidValue> {
440 Ok(self.0.get_int(Tag(203))?.map(CoveredOrUncovered::from_value))
441 }
442
443 #[doc(alias = "CustomerOrFirm")]
445 pub fn customer_or_firm(&self) -> Result<Option<CustomerOrFirm>, InvalidValue> {
446 Ok(self.0.get_int(Tag(204))?.map(CustomerOrFirm::from_value))
447 }
448
449 #[doc(alias = "MaxShow")]
451 pub fn max_show(&self) -> Result<Option<Decimal>, InvalidValue> {
452 self.0.get_decimal(Tag(210))
453 }
454
455 #[doc(alias = "PegDifference")]
457 pub fn peg_difference(&self) -> Result<Option<Decimal>, InvalidValue> {
458 self.0.get_decimal(Tag(211))
459 }
460
461 #[doc(alias = "DiscretionInst")]
463 pub fn discretion_inst(&self) -> Result<Option<DiscretionInst<'_>>, InvalidValue> {
464 Ok(self.0.get_str(Tag(388))?.map(DiscretionInst::from_value))
465 }
466
467 #[doc(alias = "DiscretionOffset")]
469 pub fn discretion_offset(&self) -> Result<Option<Decimal>, InvalidValue> {
470 self.0.get_decimal(Tag(389))
471 }
472
473 #[doc(alias = "ClearingFirm")]
475 pub fn clearing_firm(&self) -> Result<Option<&str>, InvalidValue> {
476 self.0.get_str(Tag(439))
477 }
478
479 #[doc(alias = "ClearingAccount")]
481 pub fn clearing_account(&self) -> Result<Option<&str>, InvalidValue> {
482 self.0.get_str(Tag(440))
483 }
484}
485
486impl std::fmt::Debug for NewOrderSingle {
487 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
488 write!(f, "NewOrderSingle({})", self.0)
489 }
490}
491
492impl std::fmt::Display for NewOrderSingle {
493 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
494 std::fmt::Display::fmt(&self.0, f)
495 }
496}
497
498#[derive(Clone, Copy)]
500pub struct NewOrderSingleAllocs<'a>(refix_message::Scope<'a>);
501
502impl<'a> From<refix_message::Scope<'a>> for NewOrderSingleAllocs<'a> {
503 fn from(scope: refix_message::Scope<'a>) -> Self {
504 Self(scope)
505 }
506}
507
508impl<'a> NewOrderSingleAllocs<'a> {
509 pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
510 Tag(78),
511 Tag(79),
512 &[Tag(79), Tag(80)],
513 &[],
514 );
515
516 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
517 static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(79), Tag(80)], &[]);
518 &TAGS
519 }
520
521 pub fn raw(&self) -> refix_message::Scope<'a> {
522 self.0
523 }
524
525 #[doc(alias = "AllocAccount")]
527 pub fn alloc_account(&self) -> Result<Option<&'a str>, InvalidValue> {
528 self.0.get_str(Tag(79))
529 }
530
531 #[doc(alias = "AllocShares")]
533 pub fn alloc_shares(&self) -> Result<Option<Decimal>, InvalidValue> {
534 self.0.get_decimal(Tag(80))
535 }
536}
537
538impl std::fmt::Debug for NewOrderSingleAllocs<'_> {
539 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
540 write!(f, "NewOrderSingleAllocs({})", self.0)
541 }
542}
543
544#[derive(Clone, Copy)]
546pub struct NewOrderSingleTradingSessions<'a>(refix_message::Scope<'a>);
547
548impl<'a> From<refix_message::Scope<'a>> for NewOrderSingleTradingSessions<'a> {
549 fn from(scope: refix_message::Scope<'a>) -> Self {
550 Self(scope)
551 }
552}
553
554impl<'a> NewOrderSingleTradingSessions<'a> {
555 pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
556 Tag(386),
557 Tag(336),
558 &[Tag(336)],
559 &[],
560 );
561
562 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
563 static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(336)], &[]);
564 &TAGS
565 }
566
567 pub fn raw(&self) -> refix_message::Scope<'a> {
568 self.0
569 }
570
571 #[doc(alias = "TradingSessionID")]
573 pub fn trading_session_id(&self) -> Result<Option<&'a str>, InvalidValue> {
574 self.0.get_str(Tag(336))
575 }
576}
577
578impl std::fmt::Debug for NewOrderSingleTradingSessions<'_> {
579 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
580 write!(f, "NewOrderSingleTradingSessions({})", self.0)
581 }
582}