Struct lfest::prelude::BaseCurrency
source · pub struct BaseCurrency(_);
Expand description
The markets BASE currency, e.g.: BTCUSD -> BTC is the BASE currency
Trait Implementations§
source§impl<'a> Add<&'a BaseCurrency> for BaseCurrency
impl<'a> Add<&'a BaseCurrency> for BaseCurrency
source§impl Add<BaseCurrency> for BaseCurrency
impl Add<BaseCurrency> for BaseCurrency
§type Output = BaseCurrency
type Output = BaseCurrency
The resulting type after applying the
+
operator.source§fn add(self, rhs: BaseCurrency) -> BaseCurrency
fn add(self, rhs: BaseCurrency) -> BaseCurrency
Performs the
+
operation. Read moresource§impl Add<Decimal> for BaseCurrency
impl Add<Decimal> for BaseCurrency
source§impl<'a> AddAssign<&'a BaseCurrency> for BaseCurrency
impl<'a> AddAssign<&'a BaseCurrency> for BaseCurrency
source§fn add_assign(&mut self, rhs: &'a Self)
fn add_assign(&mut self, rhs: &'a Self)
Performs the
+=
operation. Read moresource§impl AddAssign<BaseCurrency> for BaseCurrency
impl AddAssign<BaseCurrency> for BaseCurrency
source§fn add_assign(&mut self, rhs: BaseCurrency)
fn add_assign(&mut self, rhs: BaseCurrency)
Performs the
+=
operation. Read moresource§impl Clone for BaseCurrency
impl Clone for BaseCurrency
source§fn clone(&self) -> BaseCurrency
fn clone(&self) -> BaseCurrency
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Currency for BaseCurrency
impl Currency for BaseCurrency
§type PairedCurrency = QuoteCurrency
type PairedCurrency = QuoteCurrency
The paired currency.
e.g.: for the BTCUSD market the BTC currency is paired with USD, so the
PairedCurrency
would be USDsource§fn abs(self) -> Self
fn abs(self) -> Self
TODO: it may be smart to remove this here and use another type that can
be negative Get the absolute value
source§fn fee_portion(&self, fee: Fee) -> Self
fn fee_portion(&self, fee: Fee) -> Self
Compute the fee denoted in the currency
source§fn convert(&self, rate: QuoteCurrency) -> Self::PairedCurrency
fn convert(&self, rate: QuoteCurrency) -> Self::PairedCurrency
Convert this
Currency
’s value into its pair at the conversion rate
.
E.g:
1 BTC @ 20_000 USD means that 1 USD = 1 / 20_000 BTCsource§fn into_negative(self) -> Self
fn into_negative(self) -> Self
Convert the Currency to a negative value
source§impl Debug for BaseCurrency
impl Debug for BaseCurrency
source§impl Default for BaseCurrency
impl Default for BaseCurrency
source§fn default() -> BaseCurrency
fn default() -> BaseCurrency
Returns the “default value” for a type. Read more
source§impl Display for BaseCurrency
impl Display for BaseCurrency
source§impl<'a> Div<&'a BaseCurrency> for BaseCurrency
impl<'a> Div<&'a BaseCurrency> for BaseCurrency
source§impl Div<BaseCurrency> for BaseCurrency
impl Div<BaseCurrency> for BaseCurrency
§type Output = BaseCurrency
type Output = BaseCurrency
The resulting type after applying the
/
operator.source§fn div(self, rhs: BaseCurrency) -> BaseCurrency
fn div(self, rhs: BaseCurrency) -> BaseCurrency
Performs the
/
operation. Read moresource§impl Div<Decimal> for BaseCurrency
impl Div<Decimal> for BaseCurrency
source§impl From<BaseCurrency> for Decimal
impl From<BaseCurrency> for Decimal
source§fn from(original: BaseCurrency) -> Self
fn from(original: BaseCurrency) -> Self
Converts to this type from the input type.
source§impl From<Decimal> for BaseCurrency
impl From<Decimal> for BaseCurrency
source§fn from(original: Decimal) -> BaseCurrency
fn from(original: Decimal) -> BaseCurrency
Converts to this type from the input type.
source§impl MarginCurrency for BaseCurrency
impl MarginCurrency for BaseCurrency
source§fn pnl<S>(
entry_price: QuoteCurrency,
exit_price: QuoteCurrency,
quantity: S
) -> S::PairedCurrencywhere
S: Currency,
fn pnl<S>( entry_price: QuoteCurrency, exit_price: QuoteCurrency, quantity: S ) -> S::PairedCurrencywhere S: Currency,
This represents the pnl calculation for inverse futures contracts
source§impl<'a> Mul<&'a BaseCurrency> for BaseCurrency
impl<'a> Mul<&'a BaseCurrency> for BaseCurrency
source§impl Mul<BaseCurrency> for BaseCurrency
impl Mul<BaseCurrency> for BaseCurrency
§type Output = BaseCurrency
type Output = BaseCurrency
The resulting type after applying the
*
operator.source§fn mul(self, rhs: BaseCurrency) -> BaseCurrency
fn mul(self, rhs: BaseCurrency) -> BaseCurrency
Performs the
*
operation. Read moresource§impl Mul<Decimal> for BaseCurrency
impl Mul<Decimal> for BaseCurrency
source§impl PartialEq<BaseCurrency> for BaseCurrency
impl PartialEq<BaseCurrency> for BaseCurrency
source§fn eq(&self, other: &BaseCurrency) -> bool
fn eq(&self, other: &BaseCurrency) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<BaseCurrency> for BaseCurrency
impl PartialOrd<BaseCurrency> for BaseCurrency
source§fn partial_cmp(&self, other: &BaseCurrency) -> Option<Ordering>
fn partial_cmp(&self, other: &BaseCurrency) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Rem<BaseCurrency> for BaseCurrency
impl Rem<BaseCurrency> for BaseCurrency
source§impl<'a> Sub<&'a BaseCurrency> for BaseCurrency
impl<'a> Sub<&'a BaseCurrency> for BaseCurrency
source§impl Sub<BaseCurrency> for BaseCurrency
impl Sub<BaseCurrency> for BaseCurrency
§type Output = BaseCurrency
type Output = BaseCurrency
The resulting type after applying the
-
operator.source§fn sub(self, rhs: BaseCurrency) -> BaseCurrency
fn sub(self, rhs: BaseCurrency) -> BaseCurrency
Performs the
-
operation. Read moresource§impl Sub<Decimal> for BaseCurrency
impl Sub<Decimal> for BaseCurrency
source§impl<'a> SubAssign<&'a BaseCurrency> for BaseCurrency
impl<'a> SubAssign<&'a BaseCurrency> for BaseCurrency
source§fn sub_assign(&mut self, rhs: &'a Self)
fn sub_assign(&mut self, rhs: &'a Self)
Performs the
-=
operation. Read moresource§impl SubAssign<BaseCurrency> for BaseCurrency
impl SubAssign<BaseCurrency> for BaseCurrency
source§fn sub_assign(&mut self, rhs: BaseCurrency)
fn sub_assign(&mut self, rhs: BaseCurrency)
Performs the
-=
operation. Read more