quantlab.portfolio.predefined.active_risk.ActiveRiskOptimizer#

class quantlab.portfolio.predefined.active_risk.ActiveRiskOptimizer(config)[source]#

Bases: MeanVarianceOptimizer

Mean-variance weights that price active risk against a benchmark.

See the module docstring for the problem solved.

Parameters:
configActiveRiskConfig

MeanVarianceConfig’s fields, the benchmark factor, its benchmark_weight output and the optional tracking_error.

Raises:
ValueError

If benchmark is missing or lacks benchmark_weight, or tracking_error is not positive; and as MeanVarianceOptimizer.

Examples

With use4 a built Use4RiskModel and index_weight a factor with the output benchmark_weight:

from quantlab.portfolio.config import (
    ActiveRiskConfig, FactorRiskStoreEstimatorConfig, GrinoldExpectedReturnConfig,
)
from quantlab.portfolio.predefined.expected_return import GrinoldExpectedReturn
from quantlab.portfolio.predefined.factor_risk import FactorRiskStoreEstimator

rule = ActiveRiskOptimizer(ActiveRiskConfig(
    expected_return_label="ret_5",
    covariance=FactorRiskStoreEstimator(FactorRiskStoreEstimatorConfig(risk_model=use4)),
    expected_return=GrinoldExpectedReturn(GrinoldExpectedReturnConfig(ic=0.02)),
    risk_aversion=10.0, weight_cap=0.05,
    benchmark=index_weight, tracking_error=0.02,
))
axis_factors()[source]#

The benchmark’s weights: its symbols without a prediction are in the reference book.

Examples

>>> rule.axis_factors() == (rule.config.benchmark_weight,)
True
config_cls#

alias of ActiveRiskConfig

declared_inputs()[source]#

The optimiser’s declaration, and the benchmark among the factors.

Examples

>>> rule.declared_inputs().factors[-1] is rule.config.benchmark
True
reference_weights(context)[source]#

The benchmark’s weights at the bar.

Examples

>>> rule.reference_weights(context).name
'benchmark_weight'
risk_constraints(risk)[source]#

The tracking-error cap on the active variance, if any.

Examples

>>> rule.risk_constraints(risk)  # no tracking_error
[]