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§impl PartialOrd for Instrument
impl PartialOrd for Instrument
Source§impl Serialize for Instrument
impl Serialize for Instrument
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Instrument
Auto Trait Implementations§
impl Freeze for Instrument
impl RefUnwindSafe for Instrument
impl Send for Instrument
impl Sync for Instrument
impl Unpin for Instrument
impl UnwindSafe for Instrument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more