Struct lfest::prelude::Account

source ·
pub struct Account<M, UserOrderId>
where M: Currency + MarginCurrency, UserOrderId: Clone + Debug + Eq + PartialEq + Hash,
{ /* private fields */ }
Expand description

The users account Generic over: M: The Currency representing the margin currency. UserOrderId: The type for the user defined order id.

Implementations§

source§

impl<M, UserOrderId> Account<M, UserOrderId>
where M: Currency + MarginCurrency, UserOrderId: Clone + Debug + Eq + PartialEq + Hash,

source

pub fn position(&self) -> &Position<M>

Get the current position of the Account.

source

pub fn active_limit_orders( &self ) -> &HashMap<OrderId, LimitOrder<M::PairedCurrency, UserOrderId, Pending<M::PairedCurrency>>>

Maps the order id to the actual Order.

source§

impl<M, UserOrderId> Account<M, UserOrderId>
where M: Currency + MarginCurrency, UserOrderId: Clone + Debug + Eq + PartialEq + Hash,

source

pub fn wallet_balance(&self) -> M

The wallet balance of the user denoted in the margin currency.

source

pub fn order_margin(&self) -> M

The current order margin used by the user Account.

source§

impl<M, UserOrderId> Account<M, UserOrderId>
where M: Currency + MarginCurrency, UserOrderId: Clone + Debug + Eq + PartialEq + Hash,

source

pub fn available_balance(&self) -> M

Return the available balance of the Account

source

pub fn update_desired_leverage(&mut self, _leverage: Leverage) -> Result<()>

Allows the user to update their desired leverage. This will deposit or release variation margin from the position if any.

§Returns:

If Err, the account is unable to provide enough variation margin for the desired leverage.

Trait Implementations§

source§

impl<M, UserOrderId> Clone for Account<M, UserOrderId>
where M: Currency + MarginCurrency + Clone, UserOrderId: Clone + Debug + Eq + PartialEq + Hash + Clone, M::PairedCurrency: Clone,

source§

fn clone(&self) -> Account<M, UserOrderId>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<M, UserOrderId> Debug for Account<M, UserOrderId>
where M: Currency + MarginCurrency + Debug, UserOrderId: Clone + Debug + Eq + PartialEq + Hash + Debug, M::PairedCurrency: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M, UserOrderId> Freeze for Account<M, UserOrderId>
where M: Freeze, <M as Currency>::PairedCurrency: Freeze,

§

impl<M, UserOrderId> RefUnwindSafe for Account<M, UserOrderId>

§

impl<M, UserOrderId> Send for Account<M, UserOrderId>
where UserOrderId: Send,

§

impl<M, UserOrderId> Sync for Account<M, UserOrderId>
where M: Sync, <M as Currency>::PairedCurrency: Sync, UserOrderId: Sync,

§

impl<M, UserOrderId> Unpin for Account<M, UserOrderId>
where M: Unpin, <M as Currency>::PairedCurrency: Unpin, UserOrderId: Unpin,

§

impl<M, UserOrderId> UnwindSafe for Account<M, UserOrderId>
where M: UnwindSafe, <M as Currency>::PairedCurrency: UnwindSafe, UserOrderId: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.