Record Class AlphaBacktester.RiskOptions
java.lang.Object
java.lang.Record
com.quantfinlib.alpha.AlphaBacktester.RiskOptions
- Record Components:
spec- risk model window and settingssectors- sector label per symbol in context order (null = one sector)riskAversion- λ > 0informationCoefficient- 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 Summary
ConstructorsConstructorDescriptionRiskOptions(AlphaRiskModels.Spec spec, List<String> sectors, double riskAversion, double informationCoefficient, double maxWeight, double advTradeFraction, boolean dollarNeutral) Creates an instance of aRiskOptionsrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theadvTradeFractionrecord component.static AlphaBacktester.RiskOptionsdefaults()Default spec, one sector, λ = 5, IC = 0.05, 10% cap, 10% of ADV, dollar neutral.booleanReturns the value of thedollarNeutralrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.doubleReturns the value of theinformationCoefficientrecord component.doubleReturns the value of themaxWeightrecord component.doubleReturns the value of theriskAversionrecord component.sectors()Returns the value of thesectorsrecord component.spec()Returns the value of thespecrecord component.final StringtoString()Returns a string representation of this record class.withAdvTradeFraction(double fraction) withRiskAversion(double lambda) withSectors(List<String> labels)
-
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 aRiskOptionsrecord class.- Parameters:
spec- the value for thespecrecord componentsectors- the value for thesectorsrecord componentriskAversion- the value for theriskAversionrecord componentinformationCoefficient- the value for theinformationCoefficientrecord componentmaxWeight- the value for themaxWeightrecord componentadvTradeFraction- the value for theadvTradeFractionrecord componentdollarNeutral- the value for thedollarNeutralrecord component
-
-
Method Details
-
defaults
Default spec, one sector, λ = 5, IC = 0.05, 10% cap, 10% of ADV, dollar neutral. -
withSectors
-
withSpec
-
withRiskAversion
-
withAdvTradeFraction
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
spec
-
sectors
-
riskAversion
public double riskAversion()Returns the value of theriskAversionrecord component.- Returns:
- the value of the
riskAversionrecord component
-
informationCoefficient
public double informationCoefficient()Returns the value of theinformationCoefficientrecord component.- Returns:
- the value of the
informationCoefficientrecord component
-
maxWeight
-
advTradeFraction
public double advTradeFraction()Returns the value of theadvTradeFractionrecord component.- Returns:
- the value of the
advTradeFractionrecord component
-
dollarNeutral
public boolean dollarNeutral()Returns the value of thedollarNeutralrecord component.- Returns:
- the value of the
dollarNeutralrecord component
-