Skip to content

Commit 836e760

Browse files
BUG: Test for underlying price before reducing data
Removed most references to month and year (passing expiry date around instead). Also protected with RemoteDataError checking for the expiry month links.
1 parent 43e270c commit 836e760

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/io/data.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,13 +907,14 @@ def get_near_stock_price(self, above_below=2, call=True, put=False,
907907
meth_name = 'get_{0}_data'.format(nam[:-1])
908908
df = getattr(self, meth_name)(expiry=expiry)
909909

910-
start_index = np.where(df.index.get_level_values('Strike')
910+
if self.underlying_price:
911+
start_index = np.where(df.index.get_level_values('Strike')
911912
> self.underlying_price)[0][0]
912913

913-
get_range = slice(start_index - above_below,
914+
get_range = slice(start_index - above_below,
914915
start_index + above_below + 1)
915-
chop = df[get_range].dropna(how='all')
916-
data[nam] = chop
916+
chop = df[get_range].dropna(how='all')
917+
data[nam] = chop
917918

918919
return concat([data[nam] for nam in to_ret]).sortlevel()
919920

0 commit comments

Comments
 (0)