#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Date, Decimal, InvalidValue, MonthYear, RawMessage, Tag, UtcTimestamp};
use super::super::components::{Header, Trailer};
use super::super::enums::{IDSource, OrdType, PutOrCall, QuoteResponseLevel, SecurityType};
pub struct Quote(RawMessage);
impl Quote {
pub const MSG_TYPE: &[u8] = b"S";
pub fn from_raw(raw: RawMessage) -> Self {
Self(raw)
}
pub fn raw(&self) -> &RawMessage {
&self.0
}
pub fn header(&self) -> Header<'_> {
Header(self.0.scope())
}
pub fn trailer(&self) -> Trailer<'_> {
Trailer(self.0.scope())
}
#[doc(alias = "QuoteReqID")]
pub fn quote_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(131))
}
#[doc(alias = "QuoteID")]
pub fn quote_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(117))
}
#[doc(alias = "QuoteResponseLevel")]
pub fn quote_response_level(&self) -> Result<Option<QuoteResponseLevel>, InvalidValue> {
Ok(self.0.get_int(Tag(301))?.map(QuoteResponseLevel::from_value))
}
#[doc(alias = "TradingSessionID")]
pub fn trading_session_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(336))
}
#[doc(alias = "Symbol")]
pub fn symbol(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(55))
}
#[doc(alias = "SymbolSfx")]
pub fn symbol_sfx(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(65))
}
#[doc(alias = "SecurityID")]
pub fn security_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(48))
}
#[doc(alias = "IDSource")]
pub fn id_source(&self) -> Result<Option<IDSource<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(22))?.map(IDSource::from_value))
}
#[doc(alias = "SecurityType")]
pub fn security_type(&self) -> Result<Option<SecurityType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(167))?.map(SecurityType::from_value))
}
#[doc(alias = "MaturityMonthYear")]
pub fn maturity_month_year(&self) -> Result<Option<MonthYear>, InvalidValue> {
self.0.get_month_year(Tag(200))
}
#[doc(alias = "MaturityDay")]
pub fn maturity_day(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(205))
}
#[doc(alias = "PutOrCall")]
pub fn put_or_call(&self) -> Result<Option<PutOrCall>, InvalidValue> {
Ok(self.0.get_int(Tag(201))?.map(PutOrCall::from_value))
}
#[doc(alias = "StrikePrice")]
pub fn strike_price(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(202))
}
#[doc(alias = "OptAttribute")]
pub fn opt_attribute(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(206))
}
#[doc(alias = "ContractMultiplier")]
pub fn contract_multiplier(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(231))
}
#[doc(alias = "CouponRate")]
pub fn coupon_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(223))
}
#[doc(alias = "SecurityExchange")]
pub fn security_exchange(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(207))
}
#[doc(alias = "Issuer")]
pub fn issuer(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(106))
}
#[doc(alias = "EncodedIssuerLen")]
pub fn encoded_issuer_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(348))
}
#[doc(alias = "EncodedIssuer")]
pub fn encoded_issuer(&self) -> Option<&[u8]> {
self.0.get(Tag(349))
}
#[doc(alias = "SecurityDesc")]
pub fn security_desc(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(107))
}
#[doc(alias = "EncodedSecurityDescLen")]
pub fn encoded_security_desc_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(350))
}
#[doc(alias = "EncodedSecurityDesc")]
pub fn encoded_security_desc(&self) -> Option<&[u8]> {
self.0.get(Tag(351))
}
#[doc(alias = "BidPx")]
pub fn bid_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(132))
}
#[doc(alias = "OfferPx")]
pub fn offer_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(133))
}
#[doc(alias = "BidSize")]
pub fn bid_size(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(134))
}
#[doc(alias = "OfferSize")]
pub fn offer_size(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(135))
}
#[doc(alias = "ValidUntilTime")]
pub fn valid_until_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(62))
}
#[doc(alias = "BidSpotRate")]
pub fn bid_spot_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(188))
}
#[doc(alias = "OfferSpotRate")]
pub fn offer_spot_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(190))
}
#[doc(alias = "BidForwardPoints")]
pub fn bid_forward_points(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(189))
}
#[doc(alias = "OfferForwardPoints")]
pub fn offer_forward_points(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(191))
}
#[doc(alias = "TransactTime")]
pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(60))
}
#[doc(alias = "FutSettDate")]
pub fn fut_sett_date(&self) -> Result<Option<Date>, InvalidValue> {
self.0.get_date(Tag(64))
}
#[doc(alias = "OrdType")]
pub fn ord_type(&self) -> Result<Option<OrdType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(40))?.map(OrdType::from_value))
}
#[doc(alias = "FutSettDate2")]
pub fn fut_sett_date2(&self) -> Result<Option<Date>, InvalidValue> {
self.0.get_date(Tag(193))
}
#[doc(alias = "OrderQty2")]
pub fn order_qty2(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(192))
}
#[doc(alias = "Currency")]
pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(15))
}
}
impl std::fmt::Debug for Quote {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Quote({})", self.0)
}
}
impl std::fmt::Display for Quote {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}