quantopian / pyfolio

Portfolio and risk analytics in Python
https://quantopian.github.io/pyfolio
Apache License 2.0
5.7k stars 1.78k forks source link

create_full_tearsheet function should take optional parameter to turn off Fama-French risk factor plots #153

Closed justinlent closed 8 years ago

justinlent commented 9 years ago

maybe easily via a boolean, or some kwargs?

justinlent commented 9 years ago

maybe we can even generalized this request to: Passing of settings, or arguments, to create_full_tearsheet that propagate through to the other helper functions called within create_full_tearsheet.

Thoughts @twiecki ?

twiecki commented 8 years ago

In which cases would you want to switch it off?

justinlent commented 8 years ago

@twiecki this was a pretty old request to serve as a way to deal with when the FF plot would throw an exception and keep the rest of the tearsheet from generating. If we think we have addressed the root issue (FF plot throwing exception) then we can close this issue out.

twiecki commented 8 years ago

As of https://github.com/quantopian/pyfolio/pull/251 we should be good.

citynorman commented 7 years ago

This is still a problem, right now I'm getting a download error for the FF data library and I can't turn off the FF plots.

http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_daily_CSV.zip File Transfer Blocked Transfer of the file you were trying to download or upload has been blocked in accordance with company policy. Please contact your system administrator if you believe this is in error. File name: F-F_Research_Data_Factors_daily_CSV.zip

Traceback (most recent call last):
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-9-29708a1e2517>", line 1, in <module>
    pf.create_returns_tear_sheet(returns)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pyfolio/plotting.py", line 56, in call_w_context
    return func(*args, **kwargs)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pyfolio/tears.py", line 360, in create_returns_tear_sheet
    returns, ax=ax_rolling_risk)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pyfolio/plotting.py", line 160, in plot_rolling_fama_french
    rolling_window=rolling_window)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pyfolio/timeseries.py", line 627, in rolling_fama_french
    start=returns.index[0], end=returns.index[-1])
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pyfolio/utils.py", line 354, in load_portfolio_risk_factors
    five_factors = get_returns_cached(filepath, get_fama_french, end)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pyfolio/utils.py", line 193, in get_returns_cached
    returns = update_func(**kwargs)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pyfolio/utils.py", line 318, in get_fama_french
    'famafrench', start=start)[0]
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pandas_datareader/data.py", line 145, in DataReader
    session=session).read()
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pandas_datareader/base.py", line 69, in read
    return self._read_one_data(self.url, self.params)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pandas_datareader/famafrench.py", line 91, in _read_one_data
    data = self._read_zipfile(url)
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pandas_datareader/famafrench.py", line 59, in _read_zipfile
    raw = self._get_response(url).content
  File "/mnt/data/dev/test-eb/venv/local/lib/python2.7/site-packages/pandas_datareader/base.py", line 120, in _get_response
    raise RemoteDataError('Unable to read URL: {0}'.format(url))
RemoteDataError: Unable to read URL: http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_daily_CSV.zip