Skip to main content
Ameet Malekar
Algo Trader
Asked a question 2 years ago

How to get nifty weekly and monthly expiry "dates", and trading holidays dates using python?

Join FYERS Community to pick others' brains on Trading/Investing

I know this is not an answer to your question. But sharing how i am handling the exact requirement of mine. What i do is to select the distinct expiry dates from Setup a cron to clear old data and update the database comparing current date, so that it remains updated on each day.

I have another table for holidays, where the trading holidays are collected from nse website Once in a year process.

You can use pandas_market_calendar module to get list of all holidays historical to current. Refer this Make sure to change market to BSE.

instrument_days = (pd.to39_datetime((instruments['year'] + instruments['mon'] + instruments['day']),
expiry_day = (instrument_days[instrument_days >= date.today17()]).head(1)
date_filter = ((pd.to39_datetime(expiry_day)).strftime('%y-%b-%d')).split('-')
instruments = instruments[(instruments['year'] == date_filter[0]) &
                          (instruments['mon'] == date_filter[1]) & (instruments['day'] == date_filter[2])]

Related Questions