quantopian / trading_calendars

Calendars for various securities exchanges.
Apache License 2.0
607 stars 374 forks source link

Need help for creating holiday calendar for India #26

Open half-nirvana opened 5 years ago

half-nirvana commented 5 years ago

Here's the list of holidays for NSE. Problem is, there are some holidays which follow Gregorian calendar (eg. Republic day, Independence day, Mahatama Gandhi Jayanti etc), some holidays which follow Hindu Calendars (eg. Diwali, Holi) and few holidays follow Islamic calendar (Ramzan, Eid)

How to deal with this. One option I could think is work backwards from data. Take the data of a stock which has traded longest and then figure out holidays based on it.

I am looking at hk branch but have not been able to figure out any solution yet.

Any help on this will be appreciated.

Thanks

llllllllll commented 5 years ago

Hey, I am the person who worked on the Hong Kong calendar. I plan on implementing the NSE calendar as well as the Singapore SGX calendar either this week or next week. I will likely use something similar to the code on the hk branch's etc/lunisolar to compute the holidays based on actual lunisolar rules.

swapniljariwala commented 5 years ago

Great!! Thanks!!

half-nirvana commented 5 years ago

Hey Thanks! How can I help!

half-nirvana commented 5 years ago

Hi @llllllllll, I checked out hk branch. I ran all the tests successfully (except few memory 'out of memory errors', probably because I'm running it in a VM with limited memory)

I'm trying to run python etc/lunisolar new-moon but I'm getting an error FileNotFoundError: [Errno 2] No such file or directory: 'solar-ecliptic-longitude'

llllllllll commented 5 years ago

The lunisolar tool works by calculating the ecliptic longitude of the sun and moon to derive the new moons and solar terms. That process currently takes like 40 minutes to an hour so there are two entry points:

  1. solar-ecliptic-longitude
  2. lunar-ecliptic-longitude

that compute these values and save them to disk. The other commands then read the data in these directories to do further processing. This currently computes the new moons and solar terms at minute resolution (UTC) so you can convert them to the appropriate time zone to determine which date they fall on. For example, the Chinese lunisolar calendar says that the day. midnight to midnight UTC+8, that contains the new moon is the start of the month. I am not sure what rules the Indian calendar uses but it should be possible to encode them given this data.

suryafx commented 5 years ago

I added NSE calendar for India. (XNSE) Holidays are back dated from 2010 to 2019.

60