quantlab.portfolio.predefined.mean_variance#

Markowitz mean-variance weights with a turnover penalty, solved with cvxpy.

MeanVarianceOptimizer maximises, on every rebalance bar,

w @ mu - risk_aversion / 2 * w @ Sigma @ w - turnover_penalty * |w - w_current|_1

over long-only, fully invested weights, or dollar-neutral long-short weights of gross exposure at most one, under a per-symbol cap. The expected return mu is calibrated from a label’s prediction (Grinold: ic * sigma * z) or is the prediction itself (raw), the covariance Sigma comes from a covariance estimator, its volatilities optionally from a volatility label’s prediction, and all are on the span of the expected-return label. This is the only quantlab module that imports cvxpy. The approximate backtest (quantlab.backtest.approximate) reads the same config and solves a panel of bars with its own implementation (quantlab.portfolio.predefined.approximate.mean_variance).

Classes

MeanVarianceInputs

The problem one bar poses: the candidate symbols, the locked ones and their inputs.

MeanVarianceOptimizer

Mean-variance weights with a turnover penalty, long-only or long-short.