quantlab.portfolio.predefined.expected_return.ZScoreExpectedReturn#

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

Bases: _ScaledByIC

mu = ic * median(sigma) * z: Grinold’s scale without the tilt to risky names.

z is as in GrinoldExpectedReturn; each bar’s z is scaled by the median volatility of its candidates, so mu has Grinold’s size (the same risk_aversion and turnover_penalty mean the same) and, within a bar, ranks exactly as the prediction.

Parameters:
configZScoreExpectedReturnConfig

ic, the model’s information coefficient.

Raises:
ValueError

If ic is not positive.

Examples

>>> model = ZScoreExpectedReturn(ZScoreExpectedReturnConfig(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.001]])
config_cls#

alias of ZScoreExpectedReturnConfig

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

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

Examples

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