Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
What will happen if today is not a trading day?
schedule_function(ordering_logic,date_rule=date_rules.every_day(),time_rule=time_rules.market_close((hours=0, minutes=1))  

It just occurs to me in a backtesting environment what will happen if today is thanksgiving, Will the schedule_function be skipped so the ordering_logic won't be called today?

What happens if it's the real trading environment?

2 responses

Yes, logic scheduled with schedule_function will only run on trading days (see https://www.quantopian.com/help#api-schedulefunction) Note that you can also add a half_days parameter to have it not run on half trading days (eg the day after Thanksgiving). before_trading_start runs before every trading day. Look at the logs in the attached backtest to verify this behavior for last Thanksgiving.

I use the fact that before_trading_start only runs on trading days to increment a days_held counter for each of my positions. This is MUCH easier than trying to store the date and do date calculations and knowing when the markets are open.

This is also true in real IB trading and assume it's true in Robinhood (haven't actually tried Robinhood though).

thank you