Execute the following cell to "install" the strategy by moving the file to the /codeload/moonshot
directory:
# make directory if doesn't exist
!mkdir -p /codeload/moonshot
!mv qmom.py /codeload/moonshot/
Due to the large universe size, we use the segment
parameter to tell Moonshot to run the backtest in 1-year segments and concatenate the results.
We've added Jupyter's
%time
magic to provide a gauge of total runtime for this backtest.TIP: open the detailed logs while running the backtest to monitor moonshot's progress through the backtest segments.
from quantrocket.moonshot import backtest
%time backtest("qmom", start_date="2010-01-01", end_date="2018-01-01", segment="A", filepath_or_buffer="qmom_backtest.csv")
CPU times: user 20 ms, sys: 10 ms, total: 30 ms Wall time: 1min 6s
from moonchart import Tearsheet
Tearsheet.from_moonshot_csv("qmom_backtest.csv")
import pyfolio as pf
pf.from_moonshot_csv("qmom_backtest.csv")
Start date | 2010-01-04 | |
---|---|---|
End date | 2017-12-29 | |
Total months | 95 | |
Backtest | ||
Annual return | 7.7% | |
Cumulative returns | 80.9% | |
Annual volatility | 23.4% | |
Sharpe ratio | 0.43 | |
Calmar ratio | 0.20 | |
Stability | 0.51 | |
Max drawdown | -39.0% | |
Omega ratio | 1.08 | |
Sortino ratio | 0.60 | |
Skew | -0.42 | |
Kurtosis | 4.81 | |
Tail ratio | 0.90 | |
Daily value at risk | -2.9% | |
Gross leverage | 1.00 |
/opt/conda/lib/python3.6/site-packages/numpy/core/fromnumeric.py:52: FutureWarning: 'argmin' is deprecated, use 'idxmin' instead. The behavior of 'argmin' will be corrected to return the positional minimum in the future. Use 'series.values.argmin' to get the position of the minimum now. return getattr(obj, method)(*args, **kwds)
Worst drawdown periods | Net drawdown in % | Peak date | Valley date | Recovery date | Duration |
---|---|---|---|---|---|
0 | 39.05 | 2014-09-02 | 2016-02-08 | NaT | NaN |
1 | 33.51 | 2011-07-22 | 2011-10-03 | 2013-01-02 | 379 |
2 | 29.18 | 2010-04-26 | 2010-07-06 | 2010-12-01 | 158 |
3 | 13.66 | 2010-01-08 | 2010-01-29 | 2010-03-08 | 42 |
4 | 13.32 | 2011-04-29 | 2011-06-16 | 2011-07-07 | 50 |
Stress Events | mean | min | max |
---|---|---|---|
US downgrade/European Debt Crisis | -0.05% | -10.53% | 8.55% |
Fukushima | 0.31% | -1.91% | 3.38% |
EZB IR Event | -0.03% | -1.49% | 1.54% |
Flash Crash | -0.56% | -4.32% | 7.33% |
Apr14 | -0.03% | -3.51% | 2.84% |
Oct14 | -0.46% | -5.61% | 3.87% |
Fall2015 | -0.27% | -4.36% | 3.58% |
Recovery | 0.07% | -10.53% | 8.55% |
New Normal | 0.03% | -8.33% | 4.01% |
Top 10 long positions of all time | max |
---|---|
qmom | 100.00% |
Top 10 short positions of all time | max |
---|
Top 10 positions of all time | max |
---|---|
qmom | 100.00% |