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§
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>
Sourcefn apply(&mut self, event: AccountState) -> Result<()>
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).
fn purge_account_events(&mut self, ts_now: UnixNanos, lookback_secs: u64)
Sourcefn calculate_balance_locked(
&mut self,
instrument: &InstrumentAny,
side: OrderSide,
quantity: Quantity,
price: Price,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
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.
Sourcefn calculate_pnls(
&self,
instrument: &InstrumentAny,
fill: &OrderFilled,
position: Option<Position>,
) -> Result<Vec<Money>>
fn calculate_pnls( &self, instrument: &InstrumentAny, fill: &OrderFilled, position: Option<Position>, ) -> Result<Vec<Money>>
Sourcefn calculate_commission(
&self,
instrument: &InstrumentAny,
last_qty: Quantity,
last_px: Price,
liquidity_side: LiquiditySide,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
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".