pub struct PortfolioApi<'a> { /* private fields */ }Expand description
User-facing portfolio read API.
Implementations§
Source§impl<'a> PortfolioApi<'a>
impl<'a> PortfolioApi<'a>
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Returns true if the portfolio has been initialized.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn balances_locked(&self, venue: &Venue) -> IndexMap<Currency, Money>
pub fn balances_locked(&self, venue: &Venue) -> IndexMap<Currency, Money>
Returns the locked balances for the given venue.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn margins_init(&self, venue: &Venue) -> IndexMap<InstrumentId, Money>
pub fn margins_init(&self, venue: &Venue) -> IndexMap<InstrumentId, Money>
Returns the initial margin requirements for the given venue.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn margins_maint(&self, venue: &Venue) -> IndexMap<InstrumentId, Money>
pub fn margins_maint(&self, venue: &Venue) -> IndexMap<InstrumentId, Money>
Returns the maintenance margin requirements for the given venue.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn unrealized_pnls(
&self,
venue: &Venue,
account_id: Option<&AccountId>,
) -> IndexMap<Currency, Money>
pub fn unrealized_pnls( &self, venue: &Venue, account_id: Option<&AccountId>, ) -> IndexMap<Currency, Money>
Returns the unrealized PnLs for all positions at the given venue.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn realized_pnls(
&self,
venue: &Venue,
account_id: Option<&AccountId>,
) -> IndexMap<Currency, Money>
pub fn realized_pnls( &self, venue: &Venue, account_id: Option<&AccountId>, ) -> IndexMap<Currency, Money>
Returns the realized PnLs for all positions at the given venue.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn net_exposures(
&self,
venue: &Venue,
account_id: Option<&AccountId>,
) -> Option<IndexMap<Currency, Money>>
pub fn net_exposures( &self, venue: &Venue, account_id: Option<&AccountId>, ) -> Option<IndexMap<Currency, Money>>
Returns net exposures by currency for the given venue.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn unrealized_pnl(&self, instrument_id: &InstrumentId) -> Option<Money>
pub fn unrealized_pnl(&self, instrument_id: &InstrumentId) -> Option<Money>
Returns the unrealized PnL for the given instrument ID.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn unrealized_pnl_for_account(
&self,
instrument_id: &InstrumentId,
account_id: Option<&AccountId>,
) -> Option<Money>
pub fn unrealized_pnl_for_account( &self, instrument_id: &InstrumentId, account_id: Option<&AccountId>, ) -> Option<Money>
Returns the unrealized PnL for the given instrument ID and account filter.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn realized_pnl(&self, instrument_id: &InstrumentId) -> Option<Money>
pub fn realized_pnl(&self, instrument_id: &InstrumentId) -> Option<Money>
Returns the realized PnL for the given instrument ID.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn realized_pnl_for_account(
&self,
instrument_id: &InstrumentId,
account_id: Option<&AccountId>,
) -> Option<Money>
pub fn realized_pnl_for_account( &self, instrument_id: &InstrumentId, account_id: Option<&AccountId>, ) -> Option<Money>
Returns the realized PnL for the given instrument ID and account filter.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn total_pnl(&self, instrument_id: &InstrumentId) -> Option<Money>
pub fn total_pnl(&self, instrument_id: &InstrumentId) -> Option<Money>
Returns the total PnL for the given instrument ID.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn total_pnl_for_account(
&self,
instrument_id: &InstrumentId,
account_id: Option<&AccountId>,
) -> Option<Money>
pub fn total_pnl_for_account( &self, instrument_id: &InstrumentId, account_id: Option<&AccountId>, ) -> Option<Money>
Returns the total PnL for the given instrument ID and account filter.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn total_pnls(
&self,
venue: &Venue,
account_id: Option<&AccountId>,
) -> IndexMap<Currency, Money>
pub fn total_pnls( &self, venue: &Venue, account_id: Option<&AccountId>, ) -> IndexMap<Currency, Money>
Sourcepub fn mark_values(
&self,
venue: &Venue,
account_id: Option<&AccountId>,
) -> IndexMap<Currency, Money>
pub fn mark_values( &self, venue: &Venue, account_id: Option<&AccountId>, ) -> IndexMap<Currency, Money>
Returns the per-currency mark-to-market value of open positions at the given venue.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn equity(
&self,
venue: &Venue,
account_id: Option<&AccountId>,
) -> IndexMap<Currency, Money>
pub fn equity( &self, venue: &Venue, account_id: Option<&AccountId>, ) -> IndexMap<Currency, Money>
Returns the per-currency total equity for the given venue.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn build_snapshot(
&self,
account_id: &AccountId,
) -> Option<PortfolioSnapshot>
pub fn build_snapshot( &self, account_id: &AccountId, ) -> Option<PortfolioSnapshot>
Builds a portfolio snapshot for the given account.
§Panics
Panics if the portfolio is already borrowed.
Sourcepub fn statistics(&self) -> PortfolioStatistics
pub fn statistics(&self) -> PortfolioStatistics
Returns an owned snapshot of computed portfolio performance statistics.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn snapshots(&self, account_id: &AccountId) -> Vec<PortfolioSnapshot>
pub fn snapshots(&self, account_id: &AccountId) -> Vec<PortfolioSnapshot>
Returns the recorded portfolio snapshots for the given account.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn missing_price_instruments(&self, venue: &Venue) -> Vec<InstrumentId>
pub fn missing_price_instruments(&self, venue: &Venue) -> Vec<InstrumentId>
Returns the instruments currently flagged as unpriced for the given venue.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn net_exposure(
&self,
instrument_id: &InstrumentId,
account_id: Option<&AccountId>,
) -> Option<Money>
pub fn net_exposure( &self, instrument_id: &InstrumentId, account_id: Option<&AccountId>, ) -> Option<Money>
Returns the net exposure for the given instrument ID.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn net_position(&self, instrument_id: &InstrumentId) -> Decimal
pub fn net_position(&self, instrument_id: &InstrumentId) -> Decimal
Returns the net position for the given instrument ID.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn is_net_long(&self, instrument_id: &InstrumentId) -> bool
pub fn is_net_long(&self, instrument_id: &InstrumentId) -> bool
Returns whether the net position is long for the given instrument ID.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn is_net_short(&self, instrument_id: &InstrumentId) -> bool
pub fn is_net_short(&self, instrument_id: &InstrumentId) -> bool
Returns whether the net position is short for the given instrument ID.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn is_flat(&self, instrument_id: &InstrumentId) -> bool
pub fn is_flat(&self, instrument_id: &InstrumentId) -> bool
Returns whether the net position is flat for the given instrument ID.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn is_completely_flat(&self) -> bool
pub fn is_completely_flat(&self) -> bool
Returns whether every net position is flat.
§Panics
Panics if the portfolio is already mutably borrowed.
Sourcepub fn recorded_realized_pnls(
&self,
) -> AHashMap<Currency, Vec<(PositionId, UnixNanos, f64)>>
pub fn recorded_realized_pnls( &self, ) -> AHashMap<Currency, Vec<(PositionId, UnixNanos, f64)>>
Returns realized PnLs recorded during portfolio event processing.
Each record is (position_id, ts_event, realized_pnl).
§Panics
Panics if the portfolio is already mutably borrowed.