Skip to main content

PortfolioApi

Struct PortfolioApi 

Source
pub struct PortfolioApi<'a> { /* private fields */ }
Expand description

User-facing portfolio read API.

Implementations§

Source§

impl<'a> PortfolioApi<'a>

Source

pub fn is_initialized(&self) -> bool

Returns true if the portfolio has been initialized.

§Panics

Panics if the portfolio is already mutably borrowed.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn total_pnls( &self, venue: &Venue, account_id: Option<&AccountId>, ) -> IndexMap<Currency, Money>

Returns the total PnLs for the given venue.

§Panics

Panics if the portfolio is already borrowed.

Source

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.

Source

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.

Source

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.

Source

pub fn statistics(&self) -> PortfolioStatistics

Returns an owned snapshot of computed portfolio performance statistics.

§Panics

Panics if the portfolio is already mutably borrowed.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_completely_flat(&self) -> bool

Returns whether every net position is flat.

§Panics

Panics if the portfolio is already mutably borrowed.

Source

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.

Trait Implementations§

Source§

impl<'a> Debug for PortfolioApi<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PortfolioApi<'a>

§

impl<'a> !Send for PortfolioApi<'a>

§

impl<'a> !Sync for PortfolioApi<'a>

§

impl<'a> !UnwindSafe for PortfolioApi<'a>

§

impl<'a> Freeze for PortfolioApi<'a>

§

impl<'a> Unpin for PortfolioApi<'a>

§

impl<'a> UnsafeUnpin for PortfolioApi<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more