Notebook

Quality Companies in an Uptrend, order_optimal_portfolio by Dan Whitnable.

Using Modified version by Vladimir. More mods.

In [1]:
import pyfolio as pf
import matplotlib.pyplot as plt
import empyrical  as ep
In [2]:
bt = get_backtest('5de8463d9f3e4c4be621dcc0')
returns = bt.daily_performance['returns']
100% Time:  0:00:07|##########################################################|
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 37.1%
Cumulative returns 20420.7%
Annual volatility 50.7%
Sharpe ratio 0.88
Calmar ratio 0.62
Stability 0.93
Max drawdown -59.5%
Omega ratio 1.16
Sortino ratio 1.28
Skew 0.04
Kurtosis 3.08
Tail ratio 1.01
Daily value at risk -6.2%
Alpha 0.37
Beta 0.65
In [5]:
#ax = bt.recorded_vars.plot(figsize=(14,5))
#ax.set(title='Long-Short Count and TF Check', xlabel='date');
In [ ]: