Package com.quantfinlib.backtest.portfolio


@NullMarked package com.quantfinlib.backtest.portfolio
Multi-asset portfolio backtesting with point-in-time universes and financing. The main classes: PortfolioBacktester rebalances long/short weight targets from a PortfolioStrategy with commission and turnover tracking (input series must be index-aligned — see data.SeriesAligner), and in its survivorship-aware overload consumes a data.PointInTimeUniverse (delistings terminate at the delisting return, mergers convert at deal terms, index drops force sales) plus explicit ex-date cash dividends; CrossSectionalMomentum is the built-in point-in-time factor strategy (12-1 momentum ranked over the members alive at each rebalance); PositionSizing supplies Kelly, fixed-fractional risk, inverse-volatility weights and vol-target leverage.
  • Class
    Description
    Point-in-time cross-sectional momentum — the classic equity factor, built to demonstrate (and test) universe-aware backtesting: at every rebalance the strategy ranks only the stocks that are index members at that bar's timestamp, goes long the best trailing performers and short the worst.
    Momentum strategy settings.
    Multi-asset, long/short portfolio backtester: rebalances positions (possibly fractional and negative) toward the strategy's target weights at a configurable cadence, charging commission on traded notional.
    costModel, when set, supersedes the flat commissionRate for every trade (rebalances and forced index-drop sales alike), the shared TradeCostModel seam that makes a run survivorship-aware and execution-aware at once.
    Financing terms, all annual.
    Participation cap: each symbol trades at most maxFractionOfAdv × ADV shares per bar, with ADV the mean volume of the advWindow bars before the fill bar (fewer at the start of the data; none on bar 0, so nothing trades there).
    dividendCashCredited and lifecycleEventsApplied are populated by the survivorship-aware overload (zero otherwise).
    A multi-asset, weight-based strategy for the PortfolioBacktester.
    Position sizing rules: Kelly, fixed-fractional risk, inverse-volatility weighting, and volatility targeting — the building blocks for PortfolioStrategy weight construction.