Notebook
In [ ]:
 
In [1]:
import pyfolio as pf
import matplotlib.pyplot as plt
import empyrical  as ep
In [2]:
bt = get_backtest('5d5b9a7e0e022163a8d7f1b3')
returns = bt.daily_performance['returns']
100% Time:  0:00:44|##########################################################|
In [3]:
cum_returns = ep.cum_returns(returns)
ax = cum_returns.plot(figsize=(14,5))
ax.set(title='Cumulative Returns', ylabel='returns', xlabel='date');
In [4]:
benchmark_rets = pf.utils.get_symbol_rets('SPY')
pf.plotting.show_perf_stats(returns, benchmark_rets)
Start date2004-07-01
End date2019-07-30
Total months180
Backtest
Annual return 16.0%
Cumulative returns 829.9%
Annual volatility 19.3%
Sharpe ratio 0.86
Calmar ratio 0.66
Stability 0.96
Max drawdown -24.2%
Omega ratio 1.16
Sortino ratio 1.21
Skew -0.40
Kurtosis 1.97
Tail ratio 0.94
Daily value at risk -2.4%
Alpha 0.13
Beta 0.37
In [5]:
fig = plt.figure(1)
plt.subplot(1,3,1)
pf.plot_annual_returns(returns)
plt.subplot(1,3,2)
pf.plot_monthly_returns_dist(returns)
plt.subplot(1,3,3)
pf.plot_monthly_returns_heatmap(returns)
plt.tight_layout()
fig.set_size_inches(15,5)
In [6]:
ax = bt.recorded_vars.plot(figsize=(14,5))
ax.set(title='VIX threshold + adaptive switch', ylabel='value', xlabel='date');
In [ ]: