Skip to content

Instantly share code, notes, and snippets.

@robdmc
Last active January 6, 2016 18:12
Show Gist options
  • Save robdmc/d6582edc4ec7b10e653d to your computer and use it in GitHub Desktop.
Save robdmc/d6582edc4ec7b10e653d to your computer and use it in GitHub Desktop.
options data from yahoo
# content for ipython notebook
%matplotlib inline
execfile('/Users/rob/pandasSetup.py')
import mpld3
mpld3.enable_notebook()
from pandas_datareader.data import Options
options = Options('spy', 'yahoo')
expiry_dates = options.expiry_dates
df = options.get_options_data(expiry=expiry_dates[0]).reset_index()
def make_plot(df):
for kind in ['put', 'call']:
dfx = df[df.Type==kind]
bid_label = '{} bid'.format(kind)
x = dfx.Strike - dfx.Underlying_Price
y = dfx.Bid
pl.plot(x, y, '.-', label=bid_label)
pl.xlabel('strike - current')
pl.legend(loc='best')
make_plot(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment