pub enum AccountAny {
Margin(MarginAccount),
Cash(CashAccount),
}Variants§
Margin(MarginAccount)
Cash(CashAccount)
Implementations§
Source§impl AccountAny
impl AccountAny
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 account state cannot be applied (e.g., negative balance when borrowing is not allowed for a cash account).
pub fn balances(&self) -> AHashMap<Currency, AccountBalance>
pub fn balances_locked(&self) -> AHashMap<Currency, Money>
pub fn base_currency(&self) -> Option<Currency>
Sourcepub fn from_events(events: Vec<AccountState>) -> Result<Self>
pub fn from_events(events: Vec<AccountState>) -> Result<Self>
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, returning an error for unsupported types.
§Errors
Returns an error if the account type is Betting or Wallet (unsupported in Rust).
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) -> AHashMap<Currency, Money>
fn balance_free(&self, __enum_dispatch_arg_0: Option<Currency>) -> Option<Money>
fn balances_free(&self) -> AHashMap<Currency, Money>
fn balance_locked( &self, __enum_dispatch_arg_0: Option<Currency>, ) -> Option<Money>
fn balances_locked(&self) -> AHashMap<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) -> AHashMap<Currency, Money>
fn balances(&self) -> AHashMap<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 · 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 the account type is Betting or Wallet (unsupported in Rust).
Use AccountAny::try_from_state for fallible conversion.
Source§impl From<CashAccount> for AccountAny
impl From<CashAccount> for AccountAny
Source§fn from(v: CashAccount) -> AccountAny
fn from(v: CashAccount) -> AccountAny
Source§impl From<MarginAccount> for AccountAny
impl From<MarginAccount> for AccountAny
Source§fn from(v: MarginAccount) -> AccountAny
fn from(v: MarginAccount) -> AccountAny
Source§impl PartialEq for AccountAny
impl PartialEq for AccountAny
Source§impl Serialize for AccountAny
impl Serialize for AccountAny
Source§impl TryInto<CashAccount> for AccountAny
impl TryInto<CashAccount> for AccountAny
Source§impl TryInto<MarginAccount> for AccountAny
impl TryInto<MarginAccount> for AccountAny
Auto Trait Implementations§
impl Freeze for AccountAny
impl RefUnwindSafe for AccountAny
impl Send for AccountAny
impl Sync for AccountAny
impl Unpin for AccountAny
impl UnsafeUnpin for AccountAny
impl UnwindSafe for AccountAny
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more