1

我想一次性下载多个执行价格的数据。以下功能按预期工作,但适用于单一执行价格。

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!'

有没有办法传递多个执行价格?我正在关注此链接,但无法解决。

4

0 回答 0