Skip to content

Commit 7b5bc4a

Browse files
Merge pull request #274 from davidastephens/option_types
BUG: Fix breaking API change in yahoo options
2 parents 10d967c + d66567a commit 7b5bc4a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

pandas_datareader/tests/test_google_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def test_get_options_data(self):
4444

4545
self.assert_option_result(options)
4646

47+
for typ in options.index.levels[2]:
48+
self.assertTrue(typ in ['put', 'call'])
49+
4750
def test_get_options_data_yearmonth(self):
4851
with tm.assertRaises(NotImplementedError):
4952
self.goog.get_options_data(month=1, year=2016)

pandas_datareader/tests/test_yahoo_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_get_call_data(self):
9090
raise nose.SkipTest(e)
9191

9292
self.assert_option_result(calls)
93+
self.assertTrue(calls.index.levels[2][0], 'call')
9394

9495
def test_get_put_data(self):
9596
try:
@@ -98,6 +99,7 @@ def test_get_put_data(self):
9899
raise nose.SkipTest(e)
99100

100101
self.assert_option_result(puts)
102+
self.assertTrue(puts.index.levels[2][0], 'put')
101103

102104
def test_get_expiry_dates(self):
103105
try:
@@ -169,6 +171,7 @@ def test_sample_page_chg_float(self):
169171
self.assertEqual(self.data1['Chg'].dtype, 'float64')
170172

171173
def test_month_year(self):
174+
172175
try:
173176
data = self.aapl.get_call_data(month=self.month, year=self.year)
174177
except RemoteDataError as e: # pragma: no cover

pandas_datareader/yahoo/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def get_all_data(self, call=True, put=True):
570570

571571
def _get_data_in_date_range(self, dates, call=True, put=True):
572572

573-
to_ret = Series({'calls': call, 'puts': put})
573+
to_ret = Series({'call': call, 'put': put})
574574
to_ret = to_ret[to_ret].index
575575

576576
df = self._load_data(dates)
@@ -735,7 +735,7 @@ def _process_rows(self, jd):
735735
rows_list.append(d)
736736
index.append((float(option_by_strike['strike']),
737737
dt.datetime.utcfromtimestamp(option_by_strike['expiration']),
738-
typ,
738+
typ.replace('s', ''),
739739
option_by_strike['contractSymbol']))
740740
return rows_list, index
741741

0 commit comments

Comments
 (0)