Enum AccountAny

Source
pub enum AccountAny {
    Margin(MarginAccount),
    Cash(CashAccount),
}

Variants§

Implementations§

Source§

impl AccountAny

Source

pub fn id(&self) -> AccountId

Source

pub fn last_event(&self) -> Option<AccountState>

Source

pub fn events(&self) -> Vec<AccountState>

Source

pub fn apply(&mut self, event: AccountState)

Source

pub fn balances(&self) -> HashMap<Currency, AccountBalance>

Source

pub fn balances_locked(&self) -> HashMap<Currency, Money>

Source

pub fn base_currency(&self) -> Option<Currency>

Source

pub fn from_events(events: Vec<AccountState>) -> Result<Self>

§Errors

Returns an error if events is empty.

§Panics

Panics if events is empty when unwrapping the first element.

Source

pub fn calculate_pnls( &self, instrument: InstrumentAny, fill: OrderFilled, position: Option<Position>, ) -> Result<Vec<Money>>

§Errors

Returns an error if calculating P&Ls fails for the underlying account.

Source

pub fn calculate_commission( &self, instrument: InstrumentAny, last_qty: Quantity, last_px: Price, liquidity_side: LiquiditySide, use_quote_for_inverse: Option<bool>, ) -> Result<Money>

§Errors

Returns an error if calculating commission fails for the underlying account.

Source

pub fn balance(&self, currency: Option<Currency>) -> Option<&AccountBalance>

Trait Implementations§

Source§

impl Account for AccountAny

Source§

fn calculate_balance_locked( &mut self, __enum_dispatch_arg_0: InstrumentAny, __enum_dispatch_arg_1: OrderSide, __enum_dispatch_arg_2: Quantity, __enum_dispatch_arg_3: Price, __enum_dispatch_arg_4: Option<bool>, ) -> Result<Money>

Calculates locked balance for the order parameters.

§Errors

Returns an error if calculating locked balance fails.

Source§

fn calculate_pnls( &self, __enum_dispatch_arg_0: InstrumentAny, __enum_dispatch_arg_1: OrderFilled, __enum_dispatch_arg_2: Option<Position>, ) -> Result<Vec<Money>>

Calculates PnLs for the fill and position.

§Errors

Returns an error if calculating PnLs fails.

Source§

fn calculate_commission( &self, __enum_dispatch_arg_0: InstrumentAny, __enum_dispatch_arg_1: Quantity, __enum_dispatch_arg_2: Price, __enum_dispatch_arg_3: LiquiditySide, __enum_dispatch_arg_4: Option<bool>, ) -> Result<Money>

Calculates commission for the order fill parameters.

§Errors

Returns an error if calculating commission fails.

Source§

fn id(&self) -> AccountId

Source§

fn account_type(&self) -> AccountType

Source§

fn base_currency(&self) -> Option<Currency>

Source§

fn is_cash_account(&self) -> bool

Source§

fn is_margin_account(&self) -> bool

Source§

fn calculated_account_state(&self) -> bool

Source§

fn balance_total( &self, __enum_dispatch_arg_0: Option<Currency>, ) -> Option<Money>

Source§

fn balances_total(&self) -> HashMap<Currency, Money>

Source§

fn balance_free(&self, __enum_dispatch_arg_0: Option<Currency>) -> Option<Money>

Source§

fn balances_free(&self) -> HashMap<Currency, Money>

Source§

fn balance_locked( &self, __enum_dispatch_arg_0: Option<Currency>, ) -> Option<Money>

Source§

fn balances_locked(&self) -> HashMap<Currency, Money>

Source§

fn balance( &self, __enum_dispatch_arg_0: Option<Currency>, ) -> Option<&AccountBalance>

Source§

fn last_event(&self) -> Option<AccountState>

Source§

fn events(&self) -> Vec<AccountState>

Source§

fn event_count(&self) -> usize

Source§

fn currencies(&self) -> Vec<Currency>

Source§

fn starting_balances(&self) -> HashMap<Currency, Money>

Source§

fn balances(&self) -> HashMap<Currency, AccountBalance>

Source§

fn apply(&mut self, __enum_dispatch_arg_0: AccountState)

Source§

fn purge_account_events( &mut self, __enum_dispatch_arg_0: UnixNanos, __enum_dispatch_arg_1: u64, )

Source§

impl Clone for AccountAny

Source§

fn clone(&self) -> AccountAny

Returns a duplicate 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 Debug for AccountAny

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AccountAny

Source§

fn default() -> Self

Creates a new default AccountAny instance.

Source§

impl<'de> Deserialize<'de> for AccountAny

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<AccountState> for AccountAny

Source§

fn from(event: AccountState) -> Self

Converts to this type from the input type.
Source§

impl From<CashAccount> for AccountAny

Source§

fn from(v: CashAccount) -> AccountAny

Converts to this type from the input type.
Source§

impl From<MarginAccount> for AccountAny

Source§

fn from(v: MarginAccount) -> AccountAny

Converts to this type from the input type.
Source§

impl PartialEq for AccountAny

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AccountAny

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryInto<CashAccount> for AccountAny

Source§

type Error = &'static str

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

fn try_into(self) -> Result<CashAccount, <Self as TryInto<CashAccount>>::Error>

Performs the conversion.
Source§

impl TryInto<MarginAccount> for AccountAny

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<MarginAccount, <Self as TryInto<MarginAccount>>::Error>

Performs the conversion.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Ungil for T
where T: Send,