Skip to main content

Account

Trait Account 

Source
pub trait Account: 'static + Send {
Show 24 methods // Required methods 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, currency: Option<Currency>) -> Option<Money>; fn balances_total(&self) -> IndexMap<Currency, Money>; fn balance_free(&self, currency: Option<Currency>) -> Option<Money>; fn balances_free(&self) -> IndexMap<Currency, Money>; fn balance_locked(&self, currency: Option<Currency>) -> Option<Money>; fn balances_locked(&self) -> IndexMap<Currency, Money>; fn balance(&self, currency: 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 apply(&mut self, event: AccountState) -> Result<()>; fn purge_account_events(&mut self, ts_now: UnixNanos, lookback_secs: u64); fn calculate_balance_locked( &mut self, instrument: &InstrumentAny, side: OrderSide, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, ) -> Result<Money>; fn calculate_pnls( &self, instrument: &InstrumentAny, fill: &OrderFilled, position: Option<Position>, ) -> Result<Vec<Money>>; fn calculate_commission( &self, instrument: &InstrumentAny, last_qty: Quantity, last_px: Price, liquidity_side: LiquiditySide, use_quote_for_inverse: Option<bool>, ) -> Result<Money>;
}

Required Methods§

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, currency: Option<Currency>) -> Option<Money>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

fn balance(&self, currency: 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 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).

Source

fn purge_account_events(&mut self, ts_now: UnixNanos, lookback_secs: u64)

Source

fn calculate_balance_locked( &mut self, instrument: &InstrumentAny, side: OrderSide, quantity: Quantity, price: Price, use_quote_for_inverse: 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, instrument: &InstrumentAny, fill: &OrderFilled, position: 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, instrument: &InstrumentAny, last_qty: Quantity, last_px: Price, liquidity_side: LiquiditySide, use_quote_for_inverse: Option<bool>, ) -> Result<Money>

Calculates commission for the order fill parameters.

§Errors

Returns an error if calculating commission fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§