pub enum AccountAny {
Margin(MarginAccount),
Cash(CashAccount),
Betting(BettingAccount),
Wallet(WalletAccount),
}Variants§
Implementations§
Source§impl AccountAny
impl AccountAny
Sourcepub fn clone_without_events(&self) -> Self
pub fn clone_without_events(&self) -> Self
Returns a copy without stored account state events.
pub fn id(&self) -> AccountId
pub fn last_event(&self) -> Option<AccountState>
pub fn events(&self) -> Vec<AccountState>
Sourcepub fn apply(&mut self, event: AccountState) -> Result<()>
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).
Sourcepub fn set_calculate_account_state(&mut self, calculate_account_state: bool)
pub fn set_calculate_account_state(&mut self, calculate_account_state: bool)
Sets whether account state should be recalculated from order fills.
pub fn balances(&self) -> IndexMap<Currency, AccountBalance>
pub fn balances_locked(&self) -> IndexMap<Currency, Money>
pub fn base_currency(&self) -> Option<Currency>
Sourcepub fn from_events(events: &[AccountState]) -> Result<Self>
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.
Sourcepub fn calculate_pnls(
&self,
instrument: &InstrumentAny,
fill: &OrderFilled,
position: Option<Position>,
) -> Result<Vec<Money>>
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.
Sourcepub fn calculate_commission(
&self,
instrument: &InstrumentAny,
last_qty: Quantity,
last_px: Price,
liquidity_side: LiquiditySide,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
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.
pub fn balance(&self, currency: Option<Currency>) -> Option<&AccountBalance>
Source§impl AccountAny
impl AccountAny
Sourcepub fn try_from_state(event: AccountState) -> Result<Self, &'static str>
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
impl Account for AccountAny
Source§fn apply(&mut self, __enum_dispatch_arg_0: AccountState) -> Result<()>
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>
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>>
fn calculate_pnls( &self, __enum_dispatch_arg_0: &InstrumentAny, __enum_dispatch_arg_1: &OrderFilled, __enum_dispatch_arg_2: Option<Position>, ) -> Result<Vec<Money>>
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>
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.
fn id(&self) -> AccountId
fn account_type(&self) -> AccountType
fn base_currency(&self) -> Option<Currency>
fn is_cash_account(&self) -> bool
fn is_margin_account(&self) -> bool
fn calculated_account_state(&self) -> bool
fn balance_total( &self, __enum_dispatch_arg_0: Option<Currency>, ) -> Option<Money>
fn balances_total(&self) -> IndexMap<Currency, Money>
fn balance_free(&self, __enum_dispatch_arg_0: Option<Currency>) -> Option<Money>
fn balances_free(&self) -> IndexMap<Currency, Money>
fn balance_locked( &self, __enum_dispatch_arg_0: Option<Currency>, ) -> Option<Money>
fn balances_locked(&self) -> IndexMap<Currency, Money>
fn balance( &self, __enum_dispatch_arg_0: Option<Currency>, ) -> Option<&AccountBalance>
fn last_event(&self) -> Option<AccountState>
fn events(&self) -> Vec<AccountState>
fn event_count(&self) -> usize
fn currencies(&self) -> Vec<Currency>
fn starting_balances(&self) -> IndexMap<Currency, Money>
fn balances(&self) -> IndexMap<Currency, AccountBalance>
fn purge_account_events( &mut self, __enum_dispatch_arg_0: UnixNanos, __enum_dispatch_arg_1: u64, )
Source§impl Clone for AccountAny
impl Clone for AccountAny
Source§fn clone(&self) -> AccountAny
fn clone(&self) -> AccountAny
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AccountAny
impl Debug for AccountAny
Source§impl Default for AccountAny
impl Default for AccountAny
Source§fn default() -> Self
fn default() -> Self
Creates a new default AccountAny instance.
Source§impl<'de> Deserialize<'de> for AccountAny
impl<'de> Deserialize<'de> for AccountAny
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<AccountState> for AccountAny
impl From<AccountState> for AccountAny
Source§fn from(event: AccountState) -> Self
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.