empyrical icon indicating copy to clipboard operation
empyrical copied to clipboard

KeyError: 'date'

Open veonua opened this issue 7 years ago • 4 comments

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')

veonua avatar Dec 06 '18 23:12 veonua

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

eigenfoo avatar Dec 11 '18 17:12 eigenfoo

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

and remove lines 436 and 437

veonua avatar Dec 11 '18 22:12 veonua

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.

eigenfoo avatar Dec 12 '18 02:12 eigenfoo

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...

hrosspet avatar Oct 29 '19 15:10 hrosspet