Skip to content

Yahoo Finance Options tests raises ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y' #63

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

Closed
femtotrader opened this issue Aug 22, 2015 · 7 comments
Milestone

Comments

@femtotrader
Copy link
Contributor

Hello,

some Yahoo Finance Options tests raises

ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

I can see this exception using

$ nosetests -s -v

======================================================================
ERROR: test_get_all_data (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 358, in test_get_all_data
    data = self.aapl.get_all_data(put=True)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1197, in get_all_data
    expiry_dates = self.expiry_dates
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_all_data_calls_only (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 372, in test_get_all_data_calls_only
    data = self.aapl.get_all_data(call=True, put=False)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1197, in get_all_data
    expiry_dates = self.expiry_dates
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_call_data (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 337, in test_get_call_data
    calls = self.aapl.get_call_data(expiry=self.expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 901, in get_call_data
    expiry = self._try_parse_dates(year, month, expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1061, in _try_parse_dates
    expiry = [self._validate_expiry(expiry)]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1085, in _validate_expiry
    expiry_dates = self.expiry_dates
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_data_with_list (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 365, in test_get_data_with_list
    data = self.aapl.get_call_data(expiry=self.aapl.expiry_dates)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_expiry_dates (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 351, in test_get_expiry_dates
    dates, _ = self.aapl._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_near_stock_price (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 330, in test_get_near_stock_price
    expiry=self.expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1005, in get_near_stock_price
    expiry = self._try_parse_dates(year, month, expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1061, in _try_parse_dates
    expiry = [self._validate_expiry(expiry)]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1085, in _validate_expiry
    expiry_dates = self.expiry_dates
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_options_data (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 322, in test_get_options_data
    options = self.aapl.get_options_data(expiry=self.expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 750, in get_options_data
    self.get_call_data)]).sortlevel()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 749, in <listcomp>
    for f in (self.get_put_data,
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 964, in get_put_data
    expiry = self._try_parse_dates(year, month, expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1061, in _try_parse_dates
    expiry = [self._validate_expiry(expiry)]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1085, in _validate_expiry
    expiry_dates = self.expiry_dates
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_put_data (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 344, in test_get_put_data
    puts = self.aapl.get_put_data(expiry=self.expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 964, in get_put_data
    expiry = self._try_parse_dates(year, month, expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1061, in _try_parse_dates
    expiry = [self._validate_expiry(expiry)]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1085, in _validate_expiry
    expiry_dates = self.expiry_dates
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_get_underlying_price (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 381, in test_get_underlying_price
    url = options_object._yahoo_url_from_expiry(options_object.expiry_dates[0])
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'September 18, 2015' does not match format '%B %d, %Y'

======================================================================
ERROR: test_month_year (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1226, in expiry_dates
    expiry_dates = self._expiry_dates
AttributeError: 'Options' object has no attribute '_expiry_dates'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/tests/test_data.py", line 421, in test_month_year
    data = self.aapl.get_call_data(month=self.month, year=self.year)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 901, in get_call_data
    expiry = self._try_parse_dates(year, month, expiry)
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1075, in _try_parse_dates
    expiry = [expiry for expiry in self.expiry_dates if expiry.year == year and expiry.month == month]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1228, in expiry_dates
    expiry_dates, _ = self._get_expiry_dates_and_links()
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in _get_expiry_dates_and_links
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "/Users/femto/github/others/pandas-datareader/pandas_datareader/data.py", line 1250, in <listcomp>
    expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links]
  File "//anaconda/lib/python3.4/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "//anaconda/lib/python3.4/_strptime.py", line 337, in _strptime
    (data_string, format))
ValueError: time data 'August 28, 2015' does not match format '%B %d, %Y'

but

$ nosetests -s -v pandas_datareader/tests/test_data.py:TestYahooOptions.test_get_all_data

don't raises any error !

Any idea ?

@femtotrader
Copy link
Contributor Author

There is also some

AttributeError: 'Options' object has no attribute '_expiry_dates'

@femtotrader
Copy link
Contributor Author

and some

AssertionError: False is not true


FAIL: test_sample_page_price_quote_time1 (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/femto/pandas-datareader/pandas_datareader/tests/test_data.py", line 392, in test_sample_page_price_quote_time1
    self.assert_(isinstance(quote_time, (datetime, Timestamp)))
  File "//anaconda/lib/python3.4/site-packages/pandas/util/testing.py", line 92, in assert_
    return deprecate('assert_', self.assertTrue)(*args, **kwargs)
  File "//anaconda/lib/python3.4/site-packages/pandas/util/decorators.py", line 14, in wrapper
    return alternative(*args, **kwargs)
AssertionError: False is not true

======================================================================
FAIL: test_sample_page_price_quote_time2 (test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/femto/github/femto/pandas-datareader/pandas_datareader/tests/test_data.py", line 413, in test_sample_page_price_quote_time2
    self.assert_(isinstance(quote_time, (datetime, Timestamp)))
  File "//anaconda/lib/python3.4/site-packages/pandas/util/testing.py", line 92, in assert_
    return deprecate('assert_', self.assertTrue)(*args, **kwargs)
  File "//anaconda/lib/python3.4/site-packages/pandas/util/decorators.py", line 14, in wrapper
    return alternative(*args, **kwargs)
AssertionError: False is not true

@davidastephens
Copy link
Member

I think this is a locale issue. %B matches Month as locale’s full name, you are getting the english month full name. I wonder if there is a way to force a specific language on strptime.

@davidastephens davidastephens added this to the Someday milestone Aug 23, 2015
@femtotrader
Copy link
Contributor Author

@davidastephens
Copy link
Member

@femtotrader is this fixed now with #244?

@femtotrader
Copy link
Contributor Author

femtotrader commented Jan 9, 2017

I think it's (was) a locale issue.
as tests were not passing on my system but were passing on Travis.
But I don't use this DataReader so that's not 100% sure.

@femtotrader
Copy link
Contributor Author

I can confirm now that it's fixed.
So I'm closing

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

2 participants