backtest_lib.portfolio.PortfolioBase#
- class backtest_lib.portfolio.PortfolioBase(universe: Iterable[str], holdings: UniverseMapping[H] | Mapping[str, H], cash: float, total_value: float, constructor_backend: str = 'polars')#
Bases:
GenericBase portfolio representation.
A portfolio records holdings for a fixed universe along with a cash position and the total portfolio value. Subclasses determine the unit for holdings (weights, whole-share quantities, or fractional quantities) and provide conversions across these representations.
- holdings#
Mapping from security to holdings in the portfolio’s unit.