Kotak-Neo / kotak-neo-api

100 stars 86 forks source link

scrip master expiry date #37

Closed Devdattathube closed 10 months ago

Devdattathube commented 11 months ago

please help on the format of expiry date in scrip master file. i am not able to figure out in which format is the expiry date

syedasif11 commented 11 months ago

Expiry date is in epoch. This is the code I am using after loading file into pandas dataframe;

for _, row in df.iterrows():
  expiry = datetime.datetime.fromtimestamp(row['pExpiryDate'])
  if expiry.year < datetime.datetime.now().year:
      expiry = date(expiry.year + 10, expiry.month, expiry.day)

Note that epoch starts from Jan 1, 1970 but for some reason the file considers the epoch starting from Jan 1, 1980. So, I am manually adding 10 years. Hope it helps.

Devdattathube commented 11 months ago

can you please tell me how the expiry date will be unaffected by the leap year?

Kotak-Neo commented 10 months ago

The expiry dates are in epoch format, after converting it you need to add 10 years to it to get the actual expiry. Hope it helps.