Skip to content

BUG: Fix io.data.Options quote time for DST. #8741

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

Merged
merged 1 commit into from
Nov 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.15.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ API changes
- added Index properties `is_monotonic_increasing` and `is_monotonic_decreasing` (:issue:`8680`).


.. note:: io.data.Options has been fixed for a change in the format of the Yahoo Options page (:issue:`8612`)
.. note:: io.data.Options has been fixed for a change in the format of the Yahoo Options page (:issue:`8612`), (:issue:`8741`)

As a result of a change in Yahoo's option page layout, when an expiry date is given,
``Options`` methods now return data for a single expiry date. Previously, methods returned all
Expand Down
7 changes: 5 additions & 2 deletions pandas/io/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,13 @@ def _get_underlying_price(self, url):
#Gets the time of the quote, note this is actually the time of the underlying price.
try:
quote_time_text = root.xpath('.//*[@class="time_rtq Fz-m"]')[0].getchildren()[1].getchildren()[0].text
quote_time = dt.datetime.strptime(quote_time_text, "%I:%M%p EDT")
##TODO: Enable timezone matching when strptime can match EST with %Z
quote_time_text = quote_time_text.split(' ')[0]
quote_time = dt.datetime.strptime(quote_time_text, "%I:%M%p")

quote_time = quote_time.replace(year=CUR_YEAR, month=CUR_MONTH, day=CUR_DAY)
except ValueError:
raise RemoteDataError('Unable to determine time of quote for page %s' % url)
quote_time = np.nan

return underlying_price, quote_time

Expand Down
1,529 changes: 804 additions & 725 deletions pandas/io/tests/data/yahoo_options2.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pandas/io/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ def test_chop_out_of_strike_range(self):

@network
def test_sample_page_price_quote_time2(self):
#Tests the weekday quote time format
#Tests the EDT page format
#regression test for #8741
price, quote_time = self.aapl._get_underlying_price(self.html2)
self.assertIsInstance(price, (int, float, complex))
self.assertIsInstance(quote_time, (datetime, Timestamp))
Expand Down