It looks like you're new here. If you want to get involved, click one of these buttons!
while True:
try:
if from_date.date() >= (dt.date.today() - dt.timedelta(duration)):
data = data.append(pd.DataFrame(kite.historical_data(instrument, from_date, dt.date.today(), interval)), ignore_index=True)
time.sleep(1)
break
else:
to_date = from_date + dt.timedelta(duration)
data = data.append(pd.DataFrame(kite.historical_data(instrument, from_date, to_date, interval)), ignore_index=True)
time.sleep(1)
from_date = to_date
break
except kite_exceptions.DataException as e:
print("Caught DataException:", e)
print("Retrying after 1 second...")
time.sleep(1)
continue