Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_from_yahoo raises Exception. #20

Open
haje01 opened this issue Jan 12, 2018 · 2 comments
Open

load_from_yahoo raises Exception. #20

haje01 opened this issue Jan 12, 2018 · 2 comments

Comments

@haje01
Copy link

haje01 commented Jan 12, 2018

When running this:

import pybacktest
ohlc = pybacktest.load_from_yahoo('SPY')

Raises error:


---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-14-09359e4057e9> in <module>()
----> 1 ohlc = pybacktest.load_from_yahoo('SPY')

~/.pyenv/versions/3.5.3/envs/acdt/lib/python3.5/site-packages/pybacktest/data.py in load_from_yahoo(ticker, start, adjust_close)
     24              for t in ticker})
     25 
---> 26     data = dr.DataReader(ticker, data_source='yahoo', start=start)
     27     r = data['Adj Close'] / data['Close']
     28     ohlc_cols = ['Open', 'High', 'Low', 'Close']

~/.pyenv/versions/3.5.3/envs/acdt/lib/python3.5/site-packages/pandas_datareader/data.py in DataReader(name, data_source, start, end, retry_count, pause, session, access_key)
    119                                 adjust_price=False, chunksize=25,
    120                                 retry_count=retry_count, pause=pause,
--> 121                                 session=session).read()
    122 
    123     elif data_source == "yahoo-actions":

~/.pyenv/versions/3.5.3/envs/acdt/lib/python3.5/site-packages/pandas_datareader/yahoo/daily.py in read(self)
    113         """ read one data from specified URL """
    114         try:
--> 115             df = super(YahooDailyReader, self).read()
    116             if self.ret_index:
    117                 df['Ret_Index'] = _calc_return_index(df['Adj Close'])

~/.pyenv/versions/3.5.3/envs/acdt/lib/python3.5/site-packages/pandas_datareader/base.py in read(self)
    179         if isinstance(self.symbols, (compat.string_types, int)):
    180             df = self._read_one_data(self.url,
--> 181                                      params=self._get_params(self.symbols))
    182         # Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT'])
    183         elif isinstance(self.symbols, DataFrame):

~/.pyenv/versions/3.5.3/envs/acdt/lib/python3.5/site-packages/pandas_datareader/yahoo/daily.py in _get_params(self, symbol)
     97 
     98     def _get_params(self, symbol):
---> 99         unix_start = int(time.mktime(self.start.timetuple()))
    100         day_end = self.end.replace(hour=23, minute=59, second=59)
    101         unix_end = int(time.mktime(day_end.timetuple()))

OverflowError: mktime argument out of range
@plankconst
Copy link

plankconst commented Feb 10, 2019

I got the same thing while running the tutorial. I think the Yahoo feed reader is no longer compatible with Yahoo's website.

To test it, just load a simple csv file to load some data.

@git-it
Copy link
Contributor

git-it commented May 14, 2019

another option is to set the 'start' i.e. the start-time range of our query to yahoo finance. The snippet bellow queries from January 1, 2012 to present.

import pybacktest
import pandas as pd
from datetime import datetime, timedelta
ohlc = pybacktest.load_from_yahoo('SPY',start=datetime(2012, 10, 1) )
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants