backtest_lib.portfolio.WeightedPortfolio#

class backtest_lib.portfolio.WeightedPortfolio(universe: Iterable[str], holdings: UniverseMapping[H] | Mapping[str, H], cash: float, total_value: float, constructor_backend: str = 'polars')#

Bases: PortfolioBase[float]

Portfolio whose holdings are weights.

Holdings are expressed as weights that sum to 1 when combined with the cash weight. Converting to quantities requires prices and the portfolio’s total_value.