use crate::{
pretty::px_to_f64, record::c_chars_to_str, InstrumentClass, InstrumentDefRec, Result, Side,
UserDefinedInstrument,
};
use super::*;
impl InstrumentDefMsg {
pub fn trading_reference_price_f64(&self) -> f64 {
px_to_f64(self.trading_reference_price)
}
pub fn currency(&self) -> crate::Result<&str> {
c_chars_to_str(&self.currency)
}
pub fn settl_currency(&self) -> crate::Result<&str> {
c_chars_to_str(&self.settl_currency)
}
pub fn secsubtype(&self) -> crate::Result<&str> {
c_chars_to_str(&self.secsubtype)
}
pub fn group(&self) -> crate::Result<&str> {
c_chars_to_str(&self.group)
}
pub fn exchange(&self) -> crate::Result<&str> {
c_chars_to_str(&self.exchange)
}
pub fn asset(&self) -> crate::Result<&str> {
c_chars_to_str(&self.asset)
}
pub fn cfi(&self) -> crate::Result<&str> {
c_chars_to_str(&self.cfi)
}
pub fn security_type(&self) -> crate::Result<&str> {
c_chars_to_str(&self.security_type)
}
pub fn unit_of_measure(&self) -> crate::Result<&str> {
c_chars_to_str(&self.unit_of_measure)
}
pub fn underlying(&self) -> crate::Result<&str> {
c_chars_to_str(&self.underlying)
}
pub fn strike_price_currency(&self) -> crate::Result<&str> {
c_chars_to_str(&self.strike_price_currency)
}
}
impl InstrumentDefRec for InstrumentDefMsg {
fn raw_ts_recv(&self) -> u64 {
self.ts_recv
}
fn min_price_increment(&self) -> i64 {
self.min_price_increment
}
fn display_factor(&self) -> i64 {
self.display_factor
}
fn raw_instrument_id(&self) -> u64 {
u64::from(self.raw_instrument_id)
}
fn min_lot_size_round_lot(&self) -> i32 {
self.min_lot_size_round_lot
}
fn raw_security_update_action(&self) -> c_char {
self.security_update_action
}
fn raw_instrument_class(&self) -> c_char {
self.instrument_class
}
fn raw_match_algorithm(&self) -> c_char {
self.match_algorithm
}
fn channel_id(&self) -> u8 {
u8::try_from(self.channel_id).unwrap_or(u8::MAX)
}
fn raw_symbol(&self) -> Result<&str> {
c_chars_to_str(&self.raw_symbol)
}
fn raw_expiration(&self) -> Option<u64> {
Some(self.expiration)
}
fn raw_activation(&self) -> Option<u64> {
Some(self.activation)
}
fn high_limit_price(&self) -> Option<i64> {
Some(self.high_limit_price)
}
fn low_limit_price(&self) -> Option<i64> {
Some(self.low_limit_price)
}
fn max_price_variation(&self) -> Option<i64> {
Some(self.max_price_variation)
}
fn unit_of_measure_qty(&self) -> Option<i64> {
Some(self.unit_of_measure_qty)
}
fn min_price_increment_amount(&self) -> Option<i64> {
Some(self.min_price_increment_amount)
}
fn price_ratio(&self) -> Option<i64> {
Some(self.price_ratio)
}
fn strike_price(&self) -> Option<i64> {
Some(self.strike_price)
}
fn leg_price(&self) -> Option<i64> {
None
}
fn leg_delta(&self) -> Option<i64> {
None
}
fn user_defined_instrument(&self) -> Result<Option<UserDefinedInstrument>> {
Ok(Some(self.user_defined_instrument))
}
fn leg_instrument_class(&self) -> Result<Option<InstrumentClass>> {
Ok(None)
}
fn leg_side(&self) -> Result<Option<Side>> {
Ok(None)
}
}