1#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{
5 Date, Decimal, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp,
6};
7
8use super::super::components::{
9 AllocGrp, ExecAllocGrp, FinancingDetails, Header, InstrmtLegGrp, Instrument,
10 InstrumentExtension, OrdAllocGrp, Parties, SpreadOrBenchmarkCurveData, Stipulations, Trailer,
11 UndInstrmtGrp, YieldData,
12};
13use super::super::enums::{
14 AllocCancReplaceReason, AllocIntermedReqType, AllocLinkType, AllocNoOrdersType, AllocTransType,
15 AllocType, BookingType, MatchType, PositionEffect, PriceType, QtyType, SettlType, Side,
16};
17
18pub struct AllocationInstruction(RawMessage);
20
21impl AllocationInstruction {
22 pub const MSG_TYPE: &[u8] = b"J";
23
24 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
25 static TAGS: LazyKnownTags = LazyKnownTags::new(
26 &[
27 Tag(70), Tag(71), Tag(626), Tag(793), Tag(72), Tag(796), Tag(808), Tag(196),
28 Tag(197), Tag(466), Tag(857), Tag(73), Tag(124), Tag(570), Tag(700), Tag(574),
29 Tag(54), Tag(711), Tag(555), Tag(53), Tag(854), Tag(30), Tag(229), Tag(336),
30 Tag(625), Tag(423), Tag(6), Tag(860), Tag(15), Tag(74), Tag(453), Tag(75), Tag(60),
31 Tag(63), Tag(64), Tag(775), Tag(381), Tag(238), Tag(237), Tag(118), Tag(77),
32 Tag(754), Tag(58), Tag(354), Tag(355), Tag(157), Tag(158), Tag(159), Tag(540),
33 Tag(738), Tag(920), Tag(921), Tag(922), Tag(650), Tag(232), Tag(892), Tag(893),
34 Tag(78),
35 ],
36 &[
37 Header::known_tags(), Trailer::known_tags(), OrdAllocGrp::known_tags(),
38 ExecAllocGrp::known_tags(), Instrument::known_tags(),
39 InstrumentExtension::known_tags(), FinancingDetails::known_tags(),
40 UndInstrmtGrp::known_tags(), InstrmtLegGrp::known_tags(),
41 SpreadOrBenchmarkCurveData::known_tags(), Parties::known_tags(),
42 Stipulations::known_tags(), YieldData::known_tags(), AllocGrp::known_tags(),
43 ],
44 );
45 &TAGS
46 }
47
48 pub fn from_raw(raw: RawMessage) -> Self {
49 Self(raw)
50 }
51
52 pub fn raw(&self) -> &RawMessage {
53 &self.0
54 }
55
56 pub fn header(&self) -> Header<'_> {
57 Header(self.0.scope(), Self::known_tags().get())
58 }
59
60 pub fn trailer(&self) -> Trailer<'_> {
61 Trailer(self.0.scope())
62 }
63
64 #[doc(alias = "AllocID")]
66 pub fn alloc_id(&self) -> Result<Option<&str>, InvalidValue> {
67 self.0.get_str(Tag(70))
68 }
69
70 #[doc(alias = "AllocTransType")]
72 pub fn alloc_trans_type(&self) -> Result<Option<AllocTransType<'_>>, InvalidValue> {
73 Ok(self.0.get_str(Tag(71))?.map(AllocTransType::from_value))
74 }
75
76 #[doc(alias = "AllocType")]
78 pub fn alloc_type(&self) -> Result<Option<AllocType>, InvalidValue> {
79 Ok(self.0.get_int(Tag(626))?.map(AllocType::from_value))
80 }
81
82 #[doc(alias = "SecondaryAllocID")]
84 pub fn secondary_alloc_id(&self) -> Result<Option<&str>, InvalidValue> {
85 self.0.get_str(Tag(793))
86 }
87
88 #[doc(alias = "RefAllocID")]
90 pub fn ref_alloc_id(&self) -> Result<Option<&str>, InvalidValue> {
91 self.0.get_str(Tag(72))
92 }
93
94 #[doc(alias = "AllocCancReplaceReason")]
96 pub fn alloc_canc_replace_reason(&self) -> Result<Option<AllocCancReplaceReason>, InvalidValue> {
97 Ok(self.0.get_int(Tag(796))?.map(AllocCancReplaceReason::from_value))
98 }
99
100 #[doc(alias = "AllocIntermedReqType")]
102 pub fn alloc_intermed_req_type(&self) -> Result<Option<AllocIntermedReqType>, InvalidValue> {
103 Ok(self.0.get_int(Tag(808))?.map(AllocIntermedReqType::from_value))
104 }
105
106 #[doc(alias = "AllocLinkID")]
108 pub fn alloc_link_id(&self) -> Result<Option<&str>, InvalidValue> {
109 self.0.get_str(Tag(196))
110 }
111
112 #[doc(alias = "AllocLinkType")]
114 pub fn alloc_link_type(&self) -> Result<Option<AllocLinkType>, InvalidValue> {
115 Ok(self.0.get_int(Tag(197))?.map(AllocLinkType::from_value))
116 }
117
118 #[doc(alias = "BookingRefID")]
120 pub fn booking_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
121 self.0.get_str(Tag(466))
122 }
123
124 #[doc(alias = "AllocNoOrdersType")]
126 pub fn alloc_no_orders_type(&self) -> Result<Option<AllocNoOrdersType>, InvalidValue> {
127 Ok(self.0.get_int(Tag(857))?.map(AllocNoOrdersType::from_value))
128 }
129
130 #[doc(alias = "NoOrders")]
132 pub fn orders(&self) -> Result<Instances<'_, OrdAllocGrp<'_>>, InvalidValue> {
133 self.0.get_group(&OrdAllocGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
134 }
135
136 #[doc(alias = "NoExecs")]
138 pub fn execs(&self) -> Result<Instances<'_, ExecAllocGrp<'_>>, InvalidValue> {
139 self.0.get_group(&ExecAllocGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
140 }
141
142 #[doc(alias = "PreviouslyReported")]
144 pub fn previously_reported(&self) -> Result<Option<bool>, InvalidValue> {
145 self.0.get_bool(Tag(570))
146 }
147
148 #[doc(alias = "ReversalIndicator")]
150 pub fn reversal_indicator(&self) -> Result<Option<bool>, InvalidValue> {
151 self.0.get_bool(Tag(700))
152 }
153
154 #[doc(alias = "MatchType")]
156 pub fn match_type(&self) -> Result<Option<MatchType<'_>>, InvalidValue> {
157 Ok(self.0.get_str(Tag(574))?.map(MatchType::from_value))
158 }
159
160 #[doc(alias = "Side")]
162 pub fn side(&self) -> Result<Option<Side<'_>>, InvalidValue> {
163 Ok(self.0.get_str(Tag(54))?.map(Side::from_value))
164 }
165
166 pub fn instrument(&self) -> Instrument<'_> {
168 Instrument(self.0.scope(), Self::known_tags().get())
169 }
170
171 pub fn instrument_extension(&self) -> InstrumentExtension<'_> {
173 InstrumentExtension(self.0.scope(), Self::known_tags().get())
174 }
175
176 pub fn financing_details(&self) -> FinancingDetails<'_> {
178 FinancingDetails(self.0.scope())
179 }
180
181 #[doc(alias = "NoUnderlyings")]
183 pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
184 self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
185 }
186
187 #[doc(alias = "NoLegs")]
189 pub fn legs(&self) -> Result<Instances<'_, InstrmtLegGrp<'_>>, InvalidValue> {
190 self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
191 }
192
193 #[doc(alias = "Quantity")]
195 pub fn quantity(&self) -> Result<Option<Decimal>, InvalidValue> {
196 self.0.get_decimal(Tag(53))
197 }
198
199 #[doc(alias = "QtyType")]
201 pub fn qty_type(&self) -> Result<Option<QtyType>, InvalidValue> {
202 Ok(self.0.get_int(Tag(854))?.map(QtyType::from_value))
203 }
204
205 #[doc(alias = "LastMkt")]
207 pub fn last_mkt(&self) -> Result<Option<&str>, InvalidValue> {
208 self.0.get_str(Tag(30))
209 }
210
211 #[doc(alias = "TradeOriginationDate")]
213 pub fn trade_origination_date(&self) -> Result<Option<Date>, InvalidValue> {
214 self.0.get_date(Tag(229))
215 }
216
217 #[doc(alias = "TradingSessionID")]
219 pub fn trading_session_id(&self) -> Result<Option<&str>, InvalidValue> {
220 self.0.get_str(Tag(336))
221 }
222
223 #[doc(alias = "TradingSessionSubID")]
225 pub fn trading_session_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
226 self.0.get_str(Tag(625))
227 }
228
229 #[doc(alias = "PriceType")]
231 pub fn price_type(&self) -> Result<Option<PriceType>, InvalidValue> {
232 Ok(self.0.get_int(Tag(423))?.map(PriceType::from_value))
233 }
234
235 #[doc(alias = "AvgPx")]
237 pub fn avg_px(&self) -> Result<Option<Decimal>, InvalidValue> {
238 self.0.get_decimal(Tag(6))
239 }
240
241 #[doc(alias = "AvgParPx")]
243 pub fn avg_par_px(&self) -> Result<Option<Decimal>, InvalidValue> {
244 self.0.get_decimal(Tag(860))
245 }
246
247 pub fn spread_or_benchmark_curve_data(&self) -> SpreadOrBenchmarkCurveData<'_> {
249 SpreadOrBenchmarkCurveData(self.0.scope())
250 }
251
252 #[doc(alias = "Currency")]
254 pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
255 self.0.get_str(Tag(15))
256 }
257
258 #[doc(alias = "AvgPxPrecision")]
260 pub fn avg_px_precision(&self) -> Result<Option<i64>, InvalidValue> {
261 self.0.get_int(Tag(74))
262 }
263
264 #[doc(alias = "NoPartyIDs")]
266 pub fn party_ids(&self) -> Result<Instances<'_, Parties<'_>>, InvalidValue> {
267 self.0.get_group(&Parties::TABLE, &Self::known_tags().get()).map(Instances::from)
268 }
269
270 #[doc(alias = "TradeDate")]
272 pub fn trade_date(&self) -> Result<Option<Date>, InvalidValue> {
273 self.0.get_date(Tag(75))
274 }
275
276 #[doc(alias = "TransactTime")]
278 pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
279 self.0.get_utc_timestamp(Tag(60))
280 }
281
282 #[doc(alias = "SettlType")]
284 pub fn settl_type(&self) -> Result<Option<SettlType<'_>>, InvalidValue> {
285 Ok(self.0.get_str(Tag(63))?.map(SettlType::from_value))
286 }
287
288 #[doc(alias = "SettlDate")]
290 pub fn settl_date(&self) -> Result<Option<Date>, InvalidValue> {
291 self.0.get_date(Tag(64))
292 }
293
294 #[doc(alias = "BookingType")]
296 pub fn booking_type(&self) -> Result<Option<BookingType>, InvalidValue> {
297 Ok(self.0.get_int(Tag(775))?.map(BookingType::from_value))
298 }
299
300 #[doc(alias = "GrossTradeAmt")]
302 pub fn gross_trade_amt(&self) -> Result<Option<Decimal>, InvalidValue> {
303 self.0.get_decimal(Tag(381))
304 }
305
306 #[doc(alias = "Concession")]
308 pub fn concession(&self) -> Result<Option<Decimal>, InvalidValue> {
309 self.0.get_decimal(Tag(238))
310 }
311
312 #[doc(alias = "TotalTakedown")]
314 pub fn total_takedown(&self) -> Result<Option<Decimal>, InvalidValue> {
315 self.0.get_decimal(Tag(237))
316 }
317
318 #[doc(alias = "NetMoney")]
320 pub fn net_money(&self) -> Result<Option<Decimal>, InvalidValue> {
321 self.0.get_decimal(Tag(118))
322 }
323
324 #[doc(alias = "PositionEffect")]
326 pub fn position_effect(&self) -> Result<Option<PositionEffect<'_>>, InvalidValue> {
327 Ok(self.0.get_str(Tag(77))?.map(PositionEffect::from_value))
328 }
329
330 #[doc(alias = "AutoAcceptIndicator")]
332 pub fn auto_accept_indicator(&self) -> Result<Option<bool>, InvalidValue> {
333 self.0.get_bool(Tag(754))
334 }
335
336 #[doc(alias = "Text")]
338 pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
339 self.0.get_str(Tag(58))
340 }
341
342 #[doc(alias = "EncodedTextLen")]
344 pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
345 self.0.get_int(Tag(354))
346 }
347
348 #[doc(alias = "EncodedText")]
350 pub fn encoded_text(&self) -> Option<&[u8]> {
351 self.0.get(Tag(355))
352 }
353
354 #[doc(alias = "NumDaysInterest")]
356 pub fn num_days_interest(&self) -> Result<Option<i64>, InvalidValue> {
357 self.0.get_int(Tag(157))
358 }
359
360 #[doc(alias = "AccruedInterestRate")]
362 pub fn accrued_interest_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
363 self.0.get_decimal(Tag(158))
364 }
365
366 #[doc(alias = "AccruedInterestAmt")]
368 pub fn accrued_interest_amt(&self) -> Result<Option<Decimal>, InvalidValue> {
369 self.0.get_decimal(Tag(159))
370 }
371
372 #[doc(alias = "TotalAccruedInterestAmt")]
374 pub fn total_accrued_interest_amt(&self) -> Result<Option<Decimal>, InvalidValue> {
375 self.0.get_decimal(Tag(540))
376 }
377
378 #[doc(alias = "InterestAtMaturity")]
380 pub fn interest_at_maturity(&self) -> Result<Option<Decimal>, InvalidValue> {
381 self.0.get_decimal(Tag(738))
382 }
383
384 #[doc(alias = "EndAccruedInterestAmt")]
386 pub fn end_accrued_interest_amt(&self) -> Result<Option<Decimal>, InvalidValue> {
387 self.0.get_decimal(Tag(920))
388 }
389
390 #[doc(alias = "StartCash")]
392 pub fn start_cash(&self) -> Result<Option<Decimal>, InvalidValue> {
393 self.0.get_decimal(Tag(921))
394 }
395
396 #[doc(alias = "EndCash")]
398 pub fn end_cash(&self) -> Result<Option<Decimal>, InvalidValue> {
399 self.0.get_decimal(Tag(922))
400 }
401
402 #[doc(alias = "LegalConfirm")]
404 pub fn legal_confirm(&self) -> Result<Option<bool>, InvalidValue> {
405 self.0.get_bool(Tag(650))
406 }
407
408 #[doc(alias = "NoStipulations")]
410 pub fn stipulations(&self) -> Result<Instances<'_, Stipulations<'_>>, InvalidValue> {
411 self.0.get_group(&Stipulations::TABLE, &Self::known_tags().get()).map(Instances::from)
412 }
413
414 pub fn yield_data(&self) -> YieldData<'_> {
416 YieldData(self.0.scope())
417 }
418
419 #[doc(alias = "TotNoAllocs")]
421 pub fn tot_no_allocs(&self) -> Result<Option<i64>, InvalidValue> {
422 self.0.get_int(Tag(892))
423 }
424
425 #[doc(alias = "LastFragment")]
427 pub fn last_fragment(&self) -> Result<Option<bool>, InvalidValue> {
428 self.0.get_bool(Tag(893))
429 }
430
431 #[doc(alias = "NoAllocs")]
433 pub fn allocs(&self) -> Result<Instances<'_, AllocGrp<'_>>, InvalidValue> {
434 self.0.get_group(&AllocGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
435 }
436}
437
438impl std::fmt::Debug for AllocationInstruction {
439 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
440 write!(f, "AllocationInstruction({})", self.0)
441 }
442}
443
444impl std::fmt::Display for AllocationInstruction {
445 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
446 std::fmt::Display::fmt(&self.0, f)
447 }
448}