Skip to main content

AccountAny

Enum AccountAny 

Source
pub enum AccountAny {
    Margin(MarginAccount),
    Cash(CashAccount),
    Betting(BettingAccount),
    Wallet(WalletAccount),
}

Variants§

Implementations§

Source§

impl AccountAny

Source

pub fn clone_without_events(&self) -> Self

Returns a copy without stored account state events.

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) -> Result<()>

Applies an account state event to update the account.

§Errors

Returns an error if the event belongs to a different account or the account state cannot be applied (e.g., negative balance when borrowing is not allowed for a cash account).

Source

pub fn set_calculate_account_state(&mut self, calculate_account_state: bool)

Sets whether account state should be recalculated from order fills.

Source

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

Source

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

Source

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

Source

pub fn from_events(events: &[AccountState]) -> Result<Self>

§Errors

Returns an error if events is empty or an account state cannot be created or applied.

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>

Source§

impl AccountAny

Source

pub fn try_from_state(event: AccountState) -> Result<Self, &'static str>

Creates an AccountAny from an AccountState.

§Errors

Returns an error if a wallet account state is invalid.

Trait Implementations§

Source§

impl Account for AccountAny

Source§

fn apply(&mut self, __enum_dispatch_arg_0: AccountState) -> Result<()>

Applies an account state event to update the account.

§Errors

Returns an error if the account state cannot be applied (e.g., negative balance when borrowing is not allowed for a cash account).

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) -> IndexMap<Currency, Money>

Source§

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

Source§

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

Source§

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

Source§

fn balances_locked(&self) -> IndexMap<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) -> IndexMap<Currency, Money>

Source§

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

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 (const: unstable) · 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

Creates an AccountAny from an AccountState.

§Panics

Panics if a wallet account state is invalid. Use AccountAny::try_from_state for fallible conversion.

Source§

impl From<BettingAccount> for AccountAny

Source§

fn from(v: BettingAccount) -> AccountAny

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 From<WalletAccount> for AccountAny

Source§

fn from(v: WalletAccount) -> AccountAny

Converts to this type from the input type.
Source§

impl PartialEq for AccountAny

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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<BettingAccount> for AccountAny

Source§

type Error = &'static str

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

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

Performs the conversion.
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.
Source§

impl TryInto<WalletAccount> for AccountAny

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<WalletAccount, <Self as TryInto<WalletAccount>>::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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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<T> Ungil for T
where T: Send,