Is there any way we can find out that this moment market is open or not?
I want to add this code so that my algorithm doesnot run when there is a holiday on weekday or if its a mocktrading day.
I can parse the nse site and find out if market is open or close but was wondering if we can find that via kite connect python api.
am sure there is no such function available but was wondering if there is any workaround jugaad or trick so that we can find out the market is live or not?
maybe if livestraming is null? = market is closed?
Hey, You'd mentioned in June 2017, that you intend to stream market status in future. Any update here ? If not, what do you recommend ? What's the workaround here ?
You can compare the current date with the dates returned from this function. and check for if the current day is sat and sun and stop trading accordingly, this is how I currently do it. You can update the holiday list every year
@vandanchopra No, it's still not live. For time being, we will recommend you to create holiday calender list at your end and don't run your program on those day's.Something as below:
@ZI4453 Adding all weekends in array is an inefficient style of programming when you can check today with weekday number and identity if weekend or not. Request was only for Holidays response.
Anyway, I have modified the code. Now it just returns True / False. Function is trading_day()
If True means you can trade and if False, means you cannot trade. So nothing can now become simpler than this
There might be a simpler but more robust way to do this. Download historical data for NIFTY 50 index for the last 2 days till today. Run after market open. If the last date = today, then the market is open, else market is closed.
https://github.com/anandanand84/nse-market-holidays
If not, what do you recommend ? What's the workaround here ?
h_list = open(config.HOLIDAY_LIST_FILE, 'r')
holiday_list = []
for i in h_list.readlines():
if i.strip() != '':
holiday_list.append(i.strip())
return holiday_list
No, it's still not live.
For time being, we will recommend you to create holiday calender list at your end and don't run your program on those day's.Something as below:
You can import in your program and use it like
if today not in holidays():
os.exit(1)
Code at
https://github.com/tahseenjamal/nse_holidays
@tahseen
Adding all weekends in array is an inefficient style of programming when you can check today with weekday number and identity if weekend or not. Request was only for Holidays response.
Anyway, I have modified the code. Now it just returns True / False. Function is trading_day()
If True means you can trade and if False, means you cannot trade. So nothing can now become simpler than this
Enjoy!!
Tahseen