Notebook

BENCHMARK: MARKET PERFORMANCE

In [10]:
bt = get_backtest('59163d3bfb7902620654d4a1')
bt.create_full_tear_sheet()
100% Time: 0:00:02|###########################################################|
Entire data start date: 2003-01-02
Entire data end date: 2017-05-11


Backtest Months: 172
Performance statistics Backtest
annual_return 0.09
cum_returns_final 2.54
annual_volatility 0.18
sharpe_ratio 0.57
calmar_ratio 0.17
stability_of_timeseries 0.76
max_drawdown -0.55
omega_ratio 1.12
sortino_ratio 0.81
skew -0.05
kurtosis 11.08
tail_ratio 0.98
common_sense_ratio 1.07
gross_leverage 1.00
information_ratio -0.00
alpha 0.00
beta 1.00

RemoteDataErrorTraceback (most recent call last)
<ipython-input-10-42f1e6dc7c09> in <module>()
      1 bt = get_backtest('59163d3bfb7902620654d4a1')
----> 2 bt.create_full_tear_sheet()

/build/src/qexec_repo/qexec/research/results.py in create_full_tear_sheet(self, benchmark_rets, slippage, live_start_date, bayesian, round_trips, estimate_intraday, hide_positions, cone_std, bootstrap)
   1147             hide_positions=hide_positions,
   1148             cone_std=cone_std,
-> 1149             bootstrap=bootstrap
   1150         )

/usr/local/lib/python2.7/dist-packages/pyfolio/tears.pyc in create_full_tear_sheet(returns, positions, transactions, market_data, benchmark_rets, slippage, live_start_date, sector_mappings, bayesian, round_trips, estimate_intraday, hide_positions, cone_std, bootstrap, unadjusted_returns, set_context)
    168         benchmark_rets=benchmark_rets,
    169         bootstrap=bootstrap,
--> 170         set_context=set_context)
    171 
    172     create_interesting_times_tear_sheet(returns,

/usr/local/lib/python2.7/dist-packages/pyfolio/plotting.pyc in call_w_context(*args, **kwargs)
     54         if set_context:
     55             with context():
---> 56                 return func(*args, **kwargs)
     57         else:
     58             return func(*args, **kwargs)

/usr/local/lib/python2.7/dist-packages/pyfolio/tears.pyc in create_returns_tear_sheet(returns, positions, live_start_date, cone_std, benchmark_rets, bootstrap, return_fig)
    358 
    359     plotting.plot_rolling_fama_french(
--> 360         returns, ax=ax_rolling_risk)
    361 
    362     # Drawdowns

/usr/local/lib/python2.7/dist-packages/pyfolio/plotting.pyc in plot_rolling_fama_french(returns, factor_returns, rolling_window, legend_loc, ax, **kwargs)
    158         returns,
    159         factor_returns=factor_returns,
--> 160         rolling_window=rolling_window)
    161 
    162     rolling_beta.plot(alpha=0.7, ax=ax, **kwargs)

/usr/local/lib/python2.7/dist-packages/pyfolio/timeseries.pyc in rolling_fama_french(returns, factor_returns, rolling_window)
    625     if factor_returns is None:
    626         factor_returns = utils.load_portfolio_risk_factors(
--> 627             start=returns.index[0], end=returns.index[-1])
    628         factor_returns = factor_returns.drop(['Mkt-RF', 'RF'],
    629                                              axis='columns')

/usr/local/lib/python2.7/dist-packages/pyfolio/utils.pyc in load_portfolio_risk_factors(filepath_prefix, start, end)
    352         filepath = filepath_prefix
    353 
--> 354     five_factors = get_returns_cached(filepath, get_fama_french, end)
    355 
    356     return five_factors.loc[start:end]

/usr/local/lib/python2.7/dist-packages/pyfolio/utils.pyc in get_returns_cached(filepath, update_func, latest_dt, **kwargs)
    191 
    192     if update_cache:
--> 193         returns = update_func(**kwargs)
    194         try:
    195             ensure_directory(cache_dir())

/usr/local/lib/python2.7/dist-packages/pyfolio/utils.pyc in get_fama_french()
    316     start = '1/1/1970'
    317     research_factors = web.DataReader('F-F_Research_Data_Factors_daily',
--> 318                                       'famafrench', start=start)[0]
    319     momentum_factor = web.DataReader('F-F_Momentum_Factor_daily',
    320                                      'famafrench', start=start)[0]

/usr/local/lib/python2.7/dist-packages/pandas_datareader/data.pyc in DataReader(name, data_source, start, end, retry_count, pause, session)
    113         return FamaFrenchReader(symbols=name, start=start, end=end,
    114                                 retry_count=retry_count, pause=pause,
--> 115                                 session=session).read()
    116 
    117     elif data_source == "oecd":

/usr/local/lib/python2.7/dist-packages/pandas_datareader/base.pyc in read(self)
     73     def read(self):
     74         """ read data """
---> 75         return self._read_one_data(self.url, self.params)
     76 
     77     def _read_one_data(self, url, params):

/usr/local/lib/python2.7/dist-packages/pandas_datareader/famafrench.pyc in _read_one_data(self, url, params)
     95 
     96         doc_chunks, tables = [], []
---> 97         data = self._read_zipfile(url)
     98 
     99         for chunk in data.split(2 * '\r\n'):

/usr/local/lib/python2.7/dist-packages/pandas_datareader/famafrench.pyc in _read_zipfile(self, url)
     63 
     64     def _read_zipfile(self, url):
---> 65         raw = self._get_response(url).content
     66 
     67         with tempfile.TemporaryFile() as tmpf:

/usr/local/lib/python2.7/dist-packages/pandas_datareader/base.pyc in _get_response(self, url, params)
    115             time.sleep(self.pause)
    116 
--> 117         raise RemoteDataError('Unable to read URL: {0}'.format(url))
    118 
    119     def _read_lines(self, out):

RemoteDataError: Unable to read URL: http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_daily_CSV.zip

FULL BACKTEST

01/01/2003 - 05/05/2017

In [9]:
bt = get_backtest('590fa9d2fd011b61d31281a7')
bt.create_full_tear_sheet()
100% Time: 0:00:07|###########################################################|
Entire data start date: 2003-01-02
Entire data end date: 2017-05-05


Backtest Months: 171
Performance statistics Backtest
annual_return 0.49
cum_returns_final 315.17
annual_volatility 0.29
sharpe_ratio 1.55
calmar_ratio 1.71
stability_of_timeseries 0.97
max_drawdown -0.29
omega_ratio 1.43
sortino_ratio 2.55
skew 1.21
kurtosis 25.73
tail_ratio 1.21
common_sense_ratio 1.80
gross_leverage 1.09
information_ratio 0.07
alpha 0.41
beta 0.25

RemoteDataErrorTraceback (most recent call last)
<ipython-input-9-98d9df1c12c5> in <module>()
      1 bt = get_backtest('590fa9d2fd011b61d31281a7')
----> 2 bt.create_full_tear_sheet()

/build/src/qexec_repo/qexec/research/results.py in create_full_tear_sheet(self, benchmark_rets, slippage, live_start_date, bayesian, round_trips, estimate_intraday, hide_positions, cone_std, bootstrap)
   1147             hide_positions=hide_positions,
   1148             cone_std=cone_std,
-> 1149             bootstrap=bootstrap
   1150         )

/usr/local/lib/python2.7/dist-packages/pyfolio/tears.pyc in create_full_tear_sheet(returns, positions, transactions, market_data, benchmark_rets, slippage, live_start_date, sector_mappings, bayesian, round_trips, estimate_intraday, hide_positions, cone_std, bootstrap, unadjusted_returns, set_context)
    168         benchmark_rets=benchmark_rets,
    169         bootstrap=bootstrap,
--> 170         set_context=set_context)
    171 
    172     create_interesting_times_tear_sheet(returns,

/usr/local/lib/python2.7/dist-packages/pyfolio/plotting.pyc in call_w_context(*args, **kwargs)
     54         if set_context:
     55             with context():
---> 56                 return func(*args, **kwargs)
     57         else:
     58             return func(*args, **kwargs)

/usr/local/lib/python2.7/dist-packages/pyfolio/tears.pyc in create_returns_tear_sheet(returns, positions, live_start_date, cone_std, benchmark_rets, bootstrap, return_fig)
    358 
    359     plotting.plot_rolling_fama_french(
--> 360         returns, ax=ax_rolling_risk)
    361 
    362     # Drawdowns

/usr/local/lib/python2.7/dist-packages/pyfolio/plotting.pyc in plot_rolling_fama_french(returns, factor_returns, rolling_window, legend_loc, ax, **kwargs)
    158         returns,
    159         factor_returns=factor_returns,
--> 160         rolling_window=rolling_window)
    161 
    162     rolling_beta.plot(alpha=0.7, ax=ax, **kwargs)

/usr/local/lib/python2.7/dist-packages/pyfolio/timeseries.pyc in rolling_fama_french(returns, factor_returns, rolling_window)
    625     if factor_returns is None:
    626         factor_returns = utils.load_portfolio_risk_factors(
--> 627             start=returns.index[0], end=returns.index[-1])
    628         factor_returns = factor_returns.drop(['Mkt-RF', 'RF'],
    629                                              axis='columns')

/usr/local/lib/python2.7/dist-packages/pyfolio/utils.pyc in load_portfolio_risk_factors(filepath_prefix, start, end)
    352         filepath = filepath_prefix
    353 
--> 354     five_factors = get_returns_cached(filepath, get_fama_french, end)
    355 
    356     return five_factors.loc[start:end]

/usr/local/lib/python2.7/dist-packages/pyfolio/utils.pyc in get_returns_cached(filepath, update_func, latest_dt, **kwargs)
    191 
    192     if update_cache:
--> 193         returns = update_func(**kwargs)
    194         try:
    195             ensure_directory(cache_dir())

/usr/local/lib/python2.7/dist-packages/pyfolio/utils.pyc in get_fama_french()
    316     start = '1/1/1970'
    317     research_factors = web.DataReader('F-F_Research_Data_Factors_daily',
--> 318                                       'famafrench', start=start)[0]
    319     momentum_factor = web.DataReader('F-F_Momentum_Factor_daily',
    320                                      'famafrench', start=start)[0]

/usr/local/lib/python2.7/dist-packages/pandas_datareader/data.pyc in DataReader(name, data_source, start, end, retry_count, pause, session)
    113         return FamaFrenchReader(symbols=name, start=start, end=end,
    114                                 retry_count=retry_count, pause=pause,
--> 115                                 session=session).read()
    116 
    117     elif data_source == "oecd":

/usr/local/lib/python2.7/dist-packages/pandas_datareader/base.pyc in read(self)
     73     def read(self):
     74         """ read data """
---> 75         return self._read_one_data(self.url, self.params)
     76 
     77     def _read_one_data(self, url, params):

/usr/local/lib/python2.7/dist-packages/pandas_datareader/famafrench.pyc in _read_one_data(self, url, params)
     95 
     96         doc_chunks, tables = [], []
---> 97         data = self._read_zipfile(url)
     98 
     99         for chunk in data.split(2 * '\r\n'):

/usr/local/lib/python2.7/dist-packages/pandas_datareader/famafrench.pyc in _read_zipfile(self, url)
     63 
     64     def _read_zipfile(self, url):
---> 65         raw = self._get_response(url).content
     66 
     67         with tempfile.TemporaryFile() as tmpf:

/usr/local/lib/python2.7/dist-packages/pandas_datareader/base.pyc in _get_response(self, url, params)
    115             time.sleep(self.pause)
    116 
--> 117         raise RemoteDataError('Unable to read URL: {0}'.format(url))
    118 
    119     def _read_lines(self, out):

RemoteDataError: Unable to read URL: http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_daily_CSV.zip

PART 1

01/01/2003 - 01/01/2007

In [21]:
bt = get_backtest('590fad1c04563461cc15c71b')
bt.create_returns_tear_sheet()
100% Time: 0:00:05|###########################################################|
Entire data start date: 2003-01-02
Entire data end date: 2006-12-29


Backtest Months: 47
Performance statistics Backtest
annual_return 0.39
cum_returns_final 2.68
annual_volatility 0.19
sharpe_ratio 1.83
calmar_ratio 2.31
stability_of_timeseries 0.82
max_drawdown -0.17
omega_ratio 1.42
sortino_ratio 3.03
skew 0.59
kurtosis 3.66
tail_ratio 1.25
common_sense_ratio 1.73
gross_leverage 1.10
information_ratio 0.09
alpha 0.21
beta 0.97
Worst drawdown periods net drawdown in % peak date valley date recovery date duration
0 16.72 2006-05-09 2006-08-11 2006-10-09 110
1 15.61 2004-03-05 2004-07-08 2004-12-02 195
2 13.95 2005-08-02 2005-11-01 2005-12-14 97
3 7.89 2004-12-31 2005-02-01 2005-03-07 47
4 7.70 2005-03-07 2005-05-12 2005-07-08 90

[-0.022 -0.045]

PART 2

01/01/2007 - 05/05/2017

In [22]:
bt = get_backtest('590faa55fcfa7f61ce648968')
bt.create_returns_tear_sheet()
100% Time: 0:00:12|###########################################################|
Entire data start date: 2007-01-03
Entire data end date: 2017-05-05


Backtest Months: 124
Performance statistics Backtest
annual_return 0.54
cum_returns_final 83.95
annual_volatility 0.31
sharpe_ratio 1.53
calmar_ratio 1.86
stability_of_timeseries 0.95
max_drawdown -0.29
omega_ratio 1.44
sortino_ratio 2.51
skew 1.20
kurtosis 23.77
tail_ratio 1.16
common_sense_ratio 1.78
gross_leverage 1.07
information_ratio 0.07
alpha 0.47
beta 0.14
Worst drawdown periods net drawdown in % peak date valley date recovery date duration
0 28.85 2011-08-08 2011-10-07 2012-10-17 313
1 27.23 2008-05-16 2008-11-11 2008-11-19 134
2 22.59 2008-12-01 2009-01-14 2009-01-20 37
3 19.09 2015-09-01 2015-09-25 2015-12-18 79
4 18.08 2014-12-03 2015-05-06 2015-08-21 188

[-0.038 -0.072]

MARKET CRASH ZOOM IN

01/01/2008 - 01/01/2010

In [24]:
bt = get_backtest('590facd3b9b30961eefcca98')
bt.create_returns_tear_sheet()
100% Time: 0:00:02|###########################################################|
Entire data start date: 2008-01-02
Entire data end date: 2009-12-31


Backtest Months: 24
Performance statistics Backtest
annual_return 1.25
cum_returns_final 4.09
annual_volatility 0.44
sharpe_ratio 2.05
calmar_ratio 4.64
stability_of_timeseries 0.86
max_drawdown -0.27
omega_ratio 1.69
sortino_ratio 3.79
skew 1.74
kurtosis 14.76
tail_ratio 1.52
common_sense_ratio 3.41
gross_leverage 0.85
information_ratio 0.11
alpha 0.91
beta 0.03
Worst drawdown periods net drawdown in % peak date valley date recovery date duration
0 26.96 2008-05-16 2008-11-11 2008-11-19 134
1 22.60 2008-12-01 2009-01-14 2009-01-20 37
2 13.63 2009-06-12 2009-06-24 2009-07-16 25
3 12.75 2009-01-20 2009-01-22 2009-03-02 30
4 9.10 2009-10-22 2009-10-28 2009-11-11 15

[-0.052 -0.094]

LAST 5 YEARS

01/01/2012 - 05/05/2017

In [23]:
bt = get_backtest('590fab4f1fdca661ab9b84f2')
bt.create_returns_tear_sheet()
100% Time: 0:00:06|###########################################################|
Entire data start date: 2012-01-03
Entire data end date: 2017-05-05


Backtest Months: 64
Performance statistics Backtest
annual_return 0.43
cum_returns_final 5.79
annual_volatility 0.24
sharpe_ratio 1.62
calmar_ratio 2.26
stability_of_timeseries 0.97
max_drawdown -0.19
omega_ratio 1.39
sortino_ratio 2.56
skew 0.56
kurtosis 10.41
tail_ratio 1.21
common_sense_ratio 1.74
gross_leverage 1.17
information_ratio 0.06
alpha 0.33
beta 0.42
Worst drawdown periods net drawdown in % peak date valley date recovery date duration
0 19.09 2015-09-01 2015-09-25 2015-12-18 79
1 18.07 2016-01-14 2016-01-21 2016-03-30 55
2 17.98 2014-12-03 2015-05-06 2015-08-21 188
3 14.28 2012-04-02 2012-04-23 2012-08-16 99
4 14.27 2016-05-02 2016-06-22 2016-06-30 44

[-0.029 -0.057]

1 YEAR ZOOM IN

05/05/2016 - 05/05/2017

In [25]:
bt = get_backtest('590fac5599f11f61ab83608a')
bt.create_returns_tear_sheet()
100% Time: 0:00:02|###########################################################|
Entire data start date: 2016-05-05
Entire data end date: 2017-05-05


Backtest Months: 12
Performance statistics Backtest
annual_return 0.52
cum_returns_final 0.52
annual_volatility 0.20
sharpe_ratio 2.16
calmar_ratio 4.64
stability_of_timeseries 0.88
max_drawdown -0.11
omega_ratio 1.55
sortino_ratio 4.02
skew 2.01
kurtosis 14.86
tail_ratio 1.27
common_sense_ratio 1.93
gross_leverage 1.14
information_ratio 0.08
alpha 0.38
beta 0.31
Worst drawdown periods net drawdown in % peak date valley date recovery date duration
0 11.23 2016-05-10 2016-06-22 2016-06-27 35
1 8.38 2016-09-09 2016-11-14 2016-12-05 62
2 6.12 2017-03-15 2017-05-04 NaT NaN
3 4.21 2016-08-15 2016-08-31 2016-09-09 20
4 3.97 2017-03-01 2017-03-09 2017-03-15 11

[-0.024 -0.053]
In [ ]: