Skip to content

BUG: get_options_data should validate it's arguments GH6105 #6114

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
2 commits merged into from Jan 27, 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
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Bug Fixes
- Subtle ``iloc`` indexing bug, surfaced in (:issue:`6059`)
- Bug with insert of strings into DatetimeIndex (:issue:`5818`)
- Fixed unicode bug in to_html/HTML repr (:issue:`6098`)
- Fixed missing arg validation in get_options_data (:issue:`6105`)

pandas 0.13.0
-------------
Expand Down
4 changes: 4 additions & 0 deletions pandas/io/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ def get_options_data(self, month=None, year=None, expiry=None):
_OPTIONS_BASE_URL = 'http://finance.yahoo.com/q/op?s={sym}'

def _get_option_data(self, month, year, expiry, table_loc, name):
if (month is None or year is None) and expiry is None:
msg = "You must specify either (`year` and `month`) or `expiry`."
raise ValueError(msg)

year, month = self._try_parse_dates(year, month, expiry)

url = self._OPTIONS_BASE_URL.format(sym=self.symbol)
Expand Down
6 changes: 6 additions & 0 deletions pandas/io/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def test_get_options_data(self):
assert len(calls)>1
assert len(puts)>1

def test_get_options_data(self):

# regression test GH6105
self.assertRaises(ValueError,self.aapl.get_options_data,month=3)
self.assertRaises(ValueError,self.aapl.get_options_data,year=1992)

@network
def test_get_near_stock_price(self):
try:
Expand Down