Пример #1
0
def get_surf(ticker):
    q = Options(ticker, 'yahoo').get_all_data()
    q.reset_index(inplace=True)
    q.set_index('Symbol', inplace=True)
    vals = []
    print(q.head())
    #Iterate through the DataFrame pulled from the API
    for index, row in q.iterrows():
        if row['Type'] == 'put':
            underlying = float(row['Underlying_Price'])
            #Midpoint of bid/ask spread
            price = (float(row['Ask']) + float(row['Bid'])) / 2.0
            exp_d = (row['Expiry'] - datetime.now()).days
            exp_s = (row['Expiry'] - datetime.now()).seconds
            exp = (exp_d * 24 * 3600 + exp_s) / (365 * 24 * 3600)
            try:
                #Calculate the implied volatility
                impl = calc_impl_vol(price, 'p', underlying,
                                     float(row['Strike']), exp)
                vals.append([exp, float(row['Strike']), impl])
            except:
                pass
    vals = array(vals).T
    combine_plots(vals[0], vals[1], vals[2])
Пример #2
0
def get_one_ticker():
    ticker=company.get()
    option_data = Options(ticker,data_source='yahoo').get_all_data()
    option_data.reset_index(inplace=True)
    option_data.drop('JSON', axis=1, inplace=True)
    print option_data
Пример #3
0
def get_one_ticker(one_ticker_name):
    option_data = Options(one_ticker_name,data_source='yahoo').get_all_data()
    option_data.reset_index(inplace=True)
    option_data.drop('JSON', axis=1, inplace=True)
    r=clean(option_data)
    return r