Back to Community
long-only mean reversion w/ CVXPY

Thought I'd see if I could whip together a quick-and-dirty algo w/ CVXPY, which recently was released on Quantopian (and is reportedly used under the hood in the optimization API that is in the works).

If I've implemented things correctly, the code should be solving the optimization problem described in Section 4.2 of On-Line Portfolio Selection with Moving Average Reversion.

The CVXPY code:

import cvxpy as cvx  
x = cvx.Variable(m)  
objective = cvx.Minimize(cvx.sum_entries(cvx.square(x-b_t)))  
constraints = [cvx.sum_entries(x) == 1, cvx.sum_entries(x_tilde*x) >= 1, x >= 0]  
prob = cvx.Problem(objective, constraints)  
prob.solve()  
weight = x.value  
Clone Algorithm
56
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5859dfed3fd7595e7b801694
There was a runtime error.