backtest_lib.portfolio.QuantityPortfolio#

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

Bases: PortfolioBase[int]

Portfolio with integer share quantities.

Holdings represent whole-share quantities for each security. Converting to a weighted portfolio requires passing prices so that weights can be computed.