Struct exc_core::Instrument
source · pub struct Instrument { /* private fields */ }Expand description
Instrument.
Implementations§
source§impl Instrument
impl Instrument
sourcepub fn try_new(
symbol: &str,
base: &Asset,
quote: &Asset
) -> Result<Instrument, ParseSymbolError>
pub fn try_new( symbol: &str, base: &Asset, quote: &Asset ) -> Result<Instrument, ParseSymbolError>
Create a new instrument.
Return ParseSymbolError if the format of the symbol is not valid.
sourcepub fn spot(base: &Asset, quote: &Asset) -> Instrument
pub fn spot(base: &Asset, quote: &Asset) -> Instrument
Create a new spot.
sourcepub fn derivative(
prefix: &str,
symbol: &str,
base: &Asset,
quote: &Asset
) -> Result<Instrument, ParseSymbolError>
pub fn derivative( prefix: &str, symbol: &str, base: &Asset, quote: &Asset ) -> Result<Instrument, ParseSymbolError>
Create a new derivative.
Return ParseSymbolError if the prefix is not valid.
§Warning
User must make sure that inst1.symbol == inst2.symbol
only if inst1.base == inst2.base && inst1.quote == inst2.quote.
sourcepub fn to_reversed_spot(&self) -> Option<Instrument>
pub fn to_reversed_spot(&self) -> Option<Instrument>
Convert to the revsered spot.
Return None if it is not a spot.
sourcepub fn try_with_symbol(
symbol: Symbol,
base: &Asset,
quote: &Asset
) -> Result<Instrument, ParseSymbolError>
pub fn try_with_symbol( symbol: Symbol, base: &Asset, quote: &Asset ) -> Result<Instrument, ParseSymbolError>
Create a new instrument with the given symbol.
Return ParseSymbolError if the symbol does not match the given base or quote.
§Warning
User must make sure that inst1.symbol == inst2.symbol
only if inst1.base == inst2.base && inst1.quote == inst2.quote.
sourcepub fn prefer_reversed(self, reversed: bool) -> Instrument
pub fn prefer_reversed(self, reversed: bool) -> Instrument
Whether to mark this instrument as a reversed-prefering.
Default to false.
sourcepub fn is_prefer_reversed(&self) -> bool
pub fn is_prefer_reversed(&self) -> bool
Is this instrument reversed-prefering.
Default to false.
sourcepub fn is_derivative(&self) -> bool
pub fn is_derivative(&self) -> bool
Is derivative.
sourcepub fn position<T, P>(&self, position: P) -> Position<T>where
T: PositionNum,
P: IntoNaivePosition<T>,
pub fn position<T, P>(&self, position: P) -> Position<T>where
T: PositionNum,
P: IntoNaivePosition<T>,
Create a Position with the given position of this instrument.
Trait Implementations§
source§impl AsRef<Symbol> for Instrument
impl AsRef<Symbol> for Instrument
source§impl<'a> Borrow<Symbol> for &'a Instrument
impl<'a> Borrow<Symbol> for &'a Instrument
source§impl Borrow<Symbol> for Instrument
impl Borrow<Symbol> for Instrument
source§impl Clone for Instrument
impl Clone for Instrument
source§fn clone(&self) -> Instrument
fn clone(&self) -> Instrument
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Instrument
impl Debug for Instrument
source§impl<'de> Deserialize<'de> for Instrument
impl<'de> Deserialize<'de> for Instrument
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Instrument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Instrument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl Display for Instrument
impl Display for Instrument
source§impl Hash for Instrument
impl Hash for Instrument
source§impl Ord for Instrument
impl Ord for Instrument
source§fn cmp(&self, other: &Instrument) -> Ordering
fn cmp(&self, other: &Instrument) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<Symbol> for Instrument
impl PartialEq<Symbol> for Instrument
source§impl PartialEq for Instrument
impl PartialEq for Instrument
source§fn eq(&self, other: &Instrument) -> bool
fn eq(&self, other: &Instrument) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for Instrument
impl PartialOrd for Instrument
source§fn partial_cmp(&self, other: &Instrument) -> Option<Ordering>
fn partial_cmp(&self, other: &Instrument) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more