Notebook

Quality Companies in an Uptrend order_optimal_portfolio(modified by Vladimir) v02

In [1]:
import pyfolio as pf
import matplotlib.pyplot as plt
import empyrical  as ep
In [2]:
bt = get_backtest('5de379b1d610df4a5f11d7df')
returns = bt.daily_performance['returns']
100% Time:  0:00:08|##########################################################|
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 date2003-01-02
End date2019-11-18
Total months202
Backtest
Annual return 19.5%
Cumulative returns 1921.9%
Annual volatility 15.6%
Sharpe ratio 1.22
Calmar ratio 1.00
Stability 0.98
Max drawdown -19.5%
Omega ratio 1.23
Sortino ratio 1.74
Skew -0.42
Kurtosis 2.38
Tail ratio 1.01
Daily value at risk -1.9%
Alpha 0.14
Beta 0.47
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 [ ]: