Avoiding Non-Trading Dates in Scheduled Daily Backtests
Summary
This post describes a scheduling problem in a daily China-stock simulation: a strategy launched at 5 a.m. after a weekend or holiday may use the previous calendar day as both its start and end date. Because that date has no market session, the run fails. The author recommends setting the simulation window to the most recent trading day, using a platform function to determine that date if available.
The post illustrates the issue by comparing a run using the prior Friday with one using Sunday. The Sunday example reports a missing-session error followed by a KeyError involving a cash field; the Friday run is reported to complete without error. This is a troubleshooting report rather than a detailed explanation of the platform’s internals or a verified fix for every data source. Calendar adjustments in source data may affect results, so scheduled simulations should align their date range with the relevant market calendar and confirm how the platform handles holidays.
Key ideas
- A daily simulation scheduled after a weekend can select a calendar date with no trading session.
- A start and end date on a non-trading day may cause the run to fail.
- The post recommends deriving the simulation date from the latest trading day.
- The example contrasts a reported successful Friday run with a failed Sunday run.
- Holiday calendars and source data can affect which date should be used.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.