Skip to content

Commit 04d93cf

Browse files
committed
Merge pull request #8741 from dstephens99/issue8612
BUG: Fix io.data.Options quote time for DST.
2 parents 24e3ba2 + bddec83 commit 04d93cf

File tree

4 files changed

+812
-729
lines changed

4 files changed

+812
-729
lines changed

doc/source/whatsnew/v0.15.1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ API changes
170170
- added Index properties `is_monotonic_increasing` and `is_monotonic_decreasing` (:issue:`8680`).
171171

172172

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

175175
As a result of a change in Yahoo's option page layout, when an expiry date is given,
176176
``Options`` methods now return data for a single expiry date. Previously, methods returned all

pandas/io/data.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,13 @@ def _get_underlying_price(self, url):
698698
#Gets the time of the quote, note this is actually the time of the underlying price.
699699
try:
700700
quote_time_text = root.xpath('.//*[@class="time_rtq Fz-m"]')[0].getchildren()[1].getchildren()[0].text
701-
quote_time = dt.datetime.strptime(quote_time_text, "%I:%M%p EDT")
701+
##TODO: Enable timezone matching when strptime can match EST with %Z
702+
quote_time_text = quote_time_text.split(' ')[0]
703+
quote_time = dt.datetime.strptime(quote_time_text, "%I:%M%p")
704+
702705
quote_time = quote_time.replace(year=CUR_YEAR, month=CUR_MONTH, day=CUR_DAY)
703706
except ValueError:
704-
raise RemoteDataError('Unable to determine time of quote for page %s' % url)
707+
quote_time = np.nan
705708

706709
return underlying_price, quote_time
707710

pandas/io/tests/data/yahoo_options2.html

+804-725
Large diffs are not rendered by default.

pandas/io/tests/test_data.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ def test_chop_out_of_strike_range(self):
354354

355355
@network
356356
def test_sample_page_price_quote_time2(self):
357-
#Tests the weekday quote time format
357+
#Tests the EDT page format
358+
#regression test for #8741
358359
price, quote_time = self.aapl._get_underlying_price(self.html2)
359360
self.assertIsInstance(price, (int, float, complex))
360361
self.assertIsInstance(quote_time, (datetime, Timestamp))

0 commit comments

Comments
 (0)