Last active
January 6, 2016 18:12
-
-
Save robdmc/d6582edc4ec7b10e653d to your computer and use it in GitHub Desktop.
options data from yahoo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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