Struct lfest::prelude::BaseCurrency
source · pub struct BaseCurrency(/* private fields */);
Expand description
The markets BASE currency, e.g.: BTCUSD -> BTC is the BASE currency
Trait Implementations§
source§impl Add<Fee> for BaseCurrency
impl Add<Fee> for BaseCurrency
source§impl Add for BaseCurrency
impl Add 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 AddAssign for BaseCurrency
impl AddAssign 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 new(val: Decimal) -> Self
fn new(val: Decimal) -> Self
Create a new instance from a
Rational
value
TODO: change return type to be Result<Self>
, beacuse inputting a Decimal
that it LTE zero could happen.source§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
TODO: rename for greater clarity
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 Div<Decimal> for BaseCurrency
impl Div<Decimal> for BaseCurrency
source§impl Div<Leverage> for BaseCurrency
impl Div<Leverage> for BaseCurrency
source§impl Div for BaseCurrency
impl Div 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 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 Hash for BaseCurrency
impl Hash for BaseCurrency
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 Mul<Decimal> for BaseCurrency
impl Mul<Decimal> for BaseCurrency
source§impl Mul<Fee> for BaseCurrency
impl Mul<Fee> for BaseCurrency
source§impl Mul for BaseCurrency
impl Mul 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 Ord for BaseCurrency
impl Ord for BaseCurrency
source§fn cmp(&self, other: &BaseCurrency) -> Ordering
fn cmp(&self, other: &BaseCurrency) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for BaseCurrency
impl PartialEq 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 for BaseCurrency
impl PartialOrd 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 for BaseCurrency
impl Rem for BaseCurrency
source§impl Sub<Decimal> for BaseCurrency
impl Sub<Decimal> for BaseCurrency
source§impl Sub for BaseCurrency
impl Sub 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 SubAssign for BaseCurrency
impl SubAssign for BaseCurrency
source§fn sub_assign(&mut self, rhs: BaseCurrency)
fn sub_assign(&mut self, rhs: BaseCurrency)
Performs the
-=
operation. Read moreimpl Copy for BaseCurrency
impl Eq for BaseCurrency
impl StructuralPartialEq for BaseCurrency
Auto Trait Implementations§
impl Freeze for BaseCurrency
impl RefUnwindSafe for BaseCurrency
impl Send for BaseCurrency
impl Sync for BaseCurrency
impl Unpin for BaseCurrency
impl UnwindSafe for BaseCurrency
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
Mutably borrows from an owned value. Read more