Skip to main content

Instrument

Trait Instrument 

Source
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§

Provided Methods§

Source

fn tick_scheme(&self) -> Option<Ustr>

Source

fn tick_scheme_rule(&self) -> Option<&dyn TickSchemeRule>

Source

fn into_any(self) -> InstrumentAny
where Self: Sized, InstrumentAny: From<Self>,

Source

fn symbol(&self) -> Symbol

Source

fn venue(&self) -> Venue

Source

fn cost_currency(&self) -> Currency

§Panics

Panics if the instrument is inverse and does not have a base currency.

Source

fn strategy_type(&self) -> Option<Ustr>

Source

fn has_expiration(&self) -> bool

Source

fn allows_negative_price(&self) -> bool

Source

fn is_quanto(&self) -> bool

Source

fn margin_init(&self) -> Decimal

Source

fn margin_maint(&self) -> Decimal

Source

fn maker_fee(&self) -> Decimal

Source

fn taker_fee(&self) -> Decimal

Source

fn min_price_increment_precision(&self) -> u8

Source

fn min_size_increment_precision(&self) -> u8

Source

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.

Source

fn make_price(&self, value: f64) -> Price

§Panics

Panics if the value cannot be converted to a Price (see try_make_price).

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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).

Source

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.

Source

fn next_bid_price(&self, value: f64, n: i32) -> Option<Price>

Source

fn next_ask_price(&self, value: f64, n: i32) -> Option<Price>

Source

fn next_bid_prices(&self, value: f64, n: usize) -> Vec<Price>

Source

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".

Implementors§