pub struct AccountRefMut<'a>(/* private fields */);Expand description
Lifetime-scoped exclusive write borrow of a cached account.
Returned by crate::cache::Cache::account_mut. While the borrow is alive, no other read or
write on the same cell is permitted (enforced at runtime by the underlying RefMut).
Drop the borrow before dispatching events or taking any other cache borrow that may re-enter
the same account.
Implementations§
Methods from Deref<Target = AccountAny>§
pub fn clone_without_events(&self) -> AccountAny
pub fn clone_without_events(&self) -> AccountAny
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>
pub fn apply(&mut self, event: AccountState) -> Result<(), Error>
pub fn apply(&mut self, event: AccountState) -> Result<(), Error>
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).
pub 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>
pub fn calculate_pnls(
&self,
instrument: &InstrumentAny,
fill: &OrderFilled,
position: Option<Position>,
) -> Result<Vec<Money>, Error>
pub fn calculate_pnls( &self, instrument: &InstrumentAny, fill: &OrderFilled, position: Option<Position>, ) -> Result<Vec<Money>, Error>
§Errors
Returns an error if calculating P&Ls fails for the underlying account.
pub fn calculate_commission(
&self,
instrument: &InstrumentAny,
last_qty: Quantity,
last_px: Price,
liquidity_side: LiquiditySide,
use_quote_for_inverse: Option<bool>,
) -> Result<Money, Error>
pub fn calculate_commission( &self, instrument: &InstrumentAny, last_qty: Quantity, last_px: Price, liquidity_side: LiquiditySide, use_quote_for_inverse: Option<bool>, ) -> Result<Money, Error>
§Errors
Returns an error if calculating commission fails for the underlying account.