How do I get the live option chain (every minute or if possible, every second)? Also, I want to refresh my excel each time which contains this data (exported from Python) so that charts can be refreshed?
I have written this below code to fetch the end of day data:
#spot market inputs
s_ticker = "ITC"
start_date = date(2020,12,7)
end_date = date(2021,1,15)
expiry_date = date(2021,1,28)
#option market inputs
option_tick = 5
coverage = 100
atm_strike = 215
ce_type = "CE"
pe_type = "PE"
#special attributes
ce_strike = atm_strike
ce_strike_min = ce_strike - coverage
ce_strike_max = ce_strike + coverage
pe_strike = atm_strike
pe_strike_min = pe_strike - coverage
pe_strike_max = pe_strike + coverage
#data fetching
ce_df_exp = pd.DataFrame()
ce_strike_temp = ce_strike_min
while (ce_strike_temp < ce_strike_max):
ce_df = get_history(symbol=s_ticker,
start=start_date,
end=end_date,
option_type=ce_type,
strike_price=ce_strike_temp,
expiry_date=expiry_date)
temp1 = ce_df
ce_df_exp = ce_df_exp.append(temp1.tail(1))
temp1 = pd.DataFrame()
ce_strike_temp = ce_strike_temp + option_tick
ce_df_exp