Portfolio¶
The Python Portfolio exposes read-only account, PnL, exposure, margin, and snapshot queries.
Instrument PnL and exposure queries accept fresh price overrides where applicable, and all eight
scalar and collection PnL and exposure queries accept an optional target currency. Conversion
failure returns no value for scalar methods and net_exposures, while PnL collection methods
raise. No method returns a partial mixed-currency total. The authoritative update and lifecycle
commands remain internal to the Rust engine.
Portfolio accounting and analytics.
- class Portfolio¶
Bases:
objectWrapper providing shared access to [Portfolio] from Python.
- account(venue=None, account_id=None)¶
Returns a detached, point-in-time copy of the account.
The copy does not reflect later account updates, and changing it does not affect the Portfolio. Call account() again to obtain the latest account state.
- balances_locked(venue=None, account_id=None)¶
- build_snapshot(account_id)¶
- deregister_statistic(statistic)¶
Removes the statistic matching statistic by name from analysis.
Deregistering a statistic that was never registered is a no-op.
# Errors
Returns an error if statistic cannot be converted into a registrable statistic.
- deregister_statistics()¶
Removes all registered statistics, including the built-in defaults.
- equity(venue=None, account_id=None)¶
- instrument_initial_margins(venue=None, account_id=None)¶
- instrument_maintenance_margins(venue=None, account_id=None)¶
- is_completely_net_flat(account_id=None)¶
- is_initialized()¶
- is_net_flat(instrument_id, account_id=None)¶
- is_net_long(instrument_id, account_id=None)¶
- is_net_short(instrument_id, account_id=None)¶
- mark_values(venue=None, account_id=None)¶
- missing_price_instruments(venue, account_id=None)¶
- net_exposure(instrument_id, price=None, account_id=None, target_currency=None)¶
- net_exposures(venue=None, account_id=None, target_currency=None)¶
- net_position(instrument_id, account_id=None)¶
- realized_pnl(instrument_id, account_id=None, target_currency=None)¶
- realized_pnls(venue=None, account_id=None, target_currency=None)¶
- register_statistic(statistic)¶
Registers a portfolio statistic for inclusion in portfolio and backtest analysis.
Accepts a built-in statistic type or any user-defined object exposing a name and the calculation methods for the input categories it supports. The registration persists across statistics() calls, so it also reaches backtest results and post-run analysis logs. Registering a statistic whose name matches an existing one replaces it.
# Errors
Returns an error if statistic cannot be converted into a registrable statistic.
- snapshots(account_id)¶
- statistics()¶
- total_pnl(instrument_id, price=None, account_id=None, target_currency=None)¶
- total_pnls(venue=None, account_id=None, target_currency=None)¶
- unrealized_pnl(instrument_id, price=None, account_id=None, target_currency=None)¶
- unrealized_pnls(venue=None, account_id=None, target_currency=None)¶