Skip to content

Commit 16f13c1

Browse files
author
y-p
committed
Merge pull request #6114 from y-p/PR_GH6105
BUG: get_options_data should validate it's arguments GH6105
2 parents 6ed863a + c55511b commit 16f13c1

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ Bug Fixes
156156
- Subtle ``iloc`` indexing bug, surfaced in (:issue:`6059`)
157157
- Bug with insert of strings into DatetimeIndex (:issue:`5818`)
158158
- Fixed unicode bug in to_html/HTML repr (:issue:`6098`)
159+
- Fixed missing arg validation in get_options_data (:issue:`6105`)
159160

160161
pandas 0.13.0
161162
-------------

pandas/io/data.py

+4
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,10 @@ def get_options_data(self, month=None, year=None, expiry=None):
632632
_OPTIONS_BASE_URL = 'http://finance.yahoo.com/q/op?s={sym}'
633633

634634
def _get_option_data(self, month, year, expiry, table_loc, name):
635+
if (month is None or year is None) and expiry is None:
636+
msg = "You must specify either (`year` and `month`) or `expiry`."
637+
raise ValueError(msg)
638+
635639
year, month = self._try_parse_dates(year, month, expiry)
636640

637641
url = self._OPTIONS_BASE_URL.format(sym=self.symbol)

pandas/io/tests/test_data.py

+6
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ def test_get_options_data(self):
266266
assert len(calls)>1
267267
assert len(puts)>1
268268

269+
def test_get_options_data(self):
270+
271+
# regression test GH6105
272+
self.assertRaises(ValueError,self.aapl.get_options_data,month=3)
273+
self.assertRaises(ValueError,self.aapl.get_options_data,year=1992)
274+
269275
@network
270276
def test_get_near_stock_price(self):
271277
try:

0 commit comments

Comments
 (0)