I have a fever... and the only prescription is checking for the opening bell at 4.5 GHz.

This might be the first thing you wanted to know or it might be the last thing you realized you needed to know, but this information is essential to anyone using a computer to trade or analyze stocks. Luckily, it is trivial to query this using python and you can use the repl below to find out right now or you can use the code in your own project.

You will need: datetime, pytz, holidays
To install, just google pip pytz or pip holidays and you'll find all the info you need.

Once we have these packages installed (datetime should already be isntalled by default) we can set our timezone and the hours that the market is normally open, unless there is a holiday.

This script returns when the market is closed as AfterHours=True

I do want to give some props to u/numbah-0 who published the basis of this code on Reddit.

If you're new to programming, try to fork this repl and slow it down by importing time and inserting time.sleep() someplace. If you just want to check if the market is open, press the green arrow.


Previous Posts

« 1 2 3 4 5 »

FYI! Use the contact form below to initiate all other requests for services or consulting. Options include custom financial or risk analysis, currency pairs, inventory management, etc.

Contact Let us know what you think, if you find a bug, or would like to initiate a project: