Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
get_early_closes function

Here's some code that uses the Quantopian get_early_closes utility function to detect if the market will close early, due to a planned closing. I ran the backtest on daily data, but the idea is to use get_early_closes when running on minute data to flag when the market will close at 1 pm.

The log output, showing the days when the market closed early over the time period of the backtest:

2012-07-03 PRINT 2012-07-03
2012-11-23 PRINT 2012-11-23
2012-12-24 PRINT 2012-12-24
2013-07-03 PRINT 2013-07-03
End of logs.

Grant

2 responses

Interesting. Were early closes causing problems for your other algos?

The question of closing out positions prior to the market close had come up several times on the forum. I posted a question regarding market-on-close orders (https://www.quantopian.com/posts/market-on-close-moc-orders) and found out about the get_early_closes function.