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 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 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.
pub fn balance(&self, currency: Option<Currency>) -> Option<&AccountBalance>
Trait Implementations§
Source§impl AsMut<AccountAny> for AccountRefMut<'_>
impl AsMut<AccountAny> for AccountRefMut<'_>
Source§impl AsRef<AccountAny> for AccountRefMut<'_>
impl AsRef<AccountAny> for AccountRefMut<'_>
Source§impl Debug for AccountRefMut<'_>
impl Debug for AccountRefMut<'_>
Source§impl Deref for AccountRefMut<'_>
impl Deref for AccountRefMut<'_>
Source§impl DerefMut for AccountRefMut<'_>
impl DerefMut for AccountRefMut<'_>
Source§impl<'a> From<RefMut<'a, AccountAny>> for AccountRefMut<'a>
impl<'a> From<RefMut<'a, AccountAny>> for AccountRefMut<'a>
Source§impl PartialEq<&AccountAny> for AccountRefMut<'_>
impl PartialEq<&AccountAny> for AccountRefMut<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for AccountRefMut<'a>
impl<'a> !Send for AccountRefMut<'a>
impl<'a> !Sync for AccountRefMut<'a>
impl<'a> !UnwindSafe for AccountRefMut<'a>
impl<'a> Freeze for AccountRefMut<'a>
impl<'a> Unpin for AccountRefMut<'a>
impl<'a> UnsafeUnpin for AccountRefMut<'a>
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
Mutably borrows from an owned value. Read more