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

ValueError when I try to get data from Alpha Vantage #741

Open
arzieg opened this issue Dec 30, 2019 · 2 comments · May be fixed by #856
Open

ValueError when I try to get data from Alpha Vantage #741

arzieg opened this issue Dec 30, 2019 · 2 comments · May be fixed by #856

Comments

@arzieg
Copy link

arzieg commented Dec 30, 2019

Hello,
I have tried the example to get data from alpha vantage (https://pandas-datareader.readthedocs.io/en/latest/remote_data.html#historical-time-series-data) and I got a ValueError:

Traceback (most recent call last):
File "adllib.py", line 40, in
api_key=os.getenv('ALPHAVANTAGE_API_KEY'))
File "/home/arne/dev/python/stock/venv/lib/python3.5/site-packages/pandas/util/_decorators.py", line 188, in wrapper
return func(*args, **kwargs)
File "/home/arne/dev/python/stock/venv/lib/python3.5/site-packages/pandas_datareader/data.py", line 579, in DataReader
api_key=api_key,
File "/home/arne/dev/python/stock/venv/lib/python3.5/site-packages/pandas_datareader/base.py", line 100, in read
return self._read_one_data(self.url, self.params)
File "/home/arne/dev/python/stock/venv/lib/python3.5/site-packages/pandas_datareader/base.py", line 112, in _read_one_data
return self._read_lines(out)
File "/home/arne/dev/python/stock/venv/lib/python3.5/site-packages/pandas_datareader/av/time_series.py", line 112, in _read_lines
raise ValueError("Please input a valid date range")
ValueError: Please input a valid date range

I have also tried the test procedure with pytest:

pytest -v test_av_time_series.py::TestAVTimeSeries::test_av_daily
============================================================================================================ test session starts ============================================================================================================
platform linux -- Python 3.5.2, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 -- /home/arne/dev/python/stock/venv/bin/python
cachedir: .pytest_cache
rootdir: /home/arne/dev/python/stock
collected 1 item

test_av_time_series.py::TestAVTimeSeries::test_av_daily FAILED [100%]

================================================================================================================= FAILURES ==================================================================================================================
______________________________________________________________________________________________________ TestAVTimeSeries.test_av_daily _______________________________________________________________________________________________________

self = <pandas_datareader.tests.av.test_av_time_series.TestAVTimeSeries object at 0x7f85079867f0>

def test_av_daily(self):
    df = web.DataReader(
        "AAPL",
        "av-daily",
        start=self.start,
        end=self.end,
        retry_count=6,
      pause=20.5,
    )

test_av_time_series.py:63:


../../../pandas/util/_decorators.py:188: in wrapper
return func(*args, **kwargs)
../../data.py:579: in DataReader
api_key=api_key,
../../base.py:100: in read
return self._read_one_data(self.url, self.params)
../../base.py:112: in _read_one_data
return self._read_lines(out)


self = <pandas_datareader.av.time_series.AVTimeSeriesReader object at 0x7f8507984eb8>
out = {'Meta Data': {'1. Information': 'Daily Prices (open, high, low, close) and Volumes', '2. Symbol': 'AAPL', '3. Last Re..., '1999-12-30': {'1. open': '102.1900', '2. high': '104.1200', '3. low': '99.6200', '4. close': '100.3100', ...}, ...}}

def _read_lines(self, out):
    data = super(AVTimeSeriesReader, self)._read_lines(out)
    # reverse since alphavantage returns descending by date
    data = data[::-1]
    start_str = self.start.strftime("%Y-%m-%d")
    end_str = self.end.strftime("%Y-%m-%d")
    data = data.loc[start_str:end_str]
    if data.empty:
      raise ValueError("Please input a valid date range")

E ValueError: Please input a valid date range

../../av/time_series.py:112: ValueError

Best regards

arne

@aGrimRepoMan
Copy link

@jzaiwei
Copy link

jzaiwei commented May 2, 2020

I have the same problem, how to fix it ? The 662 issues is disappeared

Lambdac0re added a commit to Lambdac0re/pandas-datareader that referenced this issue Mar 1, 2021
@Lambdac0re Lambdac0re linked a pull request Mar 1, 2021 that will close this issue
5 tasks
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

Successfully merging a pull request may close this issue.

3 participants