pub trait Instrument: 'static + Send {
Show 58 methods
// Required methods
fn id(&self) -> InstrumentId;
fn raw_symbol(&self) -> Symbol;
fn asset_class(&self) -> AssetClass;
fn instrument_class(&self) -> InstrumentClass;
fn underlying(&self) -> Option<Ustr>;
fn base_currency(&self) -> Option<Currency>;
fn quote_currency(&self) -> Currency;
fn settlement_currency(&self) -> Currency;
fn isin(&self) -> Option<Ustr>;
fn option_kind(&self) -> Option<OptionKind>;
fn exchange(&self) -> Option<Ustr>;
fn strike_price(&self) -> Option<Price>;
fn activation_ns(&self) -> Option<UnixNanos>;
fn expiration_ns(&self) -> Option<UnixNanos>;
fn is_inverse(&self) -> bool;
fn price_precision(&self) -> u8;
fn size_precision(&self) -> u8;
fn price_increment(&self) -> Price;
fn size_increment(&self) -> Quantity;
fn multiplier(&self) -> Quantity;
fn lot_size(&self) -> Option<Quantity>;
fn max_quantity(&self) -> Option<Quantity>;
fn min_quantity(&self) -> Option<Quantity>;
fn max_notional(&self) -> Option<Money>;
fn min_notional(&self) -> Option<Money>;
fn max_price(&self) -> Option<Price>;
fn min_price(&self) -> Option<Price>;
fn ts_event(&self) -> UnixNanos;
fn ts_init(&self) -> UnixNanos;
// Provided methods
fn tick_scheme(&self) -> Option<Ustr> { ... }
fn tick_scheme_rule(&self) -> Option<&dyn TickSchemeRule> { ... }
fn into_any(self) -> InstrumentAny
where Self: Sized,
InstrumentAny: From<Self> { ... }
fn symbol(&self) -> Symbol { ... }
fn venue(&self) -> Venue { ... }
fn cost_currency(&self) -> Currency { ... }
fn strategy_type(&self) -> Option<Ustr> { ... }
fn has_expiration(&self) -> bool { ... }
fn allows_negative_price(&self) -> bool { ... }
fn is_quanto(&self) -> bool { ... }
fn margin_init(&self) -> Decimal { ... }
fn margin_maint(&self) -> Decimal { ... }
fn maker_fee(&self) -> Decimal { ... }
fn taker_fee(&self) -> Decimal { ... }
fn min_price_increment_precision(&self) -> u8 { ... }
fn min_size_increment_precision(&self) -> u8 { ... }
fn try_make_price(&self, value: f64) -> Result<Price> { ... }
fn make_price(&self, value: f64) -> Price { ... }
fn try_normalize_price(&self, price: Price) -> CorrectnessResult<Price> { ... }
fn try_make_qty(
&self,
value: f64,
round_down: Option<bool>,
) -> Result<Quantity> { ... }
fn make_qty(&self, value: f64, round_down: Option<bool>) -> Quantity { ... }
fn try_normalize_qty(
&self,
quantity: Quantity,
) -> CorrectnessResult<Quantity> { ... }
fn try_calculate_base_quantity(
&self,
quantity: Quantity,
last_price: Price,
) -> Result<Quantity> { ... }
fn calculate_base_quantity(
&self,
quantity: Quantity,
last_price: Price,
) -> Quantity { ... }
fn calculate_notional_value(
&self,
quantity: Quantity,
price: Price,
use_quote_for_inverse: Option<bool>,
) -> Money { ... }
fn next_bid_price(&self, value: f64, n: i32) -> Option<Price> { ... }
fn next_ask_price(&self, value: f64, n: i32) -> Option<Price> { ... }
fn next_bid_prices(&self, value: f64, n: usize) -> Vec<Price> { ... }
fn next_ask_prices(&self, value: f64, n: usize) -> Vec<Price> { ... }
}Required Methods§
fn id(&self) -> InstrumentId
fn raw_symbol(&self) -> Symbol
fn asset_class(&self) -> AssetClass
fn instrument_class(&self) -> InstrumentClass
fn underlying(&self) -> Option<Ustr>
fn base_currency(&self) -> Option<Currency>
fn quote_currency(&self) -> Currency
fn settlement_currency(&self) -> Currency
fn isin(&self) -> Option<Ustr>
fn option_kind(&self) -> Option<OptionKind>
fn exchange(&self) -> Option<Ustr>
fn strike_price(&self) -> Option<Price>
fn activation_ns(&self) -> Option<UnixNanos>
fn expiration_ns(&self) -> Option<UnixNanos>
fn is_inverse(&self) -> bool
fn price_precision(&self) -> u8
fn size_precision(&self) -> u8
fn price_increment(&self) -> Price
fn size_increment(&self) -> Quantity
fn multiplier(&self) -> Quantity
fn lot_size(&self) -> Option<Quantity>
fn max_quantity(&self) -> Option<Quantity>
fn min_quantity(&self) -> Option<Quantity>
fn max_notional(&self) -> Option<Money>
fn min_notional(&self) -> Option<Money>
fn max_price(&self) -> Option<Price>
fn min_price(&self) -> Option<Price>
fn ts_event(&self) -> UnixNanos
fn ts_init(&self) -> UnixNanos
Provided Methods§
fn tick_scheme(&self) -> Option<Ustr>
fn tick_scheme_rule(&self) -> Option<&dyn TickSchemeRule>
fn into_any(self) -> InstrumentAny
fn symbol(&self) -> Symbol
fn venue(&self) -> Venue
Sourcefn cost_currency(&self) -> Currency
fn cost_currency(&self) -> Currency
§Panics
Panics if the instrument is inverse and does not have a base currency.
fn strategy_type(&self) -> Option<Ustr>
fn has_expiration(&self) -> bool
fn allows_negative_price(&self) -> bool
fn is_quanto(&self) -> bool
fn margin_init(&self) -> Decimal
fn margin_maint(&self) -> Decimal
fn maker_fee(&self) -> Decimal
fn taker_fee(&self) -> Decimal
fn min_price_increment_precision(&self) -> u8
fn min_size_increment_precision(&self) -> u8
Sourcefn try_make_price(&self, value: f64) -> Result<Price>
fn try_make_price(&self, value: f64) -> Result<Price>
§Errors
Returns an error if the value is not finite, not representable as a Decimal, or cannot
be converted to a Price.
Sourcefn make_price(&self, value: f64) -> Price
fn make_price(&self, value: f64) -> Price
§Panics
Panics if the value cannot be converted to a Price (see try_make_price).
Sourcefn try_normalize_price(&self, price: Price) -> CorrectnessResult<Price>
fn try_normalize_price(&self, price: Price) -> CorrectnessResult<Price>
Returns price rebuilt with the instrument precision when it is on the price grid.
§Errors
Returns an error when price is a sentinel value or would require rounding.
Sourcefn try_make_qty(&self, value: f64, round_down: Option<bool>) -> Result<Quantity>
fn try_make_qty(&self, value: f64, round_down: Option<bool>) -> Result<Quantity>
§Errors
Returns an error if the value is not finite, not representable as a Decimal, rounds to
zero, or cannot be converted to a Quantity.
Sourcefn make_qty(&self, value: f64, round_down: Option<bool>) -> Quantity
fn make_qty(&self, value: f64, round_down: Option<bool>) -> Quantity
§Panics
Panics if the value cannot be converted to a Quantity (see try_make_qty).
Sourcefn try_normalize_qty(&self, quantity: Quantity) -> CorrectnessResult<Quantity>
fn try_normalize_qty(&self, quantity: Quantity) -> CorrectnessResult<Quantity>
Returns quantity rebuilt with the instrument precision when it is on the size grid.
§Errors
Returns an error when quantity is undefined or would require rounding.
Sourcefn try_calculate_base_quantity(
&self,
quantity: Quantity,
last_price: Price,
) -> Result<Quantity>
fn try_calculate_base_quantity( &self, quantity: Quantity, last_price: Price, ) -> Result<Quantity>
§Errors
Returns an error if last_price is zero, or if the value cannot be converted to a
Quantity.
Sourcefn calculate_base_quantity(
&self,
quantity: Quantity,
last_price: Price,
) -> Quantity
fn calculate_base_quantity( &self, quantity: Quantity, last_price: Price, ) -> Quantity
§Panics
Panics if last_price is zero, or if the value cannot be converted to a Quantity
(see try_calculate_base_quantity).
Sourcefn calculate_notional_value(
&self,
quantity: Quantity,
price: Price,
use_quote_for_inverse: Option<bool>,
) -> Money
fn calculate_notional_value( &self, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, ) -> Money
§Panics
Panics if the instrument is inverse and does not have a base currency, if the
instrument is inverse and price is zero, or if the notional amount cannot be
represented as Money.
fn next_bid_price(&self, value: f64, n: i32) -> Option<Price>
fn next_ask_price(&self, value: f64, n: i32) -> Option<Price>
fn next_bid_prices(&self, value: f64, n: usize) -> Vec<Price>
fn next_ask_prices(&self, value: f64, n: usize) -> Vec<Price>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".