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§
Source§impl<'a> AccountRefMut<'a>
impl<'a> AccountRefMut<'a>
Sourcepub fn new(inner: RefMut<'a, AccountAny>) -> Self
pub fn new(inner: RefMut<'a, AccountAny>) -> Self
Wraps the given RefMut borrow.
Sourcepub fn cloned(&self) -> AccountAny
pub fn cloned(&self) -> AccountAny
Returns an owned snapshot of the borrowed account.
Methods from Deref<Target = 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<(), 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).
Sourcepub 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>
Sourcepub 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.
Sourcepub 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§fn as_mut(&mut self) -> &mut AccountAny
fn as_mut(&mut self) -> &mut AccountAny
Source§impl AsRef<AccountAny> for AccountRefMut<'_>
impl AsRef<AccountAny> for AccountRefMut<'_>
Source§fn as_ref(&self) -> &AccountAny
fn as_ref(&self) -> &AccountAny
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§fn from(inner: RefMut<'a, AccountAny>) -> Self
fn from(inner: RefMut<'a, AccountAny>) -> Self
Source§impl PartialEq<&AccountAny> for AccountRefMut<'_>
impl PartialEq<&AccountAny> for AccountRefMut<'_>
Source§fn eq(&self, other: &&AccountAny) -> bool
fn eq(&self, other: &&AccountAny) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<AccountAny> for AccountRefMut<'_>
impl PartialEq<AccountAny> for AccountRefMut<'_>
Source§fn eq(&self, other: &AccountAny) -> bool
fn eq(&self, other: &AccountAny) -> bool
self and other values to be equal, and is used by ==.Auto Trait Implementations§
impl<'a> Freeze for AccountRefMut<'a>
impl<'a> !RefUnwindSafe for AccountRefMut<'a>
impl<'a> !Send for AccountRefMut<'a>
impl<'a> !Sync for AccountRefMut<'a>
impl<'a> Unpin for AccountRefMut<'a>
impl<'a> UnsafeUnpin for AccountRefMut<'a>
impl<'a> !UnwindSafe 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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