pub struct InstrumentSpec {
pub asset_class: AssetClass,
pub contract_value: f64,
pub tick_size: f64,
pub lot_size: f64,
pub min_notional: f64,
}Expand description
Exchange/asset metadata for one instrument.
Used by the framework to round prices/quantities to the venue’s increments,
enforce a minimum order notional, and apply class-aware rules. Adapters that
expose no metadata get a permissive default (see
ExchangeClient::instrument_spec),
which preserves today’s behaviour.
Fields§
§asset_class: AssetClassBroad asset class.
contract_value: f64Base-asset units per one contract (e.g. 0.001 BTC for XBTUSDTM);
1.0 for spot. Subsumes the older ExchangeClient::contract_value.
tick_size: f64Minimum price increment (tick). 0.0 ⇒ unknown / unconstrained.
lot_size: f64Minimum quantity increment (lot), in contracts. 0.0 ⇒ unknown;
futures are typically whole contracts (1.0).
min_notional: f64Minimum order notional in quote currency. 0.0 ⇒ no minimum.
Implementations§
Source§impl InstrumentSpec
impl InstrumentSpec
Sourcepub const fn spot_default() -> Self
pub const fn spot_default() -> Self
A permissive spot default: 1:1 contract value, no tick/lot/min-notional constraints. Appropriate when an adapter exposes no metadata.
Sourcepub const fn from_contract_value(contract_value: f64) -> Self
pub const fn from_contract_value(contract_value: f64) -> Self
A futures-contract spec from a known contract_value, with no other
constraints. Backs the blanket ExchangeClient::instrument_spec
default so an adapter that only overrides contract_value still gets a
correct (if minimal) spec.
Sourcepub fn round_price(&self, price: f64) -> f64
pub fn round_price(&self, price: f64) -> f64
Round a price to the nearest valid tick. No-op when tick_size <= 0.
Sourcepub fn round_qty_down(&self, qty: f64) -> f64
pub fn round_qty_down(&self, qty: f64) -> f64
Round a quantity down to the nearest valid lot — down so a sized
order never exceeds the intended risk. No-op when lot_size <= 0.
Sourcepub fn meets_min_notional(&self, notional: f64) -> bool
pub fn meets_min_notional(&self, notional: f64) -> bool
Does notional (quote currency) meet the minimum order notional?
Always true when min_notional is 0.0.
Trait Implementations§
Source§impl Clone for InstrumentSpec
impl Clone for InstrumentSpec
Source§fn clone(&self) -> InstrumentSpec
fn clone(&self) -> InstrumentSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for InstrumentSpec
Source§impl Debug for InstrumentSpec
impl Debug for InstrumentSpec
Source§impl Default for InstrumentSpec
impl Default for InstrumentSpec
Source§impl<'de> Deserialize<'de> for InstrumentSpec
impl<'de> Deserialize<'de> for InstrumentSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for InstrumentSpec
impl PartialEq for InstrumentSpec
Source§fn eq(&self, other: &InstrumentSpec) -> bool
fn eq(&self, other: &InstrumentSpec) -> bool
self and other values to be equal, and is used by ==.