Notebook

From: https://www.quantopian.com/algorithms/5b71fa2d9de4f300406e0f85/5b746e7a7c24534363b1226a/old

Trend Follow Algo. Returned to initial capital of $10,000,000. No change to code, but changed numbers that have an impact on the strategy's payoff matrix. Trading interval: 10.25 years. Payoff matrix equation:

$$ F(t) = F_0 \cdot (1 + \bar g)^t = F_0 + \sum (\mathbf{H} \cdot \Delta \mathbf{P}) - \sum (\mathbf{E}xp) = F_0 + n \cdot \bar x $$

In [1]:
bt = get_backtest('5b746e7a7c24534363b1226a')
100% Time: 0:00:24|###########################################################|
In [2]:
bt.create_full_tear_sheet(round_trips=True, hide_positions=True, live_start_date = "2016-01-01")
Start date2007-08-02
End date2017-12-29
In-sample months100
Out-of-sample months23
All In-sample Out-of-sample
Annual return 34.7% 31.7% 48.0%
Cumulative returns 2113.1% 912.1% 118.7%
Annual volatility 33.2% 33.9% 30.2%
Sharpe ratio 1.06 0.98 1.45
Calmar ratio 0.83 0.76 1.47
Stability 0.94 0.91 0.60
Max drawdown -41.8% -41.8% -32.6%
Omega ratio 1.20 1.18 1.27
Sortino ratio 1.53 1.41 2.14
Skew -0.26 -0.26 -0.23
Kurtosis 2.20 2.19 1.96
Tail ratio 0.99 0.97 1.16
Daily value at risk -4.0% -4.1% -3.6%
Gross leverage 3.10 2.73 4.68
Daily turnover 4.3% 4.5% 3.3%
Alpha 0.34 0.32 0.28
Beta 0.17 0.13 0.99
Worst drawdown periods Net drawdown in % Peak date Valley date Recovery date Duration
0 41.80 2013-05-08 2013-06-24 2014-08-21 337
1 34.69 2011-04-29 2012-05-18 2013-04-05 506
2 32.55 2016-02-29 2016-11-11 2017-03-01 263
3 24.97 2008-07-02 2008-08-11 2008-10-09 72
4 24.02 2009-03-09 2009-06-15 2009-09-08 132
/usr/local/lib/python2.7/dist-packages/numpy/lib/function_base.py:3834: RuntimeWarning: Invalid value encountered in percentile
  RuntimeWarning)
Stress Events mean min max
Lehmann 0.06% -5.56% 8.64%
US downgrade/European Debt Crisis 0.50% -11.26% 9.92%
Fukushima 0.60% -3.29% 4.71%
EZB IR Event 0.07% -3.37% 5.30%
Aug07 -0.03% -3.23% 2.22%
Mar08 -0.55% -5.17% 1.95%
Sept08 0.37% -5.56% 8.64%
2009Q1 0.42% -3.67% 4.51%
2009Q2 -0.24% -4.10% 4.76%
Flash Crash -1.04% -6.95% 6.22%
Apr14 0.02% -6.99% 4.27%
Oct14 0.78% -4.27% 7.02%
Fall2015 0.03% -4.24% 2.43%
Low Volatility Bull Market 0.00% 0.00% 0.00%
GFC Crash 0.19% -5.73% 8.64%
Recovery 0.11% -11.57% 9.92%
New Normal 0.15% -8.54% 9.07%
/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.py:2787: UserWarning: Attempting to set identical left==right results
in singular transformations; automatically expanding.
left=732889.0, right=732889.0
  'left=%s, right=%s') % (left, right))