quantlab.portfolio.predefined.expected_return.GrinoldExpectedReturn#

class quantlab.portfolio.predefined.expected_return.GrinoldExpectedReturn(config)[source]#

Bases: _ScaledByIC

mu = ic * sigma * z: Grinold’s rule, a riskier candidate getting a larger mu.

z is the prediction’s cross-sectional z-score over the bar’s candidates (ddof=1; 0.0 when the bar has fewer than two or a constant cross-section), sigma each candidate’s volatility on the label’s span, so any score will do.

Parameters:
configGrinoldExpectedReturnConfig

ic, the model’s information coefficient (a CV run’s mean IC).

Raises:
ValueError

If ic is not positive.

Examples

>>> import numpy as np
>>> model = GrinoldExpectedReturn(GrinoldExpectedReturnConfig(ic=0.05))
>>> model.expected_returns(
...     np.array([[1.0, 2.0, 3.0]]), np.array([[0.02, 0.02, 0.04]]), np.ones((1, 3), dtype=bool)
... ).round(4)
array([[-0.001,  0.   ,  0.002]])
config_cls#

alias of GrinoldExpectedReturnConfig

expected_returns(predictions, sigma, candidates)[source]#

ic * sigma * z on the candidates, 0.0 elsewhere.

See ExpectedReturnModel.expected_returns.

Examples

>>> model.expected_returns(
...     np.array([[1.0, 3.0]]), np.array([[0.01, 0.01]]), np.ones((1, 2), dtype=bool)
... ).round(4)
array([[-0.0004,  0.0004]])