1

I want to download the data in one go for multiple strike prices. Below function works as expected but for single strike price.

def download_nifty_option_data(self):
    expiry_date_prev_month = get_expiry_date(year=2018, month=11)
    #Adding one day
    expiry_date_prev_month = expiry_date_prev_month + datetime.timedelta(days=1)

    expiry_date_this_month = get_expiry_date(year=2018, month=12)
    print expiry_date_this_month

    date1 = datetime.datetime.strptime(str(expiry_date_prev_month), "%Y-%m-%d")
    date2 = datetime.datetime.strptime(str(expiry_date_this_month), "%Y-%m-%d")

    nifty_opt = get_history(symbol="NIFTY",
                            start=date(date1.year, date1.month, date1.day),
                            end=date(date2.year, date2.month, date2.day),
                            index=True,
                            option_type='CE',
                            strike_price=10900,
                            expiry_date=date(2018, 12, 27))

    #nifty = get_history(symbol="NIFTY", start=date(2015, 1, 1), end=date(2018, 12, 13), index=True)
    nifty_opt.to_csv(self.download_dir + 'nifty_opt.csv', index=True)
    print 'Data downloaded successfully!'

Is there any way to pass multiple strike prices? I am following this link but couldn't solution there.

Devesh Agrawal
  • 8,982
  • 16
  • 82
  • 131

0 Answers0