Record Class AlphaBacktester.RiskOptions

java.lang.Object
java.lang.Record
com.quantfinlib.alpha.AlphaBacktester.RiskOptions
Record Components:
spec - risk model window and settings
sectors - sector label per symbol in context order (null = one sector)
riskAversion - λ > 0
informationCoefficient - IC used to scale scores into alphas (> 0)
maxWeight - per-name |w| cap (> 0)
advTradeFraction - per-rebalance trade limit as a fraction of ADV (0 = none)
dollarNeutral - add the constraint Σw = 0
Enclosing class:
AlphaBacktester

public static record AlphaBacktester.RiskOptions(AlphaRiskModels.Spec spec, List<String> sectors, double riskAversion, double informationCoefficient, double maxWeight, double advTradeFraction, boolean dollarNeutral) extends Record
Risk-model-driven construction for AlphaBacktester.run(AlphaContext, AlphaFactor, Config, RiskOptions): at each rebalance a FactorRiskModel is rebuilt from the panel up to the decision bar (AlphaRiskModels) and the book comes from TurnoverAwareOptimizer started at the drifted book actually held.

Over the holding horizon H = rebalanceEveryBars the optimiser maximises αᵀw − λ wᵀ(H·V)w − κ‖w − w₀‖₁ with α_i = IC · σ_i · √H · z_i (Grinold 1994, "Alpha is Volatility Times IC Times Score", J. Portfolio Management 20(4)), z the cross-sectional z-score of the factor, σ_i² = V_ii the model's per-bar variance and κ the one-way flat cost (commission + halfSpread + slippage)/10⁴ of the config. Names without a score or a forecast get a zero cap.

Automatic %ADV trade limit. With advTradeFraction > 0 and capital > 0 each name may trade at most advTradeFraction × ADV_i × price_i / (capital × equity) of equity per rebalance (ADV from the impactWindow bars before the decision bar). A name held beyond its cap may always trade back to the cap.

  • Constructor Details

    • RiskOptions

      public RiskOptions(AlphaRiskModels.Spec spec, List<String> sectors, double riskAversion, double informationCoefficient, double maxWeight, double advTradeFraction, boolean dollarNeutral)
      Creates an instance of a RiskOptions record class.
      Parameters:
      spec - the value for the spec record component
      sectors - the value for the sectors record component
      riskAversion - the value for the riskAversion record component
      informationCoefficient - the value for the informationCoefficient record component
      maxWeight - the value for the maxWeight record component
      advTradeFraction - the value for the advTradeFraction record component
      dollarNeutral - the value for the dollarNeutral record component
  • Method Details

    • defaults

      public static AlphaBacktester.RiskOptions defaults()
      Default spec, one sector, λ = 5, IC = 0.05, 10% cap, 10% of ADV, dollar neutral.
    • withSectors

      public AlphaBacktester.RiskOptions withSectors(List<String> labels)
    • withSpec

    • withRiskAversion

      public AlphaBacktester.RiskOptions withRiskAversion(double lambda)
    • withAdvTradeFraction

      public AlphaBacktester.RiskOptions withAdvTradeFraction(double fraction)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • spec

      public AlphaRiskModels.Spec spec()
      Returns the value of the spec record component.
      Returns:
      the value of the spec record component
    • sectors

      public List<String> sectors()
      Returns the value of the sectors record component.
      Returns:
      the value of the sectors record component
    • riskAversion

      public double riskAversion()
      Returns the value of the riskAversion record component.
      Returns:
      the value of the riskAversion record component
    • informationCoefficient

      public double informationCoefficient()
      Returns the value of the informationCoefficient record component.
      Returns:
      the value of the informationCoefficient record component
    • maxWeight

      public double maxWeight()
      Returns the value of the maxWeight record component.
      Returns:
      the value of the maxWeight record component
    • advTradeFraction

      public double advTradeFraction()
      Returns the value of the advTradeFraction record component.
      Returns:
      the value of the advTradeFraction record component
    • dollarNeutral

      public boolean dollarNeutral()
      Returns the value of the dollarNeutral record component.
      Returns:
      the value of the dollarNeutral record component