Struct lfest::prelude::QuoteCurrency
source · pub struct QuoteCurrency(/* private fields */);
Expand description
The markets QUOTE currency, e.g.: BTCUSD -> USD is the quote currency
Trait Implementations§
source§impl Add for QuoteCurrency
impl Add for QuoteCurrency
§type Output = QuoteCurrency
type Output = QuoteCurrency
The resulting type after applying the
+
operator.source§fn add(self, rhs: QuoteCurrency) -> QuoteCurrency
fn add(self, rhs: QuoteCurrency) -> QuoteCurrency
Performs the
+
operation. Read moresource§impl AddAssign for QuoteCurrency
impl AddAssign for QuoteCurrency
source§fn add_assign(&mut self, rhs: QuoteCurrency)
fn add_assign(&mut self, rhs: QuoteCurrency)
Performs the
+=
operation. Read moresource§impl AsRef<Decimal> for QuoteCurrency
impl AsRef<Decimal> for QuoteCurrency
source§impl Clone for QuoteCurrency
impl Clone for QuoteCurrency
source§fn clone(&self) -> QuoteCurrency
fn clone(&self) -> QuoteCurrency
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 QuoteCurrency
impl Currency for QuoteCurrency
§type PairedCurrency = BaseCurrency
type PairedCurrency = BaseCurrency
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 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 QuoteCurrency
impl Debug for QuoteCurrency
source§impl Default for QuoteCurrency
impl Default for QuoteCurrency
source§fn default() -> QuoteCurrency
fn default() -> QuoteCurrency
Returns the “default value” for a type. Read more
source§impl Display for QuoteCurrency
impl Display for QuoteCurrency
source§impl Div<Decimal> for QuoteCurrency
impl Div<Decimal> for QuoteCurrency
source§impl Div<Leverage> for QuoteCurrency
impl Div<Leverage> for QuoteCurrency
source§impl Div for QuoteCurrency
impl Div for QuoteCurrency
§type Output = QuoteCurrency
type Output = QuoteCurrency
The resulting type after applying the
/
operator.source§fn div(self, rhs: QuoteCurrency) -> QuoteCurrency
fn div(self, rhs: QuoteCurrency) -> QuoteCurrency
Performs the
/
operation. Read moresource§impl From<Decimal> for QuoteCurrency
impl From<Decimal> for QuoteCurrency
source§fn from(original: Decimal) -> QuoteCurrency
fn from(original: Decimal) -> QuoteCurrency
Converts to this type from the input type.
source§impl From<QuoteCurrency> for Decimal
impl From<QuoteCurrency> for Decimal
source§fn from(original: QuoteCurrency) -> Self
fn from(original: QuoteCurrency) -> Self
Converts to this type from the input type.
source§impl Hash for QuoteCurrency
impl Hash for QuoteCurrency
source§impl MarginCurrency for QuoteCurrency
impl MarginCurrency for QuoteCurrency
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 a linear futures contract pnl calculation
source§impl Mul<Decimal> for QuoteCurrency
impl Mul<Decimal> for QuoteCurrency
source§impl Mul<Fee> for QuoteCurrency
impl Mul<Fee> for QuoteCurrency
source§impl Mul for QuoteCurrency
impl Mul for QuoteCurrency
§type Output = QuoteCurrency
type Output = QuoteCurrency
The resulting type after applying the
*
operator.source§fn mul(self, rhs: QuoteCurrency) -> QuoteCurrency
fn mul(self, rhs: QuoteCurrency) -> QuoteCurrency
Performs the
*
operation. Read moresource§impl Ord for QuoteCurrency
impl Ord for QuoteCurrency
source§fn cmp(&self, other: &QuoteCurrency) -> Ordering
fn cmp(&self, other: &QuoteCurrency) -> 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 QuoteCurrency
impl PartialEq for QuoteCurrency
source§fn eq(&self, other: &QuoteCurrency) -> bool
fn eq(&self, other: &QuoteCurrency) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for QuoteCurrency
impl PartialOrd for QuoteCurrency
source§fn partial_cmp(&self, other: &QuoteCurrency) -> Option<Ordering>
fn partial_cmp(&self, other: &QuoteCurrency) -> 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 QuoteCurrency
impl Rem for QuoteCurrency
source§impl Sub<Decimal> for QuoteCurrency
impl Sub<Decimal> for QuoteCurrency
source§impl Sub for QuoteCurrency
impl Sub for QuoteCurrency
§type Output = QuoteCurrency
type Output = QuoteCurrency
The resulting type after applying the
-
operator.source§fn sub(self, rhs: QuoteCurrency) -> QuoteCurrency
fn sub(self, rhs: QuoteCurrency) -> QuoteCurrency
Performs the
-
operation. Read moresource§impl SubAssign for QuoteCurrency
impl SubAssign for QuoteCurrency
source§fn sub_assign(&mut self, rhs: QuoteCurrency)
fn sub_assign(&mut self, rhs: QuoteCurrency)
Performs the
-=
operation. Read moreimpl Copy for QuoteCurrency
impl Eq for QuoteCurrency
impl StructuralPartialEq for QuoteCurrency
Auto Trait Implementations§
impl Freeze for QuoteCurrency
impl RefUnwindSafe for QuoteCurrency
impl Send for QuoteCurrency
impl Sync for QuoteCurrency
impl Unpin for QuoteCurrency
impl UnwindSafe for QuoteCurrency
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)