quantopian / empyrical

Common financial risk and performance metrics. Used by zipline and pyfolio.
https://quantopian.github.io/empyrical
Apache License 2.0
1.27k stars 398 forks source link

KeyError: 'date' #106

Open veonua opened 5 years ago

veonua commented 5 years ago

KeyError: 'date'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/empyrical/utils.py in get_symbol_returns_from_yahoo(symbol, start, end) 435 px = web.get_data_yahoo(symbol, start=start, end=end) --> 436 px['date'] = pd.to_datetime(px['date']) 437 px.set_index('date', drop=False, inplace=True)

Date is index field Index(['High', 'Low', 'Open', 'Close', 'Volume', 'Adj Close'], dtype='object')

eigenfoo commented 5 years ago

It's a little hard to help you diagnose your issue without your code. Could you please give us a reproducible example?

veonua commented 5 years ago

just open https://github.com/quantopian/empyrical/blob/master/empyrical/utils.py#L436

and remove lines 436 and 437

eigenfoo commented 5 years ago

Please see https://github.com/quantopian/empyrical#deprecated-data-reading-via-pandas-datareader

Since https://github.com/quantopian/empyrical/pull/97 we have deprecated all data-reading functionality from empyrical.

hrosspet commented 4 years ago

and remove lines 436 and 437

and change: rets = px[['adjclose']].pct_change().dropna() to rets = px[['Adj Close']].pct_change().dropna()

I made a PR, let's see if Quantutopian will merge it...