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, LegQuotGrp, OrderQtyData, Parties, QuotQualGrp,
10 SpreadOrBenchmarkCurveData, Stipulations, Trailer, UndInstrmtGrp, YieldData,
11};
12use super::super::enums::{
13 AccountType, AcctIDSource, CommType, CustOrderCapacity, OrdType, OrderCapacity, PriceType,
14 QuoteResponseLevel, QuoteType, SettlCurrFxRateCalc, SettlType, Side,
15};
16
17pub struct Quote(RawMessage);
19
20impl Quote {
21 pub const MSG_TYPE: &[u8] = b"S";
22
23 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
24 static TAGS: LazyKnownTags = LazyKnownTags::new(
25 &[
26 Tag(131), Tag(117), Tag(693), Tag(537), Tag(735), Tag(301), Tag(453), Tag(336),
27 Tag(625), Tag(711), Tag(54), Tag(63), Tag(64), Tag(193), Tag(192), Tag(15),
28 Tag(232), Tag(1), Tag(660), Tag(581), Tag(555), Tag(132), Tag(133), Tag(645),
29 Tag(646), Tag(647), Tag(134), Tag(648), Tag(135), Tag(62), Tag(188), Tag(190),
30 Tag(189), Tag(191), Tag(631), Tag(632), Tag(633), Tag(634), Tag(60), Tag(40),
31 Tag(642), Tag(643), Tag(656), Tag(657), Tag(156), Tag(13), Tag(12), Tag(582),
32 Tag(100), Tag(528), Tag(423), Tag(58), Tag(354), Tag(355),
33 ],
34 &[
35 Header::known_tags(), Trailer::known_tags(), QuotQualGrp::known_tags(),
36 Parties::known_tags(), Instrument::known_tags(), FinancingDetails::known_tags(),
37 UndInstrmtGrp::known_tags(), OrderQtyData::known_tags(), Stipulations::known_tags(),
38 LegQuotGrp::known_tags(), SpreadOrBenchmarkCurveData::known_tags(),
39 YieldData::known_tags(),
40 ],
41 );
42 &TAGS
43 }
44
45 pub fn from_raw(raw: RawMessage) -> Self {
46 Self(raw)
47 }
48
49 pub fn raw(&self) -> &RawMessage {
50 &self.0
51 }
52
53 pub fn header(&self) -> Header<'_> {
54 Header(self.0.scope(), Self::known_tags().get())
55 }
56
57 pub fn trailer(&self) -> Trailer<'_> {
58 Trailer(self.0.scope())
59 }
60
61 #[doc(alias = "QuoteReqID")]
63 pub fn quote_req_id(&self) -> Result<Option<&str>, InvalidValue> {
64 self.0.get_str(Tag(131))
65 }
66
67 #[doc(alias = "QuoteID")]
69 pub fn quote_id(&self) -> Result<Option<&str>, InvalidValue> {
70 self.0.get_str(Tag(117))
71 }
72
73 #[doc(alias = "QuoteRespID")]
75 pub fn quote_resp_id(&self) -> Result<Option<&str>, InvalidValue> {
76 self.0.get_str(Tag(693))
77 }
78
79 #[doc(alias = "QuoteType")]
81 pub fn quote_type(&self) -> Result<Option<QuoteType>, InvalidValue> {
82 Ok(self.0.get_int(Tag(537))?.map(QuoteType::from_value))
83 }
84
85 #[doc(alias = "NoQuoteQualifiers")]
87 pub fn quote_qualifiers(&self) -> Result<Instances<'_, QuotQualGrp<'_>>, InvalidValue> {
88 self.0.get_group(&QuotQualGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
89 }
90
91 #[doc(alias = "QuoteResponseLevel")]
93 pub fn quote_response_level(&self) -> Result<Option<QuoteResponseLevel>, InvalidValue> {
94 Ok(self.0.get_int(Tag(301))?.map(QuoteResponseLevel::from_value))
95 }
96
97 #[doc(alias = "NoPartyIDs")]
99 pub fn party_ids(&self) -> Result<Instances<'_, Parties<'_>>, InvalidValue> {
100 self.0.get_group(&Parties::TABLE, &Self::known_tags().get()).map(Instances::from)
101 }
102
103 #[doc(alias = "TradingSessionID")]
105 pub fn trading_session_id(&self) -> Result<Option<&str>, InvalidValue> {
106 self.0.get_str(Tag(336))
107 }
108
109 #[doc(alias = "TradingSessionSubID")]
111 pub fn trading_session_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
112 self.0.get_str(Tag(625))
113 }
114
115 pub fn instrument(&self) -> Instrument<'_> {
117 Instrument(self.0.scope(), Self::known_tags().get())
118 }
119
120 pub fn financing_details(&self) -> FinancingDetails<'_> {
122 FinancingDetails(self.0.scope())
123 }
124
125 #[doc(alias = "NoUnderlyings")]
127 pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
128 self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
129 }
130
131 #[doc(alias = "Side")]
133 pub fn side(&self) -> Result<Option<Side<'_>>, InvalidValue> {
134 Ok(self.0.get_str(Tag(54))?.map(Side::from_value))
135 }
136
137 pub fn order_qty_data(&self) -> OrderQtyData<'_> {
139 OrderQtyData(self.0.scope())
140 }
141
142 #[doc(alias = "SettlType")]
144 pub fn settl_type(&self) -> Result<Option<SettlType<'_>>, InvalidValue> {
145 Ok(self.0.get_str(Tag(63))?.map(SettlType::from_value))
146 }
147
148 #[doc(alias = "SettlDate")]
150 pub fn settl_date(&self) -> Result<Option<Date>, InvalidValue> {
151 self.0.get_date(Tag(64))
152 }
153
154 #[doc(alias = "SettlDate2")]
156 pub fn settl_date2(&self) -> Result<Option<Date>, InvalidValue> {
157 self.0.get_date(Tag(193))
158 }
159
160 #[doc(alias = "OrderQty2")]
162 pub fn order_qty2(&self) -> Result<Option<Decimal>, InvalidValue> {
163 self.0.get_decimal(Tag(192))
164 }
165
166 #[doc(alias = "Currency")]
168 pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
169 self.0.get_str(Tag(15))
170 }
171
172 #[doc(alias = "NoStipulations")]
174 pub fn stipulations(&self) -> Result<Instances<'_, Stipulations<'_>>, InvalidValue> {
175 self.0.get_group(&Stipulations::TABLE, &Self::known_tags().get()).map(Instances::from)
176 }
177
178 #[doc(alias = "Account")]
180 pub fn account(&self) -> Result<Option<&str>, InvalidValue> {
181 self.0.get_str(Tag(1))
182 }
183
184 #[doc(alias = "AcctIDSource")]
186 pub fn acct_id_source(&self) -> Result<Option<AcctIDSource>, InvalidValue> {
187 Ok(self.0.get_int(Tag(660))?.map(AcctIDSource::from_value))
188 }
189
190 #[doc(alias = "AccountType")]
192 pub fn account_type(&self) -> Result<Option<AccountType>, InvalidValue> {
193 Ok(self.0.get_int(Tag(581))?.map(AccountType::from_value))
194 }
195
196 #[doc(alias = "NoLegs")]
198 pub fn legs(&self) -> Result<Instances<'_, LegQuotGrp<'_>>, InvalidValue> {
199 self.0.get_group(&LegQuotGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
200 }
201
202 #[doc(alias = "BidPx")]
204 pub fn bid_px(&self) -> Result<Option<Decimal>, InvalidValue> {
205 self.0.get_decimal(Tag(132))
206 }
207
208 #[doc(alias = "OfferPx")]
210 pub fn offer_px(&self) -> Result<Option<Decimal>, InvalidValue> {
211 self.0.get_decimal(Tag(133))
212 }
213
214 #[doc(alias = "MktBidPx")]
216 pub fn mkt_bid_px(&self) -> Result<Option<Decimal>, InvalidValue> {
217 self.0.get_decimal(Tag(645))
218 }
219
220 #[doc(alias = "MktOfferPx")]
222 pub fn mkt_offer_px(&self) -> Result<Option<Decimal>, InvalidValue> {
223 self.0.get_decimal(Tag(646))
224 }
225
226 #[doc(alias = "MinBidSize")]
228 pub fn min_bid_size(&self) -> Result<Option<Decimal>, InvalidValue> {
229 self.0.get_decimal(Tag(647))
230 }
231
232 #[doc(alias = "BidSize")]
234 pub fn bid_size(&self) -> Result<Option<Decimal>, InvalidValue> {
235 self.0.get_decimal(Tag(134))
236 }
237
238 #[doc(alias = "MinOfferSize")]
240 pub fn min_offer_size(&self) -> Result<Option<Decimal>, InvalidValue> {
241 self.0.get_decimal(Tag(648))
242 }
243
244 #[doc(alias = "OfferSize")]
246 pub fn offer_size(&self) -> Result<Option<Decimal>, InvalidValue> {
247 self.0.get_decimal(Tag(135))
248 }
249
250 #[doc(alias = "ValidUntilTime")]
252 pub fn valid_until_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
253 self.0.get_utc_timestamp(Tag(62))
254 }
255
256 #[doc(alias = "BidSpotRate")]
258 pub fn bid_spot_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
259 self.0.get_decimal(Tag(188))
260 }
261
262 #[doc(alias = "OfferSpotRate")]
264 pub fn offer_spot_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
265 self.0.get_decimal(Tag(190))
266 }
267
268 #[doc(alias = "BidForwardPoints")]
270 pub fn bid_forward_points(&self) -> Result<Option<Decimal>, InvalidValue> {
271 self.0.get_decimal(Tag(189))
272 }
273
274 #[doc(alias = "OfferForwardPoints")]
276 pub fn offer_forward_points(&self) -> Result<Option<Decimal>, InvalidValue> {
277 self.0.get_decimal(Tag(191))
278 }
279
280 #[doc(alias = "MidPx")]
282 pub fn mid_px(&self) -> Result<Option<Decimal>, InvalidValue> {
283 self.0.get_decimal(Tag(631))
284 }
285
286 #[doc(alias = "BidYield")]
288 pub fn bid_yield(&self) -> Result<Option<Decimal>, InvalidValue> {
289 self.0.get_decimal(Tag(632))
290 }
291
292 #[doc(alias = "MidYield")]
294 pub fn mid_yield(&self) -> Result<Option<Decimal>, InvalidValue> {
295 self.0.get_decimal(Tag(633))
296 }
297
298 #[doc(alias = "OfferYield")]
300 pub fn offer_yield(&self) -> Result<Option<Decimal>, InvalidValue> {
301 self.0.get_decimal(Tag(634))
302 }
303
304 #[doc(alias = "TransactTime")]
306 pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
307 self.0.get_utc_timestamp(Tag(60))
308 }
309
310 #[doc(alias = "OrdType")]
312 pub fn ord_type(&self) -> Result<Option<OrdType<'_>>, InvalidValue> {
313 Ok(self.0.get_str(Tag(40))?.map(OrdType::from_value))
314 }
315
316 #[doc(alias = "BidForwardPoints2")]
318 pub fn bid_forward_points2(&self) -> Result<Option<Decimal>, InvalidValue> {
319 self.0.get_decimal(Tag(642))
320 }
321
322 #[doc(alias = "OfferForwardPoints2")]
324 pub fn offer_forward_points2(&self) -> Result<Option<Decimal>, InvalidValue> {
325 self.0.get_decimal(Tag(643))
326 }
327
328 #[doc(alias = "SettlCurrBidFxRate")]
330 pub fn settl_curr_bid_fx_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
331 self.0.get_decimal(Tag(656))
332 }
333
334 #[doc(alias = "SettlCurrOfferFxRate")]
336 pub fn settl_curr_offer_fx_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
337 self.0.get_decimal(Tag(657))
338 }
339
340 #[doc(alias = "SettlCurrFxRateCalc")]
342 pub fn settl_curr_fx_rate_calc(&self) -> Result<Option<SettlCurrFxRateCalc<'_>>, InvalidValue> {
343 Ok(self.0.get_str(Tag(156))?.map(SettlCurrFxRateCalc::from_value))
344 }
345
346 #[doc(alias = "CommType")]
348 pub fn comm_type(&self) -> Result<Option<CommType<'_>>, InvalidValue> {
349 Ok(self.0.get_str(Tag(13))?.map(CommType::from_value))
350 }
351
352 #[doc(alias = "Commission")]
354 pub fn commission(&self) -> Result<Option<Decimal>, InvalidValue> {
355 self.0.get_decimal(Tag(12))
356 }
357
358 #[doc(alias = "CustOrderCapacity")]
360 pub fn cust_order_capacity(&self) -> Result<Option<CustOrderCapacity>, InvalidValue> {
361 Ok(self.0.get_int(Tag(582))?.map(CustOrderCapacity::from_value))
362 }
363
364 #[doc(alias = "ExDestination")]
366 pub fn ex_destination(&self) -> Result<Option<&str>, InvalidValue> {
367 self.0.get_str(Tag(100))
368 }
369
370 #[doc(alias = "OrderCapacity")]
372 pub fn order_capacity(&self) -> Result<Option<OrderCapacity<'_>>, InvalidValue> {
373 Ok(self.0.get_str(Tag(528))?.map(OrderCapacity::from_value))
374 }
375
376 #[doc(alias = "PriceType")]
378 pub fn price_type(&self) -> Result<Option<PriceType>, InvalidValue> {
379 Ok(self.0.get_int(Tag(423))?.map(PriceType::from_value))
380 }
381
382 pub fn spread_or_benchmark_curve_data(&self) -> SpreadOrBenchmarkCurveData<'_> {
384 SpreadOrBenchmarkCurveData(self.0.scope())
385 }
386
387 pub fn yield_data(&self) -> YieldData<'_> {
389 YieldData(self.0.scope())
390 }
391
392 #[doc(alias = "Text")]
394 pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
395 self.0.get_str(Tag(58))
396 }
397
398 #[doc(alias = "EncodedTextLen")]
400 pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
401 self.0.get_int(Tag(354))
402 }
403
404 #[doc(alias = "EncodedText")]
406 pub fn encoded_text(&self) -> Option<&[u8]> {
407 self.0.get(Tag(355))
408 }
409}
410
411impl std::fmt::Debug for Quote {
412 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
413 write!(f, "Quote({})", self.0)
414 }
415}
416
417impl std::fmt::Display for Quote {
418 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
419 std::fmt::Display::fmt(&self.0, f)
420 }
421}