Now we are ready to run a backtest. Open a flightlog terminal to monitor the progress and performance statistics while the backtest runs:
from quantrocket.zipline import backtest
backtest(
"sell-gap",
start_date="2014-01-03",
end_date="2020-09-30",
capital_base=2e5,
filepath_or_buffer="sell_gap_backtest_results.csv",
progress="M")
Then view the pyfolio tear sheet:
import pyfolio
pyfolio.from_zipline_csv("sell_gap_backtest_results.csv")
| Start date | 2014-01-06 | |
|---|---|---|
| End date | 2020-09-30 | |
| Total months | 80 | |
| Backtest | ||
| Annual return | 8.728% | |
| Cumulative returns | 75.687% | |
| Annual volatility | 7.488% | |
| Sharpe ratio | 1.15 | |
| Calmar ratio | 1.08 | |
| Stability | 0.92 | |
| Max drawdown | -8.051% | |
| Omega ratio | 1.48 | |
| Sortino ratio | 1.88 | |
| Skew | 1.14 | |
| Kurtosis | 22.89 | |
| Tail ratio | 1.53 | |
| Daily value at risk | -0.909% | |
| Alpha | 0.09 | |
| Beta | -0.02 | |
| Worst drawdown periods | Net drawdown in % | Peak date | Valley date | Recovery date | Duration |
|---|---|---|---|---|---|
| 0 | 8.05 | 2015-05-20 | 2015-08-24 | 2015-11-03 | 120 |
| 1 | 7.37 | 2019-01-15 | 2019-07-31 | NaT | NaN |
| 2 | 5.48 | 2014-05-23 | 2014-10-22 | 2015-01-09 | 166 |
| 3 | 3.73 | 2016-07-21 | 2016-08-05 | 2016-10-25 | 69 |
| 4 | 3.31 | 2016-11-02 | 2017-05-10 | 2017-06-15 | 162 |
| Stress Events | mean | min | max |
|---|---|---|---|
| Apr14 | 0.02% | -0.63% | 1.20% |
| Oct14 | 0.03% | -1.38% | 1.09% |
| Fall2015 | -0.09% | -3.83% | 0.74% |
| 2018 Bear Market | 0.02% | -0.96% | 1.71% |
| COVID-19 | -0.01% | -1.17% | 0.68% |