TradeViaPython / Kite_Zerodha

173 stars 109 forks source link

Get Historical Data not update in while loop... every time same json output ... #24

Open shirishaardak opened 11 months ago

shirishaardak commented 11 months ago

for Ex. instrument_token = 9604354 from_datetime = datetime.datetime.now() - datetime.timedelta(days=7) # From last & days to_datetime = datetime.datetime.now() interval = "5minute" while True: t.sleep(1) if datetime.now().minute % 5 == 0 and datetime.now().second == 10: get_data = kite.historical_data(instrument_token, from_datetime, to_datetime, interval, continuous=False, oi=False)
print(get_data)

Pravinjd2796 commented 10 months ago

Are you able to get the historical data using enctoken?

Anirudh-12 commented 10 months ago

you need to update from_datetime and to_datetime variables here is the modified code

instrument_token = 9604354
from_datetime = datetime.datetime.now() - datetime.timedelta(days=7) # From last & days

interval = "5minute"
while True:
    t.sleep(1)
    if datetime.now().minute % 5 == 0 and datetime.now().second == 10:
          to_datetime = datetime.datetime.now()
          get_data = kite.historical_data(instrument_token, from_datetime, to_datetime, interval, continuous=False, oi=False)
print(get_data)
shirishaardak commented 10 months ago

Are you able to get the historical data using enctoken?

Yes for 30 days only

shirishaardak commented 10 months ago

you need to update from_datetime and to_datetime variables here is the modified code

instrument_token = 9604354
from_datetime = datetime.datetime.now() - datetime.timedelta(days=7) # From last & days

interval = "5minute"
while True:
    t.sleep(1)
    if datetime.now().minute % 5 == 0 and datetime.now().second == 10:
          to_datetime = datetime.datetime.now()
          get_data = kite.historical_data(instrument_token, from_datetime, to_datetime, interval, continuous=False, oi=False)
print(get_data)

Thank A lot.... it work for me

Pravinjd2796 commented 10 months ago

Thank you @shirishaardak

AnubhavSaini25 commented 1 month ago

Hlo how can i get the instrument token for other things like stock