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 FinancingDetails, Header, Instrument, OrderQtyData, PositionAmountData,
10 SpreadOrBenchmarkCurveData, Trailer, TrdCapRptSideGrp, TrdInstrmtLegGrp, TrdRegTimestamps,
11 UndInstrmtGrp, YieldData,
12};
13use super::super::enums::{
14 AvgPxIndicator, ExecRestatementReason, ExecType, MatchStatus, MatchType, MultiLegReportingType,
15 OrdStatus, PriceType, QtyType, SettlType, ShortSaleReason, SubscriptionRequestType,
16 TradeReportType, TrdType,
17};
18
19pub struct TradeCaptureReport(RawMessage);
21
22impl TradeCaptureReport {
23 pub const MSG_TYPE: &[u8] = b"AE";
24
25 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
26 static TAGS: LazyKnownTags = LazyKnownTags::new(
27 &[
28 Tag(571), Tag(487), Tag(856), Tag(568), Tag(828), Tag(829), Tag(855), Tag(830),
29 Tag(150), Tag(748), Tag(912), Tag(325), Tag(263), Tag(572), Tag(881), Tag(818),
30 Tag(820), Tag(880), Tag(17), Tag(39), Tag(527), Tag(378), Tag(570), Tag(423),
31 Tag(854), Tag(711), Tag(822), Tag(823), Tag(32), Tag(31), Tag(669), Tag(194),
32 Tag(195), Tag(30), Tag(75), Tag(715), Tag(6), Tag(819), Tag(753), Tag(442),
33 Tag(824), Tag(555), Tag(60), Tag(768), Tag(63), Tag(64), Tag(573), Tag(574),
34 Tag(552), Tag(797), Tag(852), Tag(853),
35 ],
36 &[
37 Header::known_tags(), Trailer::known_tags(), Instrument::known_tags(),
38 FinancingDetails::known_tags(), OrderQtyData::known_tags(), YieldData::known_tags(),
39 UndInstrmtGrp::known_tags(), SpreadOrBenchmarkCurveData::known_tags(),
40 PositionAmountData::known_tags(), TrdInstrmtLegGrp::known_tags(),
41 TrdRegTimestamps::known_tags(), TrdCapRptSideGrp::known_tags(),
42 ],
43 );
44 &TAGS
45 }
46
47 pub fn from_raw(raw: RawMessage) -> Self {
48 Self(raw)
49 }
50
51 pub fn raw(&self) -> &RawMessage {
52 &self.0
53 }
54
55 pub fn header(&self) -> Header<'_> {
56 Header(self.0.scope(), Self::known_tags().get())
57 }
58
59 pub fn trailer(&self) -> Trailer<'_> {
60 Trailer(self.0.scope())
61 }
62
63 #[doc(alias = "TradeReportID")]
65 pub fn trade_report_id(&self) -> Result<Option<&str>, InvalidValue> {
66 self.0.get_str(Tag(571))
67 }
68
69 #[doc(alias = "TradeReportTransType")]
71 pub fn trade_report_trans_type(&self) -> Result<Option<i64>, InvalidValue> {
72 self.0.get_int(Tag(487))
73 }
74
75 #[doc(alias = "TradeReportType")]
77 pub fn trade_report_type(&self) -> Result<Option<TradeReportType>, InvalidValue> {
78 Ok(self.0.get_int(Tag(856))?.map(TradeReportType::from_value))
79 }
80
81 #[doc(alias = "TradeRequestID")]
83 pub fn trade_request_id(&self) -> Result<Option<&str>, InvalidValue> {
84 self.0.get_str(Tag(568))
85 }
86
87 #[doc(alias = "TrdType")]
89 pub fn trd_type(&self) -> Result<Option<TrdType>, InvalidValue> {
90 Ok(self.0.get_int(Tag(828))?.map(TrdType::from_value))
91 }
92
93 #[doc(alias = "TrdSubType")]
95 pub fn trd_sub_type(&self) -> Result<Option<i64>, InvalidValue> {
96 self.0.get_int(Tag(829))
97 }
98
99 #[doc(alias = "SecondaryTrdType")]
101 pub fn secondary_trd_type(&self) -> Result<Option<i64>, InvalidValue> {
102 self.0.get_int(Tag(855))
103 }
104
105 #[doc(alias = "TransferReason")]
107 pub fn transfer_reason(&self) -> Result<Option<&str>, InvalidValue> {
108 self.0.get_str(Tag(830))
109 }
110
111 #[doc(alias = "ExecType")]
113 pub fn exec_type(&self) -> Result<Option<ExecType<'_>>, InvalidValue> {
114 Ok(self.0.get_str(Tag(150))?.map(ExecType::from_value))
115 }
116
117 #[doc(alias = "TotNumTradeReports")]
119 pub fn tot_num_trade_reports(&self) -> Result<Option<i64>, InvalidValue> {
120 self.0.get_int(Tag(748))
121 }
122
123 #[doc(alias = "LastRptRequested")]
125 pub fn last_rpt_requested(&self) -> Result<Option<bool>, InvalidValue> {
126 self.0.get_bool(Tag(912))
127 }
128
129 #[doc(alias = "UnsolicitedIndicator")]
131 pub fn unsolicited_indicator(&self) -> Result<Option<bool>, InvalidValue> {
132 self.0.get_bool(Tag(325))
133 }
134
135 #[doc(alias = "SubscriptionRequestType")]
137 pub fn subscription_request_type(&self) -> Result<Option<SubscriptionRequestType<'_>>, InvalidValue> {
138 Ok(self.0.get_str(Tag(263))?.map(SubscriptionRequestType::from_value))
139 }
140
141 #[doc(alias = "TradeReportRefID")]
143 pub fn trade_report_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
144 self.0.get_str(Tag(572))
145 }
146
147 #[doc(alias = "SecondaryTradeReportRefID")]
149 pub fn secondary_trade_report_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
150 self.0.get_str(Tag(881))
151 }
152
153 #[doc(alias = "SecondaryTradeReportID")]
155 pub fn secondary_trade_report_id(&self) -> Result<Option<&str>, InvalidValue> {
156 self.0.get_str(Tag(818))
157 }
158
159 #[doc(alias = "TradeLinkID")]
161 pub fn trade_link_id(&self) -> Result<Option<&str>, InvalidValue> {
162 self.0.get_str(Tag(820))
163 }
164
165 #[doc(alias = "TrdMatchID")]
167 pub fn trd_match_id(&self) -> Result<Option<&str>, InvalidValue> {
168 self.0.get_str(Tag(880))
169 }
170
171 #[doc(alias = "ExecID")]
173 pub fn exec_id(&self) -> Result<Option<&str>, InvalidValue> {
174 self.0.get_str(Tag(17))
175 }
176
177 #[doc(alias = "OrdStatus")]
179 pub fn ord_status(&self) -> Result<Option<OrdStatus<'_>>, InvalidValue> {
180 Ok(self.0.get_str(Tag(39))?.map(OrdStatus::from_value))
181 }
182
183 #[doc(alias = "SecondaryExecID")]
185 pub fn secondary_exec_id(&self) -> Result<Option<&str>, InvalidValue> {
186 self.0.get_str(Tag(527))
187 }
188
189 #[doc(alias = "ExecRestatementReason")]
191 pub fn exec_restatement_reason(&self) -> Result<Option<ExecRestatementReason>, InvalidValue> {
192 Ok(self.0.get_int(Tag(378))?.map(ExecRestatementReason::from_value))
193 }
194
195 #[doc(alias = "PreviouslyReported")]
197 pub fn previously_reported(&self) -> Result<Option<bool>, InvalidValue> {
198 self.0.get_bool(Tag(570))
199 }
200
201 #[doc(alias = "PriceType")]
203 pub fn price_type(&self) -> Result<Option<PriceType>, InvalidValue> {
204 Ok(self.0.get_int(Tag(423))?.map(PriceType::from_value))
205 }
206
207 pub fn instrument(&self) -> Instrument<'_> {
209 Instrument(self.0.scope(), Self::known_tags().get())
210 }
211
212 pub fn financing_details(&self) -> FinancingDetails<'_> {
214 FinancingDetails(self.0.scope())
215 }
216
217 pub fn order_qty_data(&self) -> OrderQtyData<'_> {
219 OrderQtyData(self.0.scope())
220 }
221
222 #[doc(alias = "QtyType")]
224 pub fn qty_type(&self) -> Result<Option<QtyType>, InvalidValue> {
225 Ok(self.0.get_int(Tag(854))?.map(QtyType::from_value))
226 }
227
228 pub fn yield_data(&self) -> YieldData<'_> {
230 YieldData(self.0.scope())
231 }
232
233 #[doc(alias = "NoUnderlyings")]
235 pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
236 self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
237 }
238
239 #[doc(alias = "UnderlyingTradingSessionID")]
241 pub fn underlying_trading_session_id(&self) -> Result<Option<&str>, InvalidValue> {
242 self.0.get_str(Tag(822))
243 }
244
245 #[doc(alias = "UnderlyingTradingSessionSubID")]
247 pub fn underlying_trading_session_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
248 self.0.get_str(Tag(823))
249 }
250
251 #[doc(alias = "LastQty")]
253 pub fn last_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
254 self.0.get_decimal(Tag(32))
255 }
256
257 #[doc(alias = "LastPx")]
259 pub fn last_px(&self) -> Result<Option<Decimal>, InvalidValue> {
260 self.0.get_decimal(Tag(31))
261 }
262
263 #[doc(alias = "LastParPx")]
265 pub fn last_par_px(&self) -> Result<Option<Decimal>, InvalidValue> {
266 self.0.get_decimal(Tag(669))
267 }
268
269 #[doc(alias = "LastSpotRate")]
271 pub fn last_spot_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
272 self.0.get_decimal(Tag(194))
273 }
274
275 #[doc(alias = "LastForwardPoints")]
277 pub fn last_forward_points(&self) -> Result<Option<Decimal>, InvalidValue> {
278 self.0.get_decimal(Tag(195))
279 }
280
281 #[doc(alias = "LastMkt")]
283 pub fn last_mkt(&self) -> Result<Option<&str>, InvalidValue> {
284 self.0.get_str(Tag(30))
285 }
286
287 #[doc(alias = "TradeDate")]
289 pub fn trade_date(&self) -> Result<Option<Date>, InvalidValue> {
290 self.0.get_date(Tag(75))
291 }
292
293 #[doc(alias = "ClearingBusinessDate")]
295 pub fn clearing_business_date(&self) -> Result<Option<Date>, InvalidValue> {
296 self.0.get_date(Tag(715))
297 }
298
299 #[doc(alias = "AvgPx")]
301 pub fn avg_px(&self) -> Result<Option<Decimal>, InvalidValue> {
302 self.0.get_decimal(Tag(6))
303 }
304
305 pub fn spread_or_benchmark_curve_data(&self) -> SpreadOrBenchmarkCurveData<'_> {
307 SpreadOrBenchmarkCurveData(self.0.scope())
308 }
309
310 #[doc(alias = "AvgPxIndicator")]
312 pub fn avg_px_indicator(&self) -> Result<Option<AvgPxIndicator>, InvalidValue> {
313 Ok(self.0.get_int(Tag(819))?.map(AvgPxIndicator::from_value))
314 }
315
316 #[doc(alias = "NoPosAmt")]
318 pub fn pos_amt(&self) -> Result<Instances<'_, PositionAmountData<'_>>, InvalidValue> {
319 self.0.get_group(&PositionAmountData::TABLE, &Self::known_tags().get()).map(Instances::from)
320 }
321
322 #[doc(alias = "MultiLegReportingType")]
324 pub fn multi_leg_reporting_type(&self) -> Result<Option<MultiLegReportingType<'_>>, InvalidValue> {
325 Ok(self.0.get_str(Tag(442))?.map(MultiLegReportingType::from_value))
326 }
327
328 #[doc(alias = "TradeLegRefID")]
330 pub fn trade_leg_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
331 self.0.get_str(Tag(824))
332 }
333
334 #[doc(alias = "NoLegs")]
336 pub fn legs(&self) -> Result<Instances<'_, TrdInstrmtLegGrp<'_>>, InvalidValue> {
337 self.0.get_group(&TrdInstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
338 }
339
340 #[doc(alias = "TransactTime")]
342 pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
343 self.0.get_utc_timestamp(Tag(60))
344 }
345
346 #[doc(alias = "NoTrdRegTimestamps")]
348 pub fn trd_reg_timestamps(&self) -> Result<Instances<'_, TrdRegTimestamps<'_>>, InvalidValue> {
349 self.0.get_group(&TrdRegTimestamps::TABLE, &Self::known_tags().get()).map(Instances::from)
350 }
351
352 #[doc(alias = "SettlType")]
354 pub fn settl_type(&self) -> Result<Option<SettlType<'_>>, InvalidValue> {
355 Ok(self.0.get_str(Tag(63))?.map(SettlType::from_value))
356 }
357
358 #[doc(alias = "SettlDate")]
360 pub fn settl_date(&self) -> Result<Option<Date>, InvalidValue> {
361 self.0.get_date(Tag(64))
362 }
363
364 #[doc(alias = "MatchStatus")]
366 pub fn match_status(&self) -> Result<Option<MatchStatus<'_>>, InvalidValue> {
367 Ok(self.0.get_str(Tag(573))?.map(MatchStatus::from_value))
368 }
369
370 #[doc(alias = "MatchType")]
372 pub fn match_type(&self) -> Result<Option<MatchType<'_>>, InvalidValue> {
373 Ok(self.0.get_str(Tag(574))?.map(MatchType::from_value))
374 }
375
376 #[doc(alias = "NoSides")]
378 pub fn sides(&self) -> Result<Instances<'_, TrdCapRptSideGrp<'_>>, InvalidValue> {
379 self.0.get_group(&TrdCapRptSideGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
380 }
381
382 #[doc(alias = "CopyMsgIndicator")]
384 pub fn copy_msg_indicator(&self) -> Result<Option<bool>, InvalidValue> {
385 self.0.get_bool(Tag(797))
386 }
387
388 #[doc(alias = "PublishTrdIndicator")]
390 pub fn publish_trd_indicator(&self) -> Result<Option<bool>, InvalidValue> {
391 self.0.get_bool(Tag(852))
392 }
393
394 #[doc(alias = "ShortSaleReason")]
396 pub fn short_sale_reason(&self) -> Result<Option<ShortSaleReason>, InvalidValue> {
397 Ok(self.0.get_int(Tag(853))?.map(ShortSaleReason::from_value))
398 }
399}
400
401impl std::fmt::Debug for TradeCaptureReport {
402 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
403 write!(f, "TradeCaptureReport({})", self.0)
404 }
405}
406
407impl std::fmt::Display for TradeCaptureReport {
408 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
409 std::fmt::Display::fmt(&self.0, f)
410 }
411}