Class PositionSizing

java.lang.Object
com.quantfinlib.backtest.portfolio.PositionSizing

public final class PositionSizing extends Object
Position sizing rules: Kelly, fixed-fractional risk, inverse-volatility weighting, and volatility targeting — the building blocks for PortfolioStrategy weight construction.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    fixedFractionalQuantity(double equity, double riskFraction, double entryPrice, double stopPrice)
    Fixed-fractional sizing: shares such that hitting the stop loses exactly riskFraction of equity.
    static double
    halfKelly(double meanReturn, double variance)
    Half-Kelly — the practitioner's standard, trading growth for drawdown.
    static double[]
    inverseVolatilityWeights(double[] vols)
    Normalized inverse-volatility weights (equal weight for any zero vols).
    static double
    kellyFraction(double meanReturn, double variance)
    Full Kelly fraction for a return stream: f* = μ / σ².
    static double
    volatilityTargetLeverage(double currentAnnualVol, double targetAnnualVol)
    Leverage multiplier that scales current volatility to the target.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • kellyFraction

      public static double kellyFraction(double meanReturn, double variance)
      Full Kelly fraction for a return stream: f* = μ / σ².
    • halfKelly

      public static double halfKelly(double meanReturn, double variance)
      Half-Kelly — the practitioner's standard, trading growth for drawdown.
    • fixedFractionalQuantity

      public static double fixedFractionalQuantity(double equity, double riskFraction, double entryPrice, double stopPrice)
      Fixed-fractional sizing: shares such that hitting the stop loses exactly riskFraction of equity.
    • inverseVolatilityWeights

      public static double[] inverseVolatilityWeights(double[] vols)
      Normalized inverse-volatility weights (equal weight for any zero vols).
    • volatilityTargetLeverage

      public static double volatilityTargetLeverage(double currentAnnualVol, double targetAnnualVol)
      Leverage multiplier that scales current volatility to the target.