pub struct AccountsManager { /* private fields */ }
Expand description
Manages account balance updates and calculations for portfolio management.
The accounts manager handles balance updates for different account types, including cash and margin accounts, based on order fills and position changes.
Implementations§
Source§impl AccountsManager
impl AccountsManager
Sourcepub fn new(clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>) -> Self
pub fn new(clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>) -> Self
Creates a new AccountsManager
instance.
Sourcepub fn update_balances(
&self,
account: AccountAny,
instrument: InstrumentAny,
fill: OrderFilled,
) -> AccountState
pub fn update_balances( &self, account: AccountAny, instrument: InstrumentAny, fill: OrderFilled, ) -> AccountState
Updates the given account state based on a filled order.
§Panics
Panics if the position list for the filled instrument is empty.
Sourcepub fn update_orders(
&self,
account: &AccountAny,
instrument: InstrumentAny,
orders_open: Vec<&OrderAny>,
ts_event: UnixNanos,
) -> Option<(AccountAny, AccountState)>
pub fn update_orders( &self, account: &AccountAny, instrument: InstrumentAny, orders_open: Vec<&OrderAny>, ts_event: UnixNanos, ) -> Option<(AccountAny, AccountState)>
Updates account balances based on open orders.
For cash accounts, updates the balance locked by open orders. For margin accounts, updates the initial margin requirements.
Sourcepub fn update_positions(
&self,
account: &MarginAccount,
instrument: InstrumentAny,
positions: Vec<&Position>,
ts_event: UnixNanos,
) -> Option<(MarginAccount, AccountState)>
pub fn update_positions( &self, account: &MarginAccount, instrument: InstrumentAny, positions: Vec<&Position>, ts_event: UnixNanos, ) -> Option<(MarginAccount, AccountState)>
Updates the account based on current open positions.
§Panics
Panics if any position’s instrument_id
does not match the provided instrument
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AccountsManager
impl !RefUnwindSafe for AccountsManager
impl !Send for AccountsManager
impl !Sync for AccountsManager
impl Unpin for AccountsManager
impl !UnwindSafe for AccountsManager
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