Does your strategy know when the market closes?

There is one very important automated trading system that is often overlooked: the management of trading hours.

I get the impression quite often that possible variations in trading times get completely ignored by many strategy developers. When talking to other strategy developers or reading blogs, the focus is most of the time about the selection of the right indicators, or about the optimal entry and exit level for a transaction. But much more important is full control over trading hours. Especially for a day trader who has to be out of the market at the end of the trading session. The general assumption is that there is a fixed open and close time – and that the platform will take care to close positions in time. Sadly, that does not work – at least not always.

First, trading hours do fluctuate. They are not fixed – sometimes markets close early, most of the time in relations to holidays. This is particularly dangerous because it often means more than a weekend of closed markets, which may lead to a significant profit or – a loss way higher than the allowed maximum loss (and on top some not so nice discussions with the broker, significant raised margins and possibly just a lot of trouble).

To demonstrate the issue, just have a look at this CME Holiday Calendar, where each holiday has a separate document describing the trading times on certain days.

Especially when day trading, there often are significant reduced margin requirements – and a high leverage. Getting stuck in a closed market, often for more than even the possibly disastrous 2 days of a weekend, is not acceptable.

The CME has quite some holidays with specific trading hours

We are solving this problem at Trade-Robots, through our Reflexo Trading Framework, which has an integrated calendar containing the on out-of-norm trading hours. This integrates with a session API that informs us about session start and end times and allows a strategy to intelligently react to those changed trading times. This is a mechanism that NinjaTrader has just announced for their version 8, where they also will handle variable opening and closing times in their (centrally maintained) symbol database.

Naturally it requires manual intervention - changed trading hours are sadly not available in a standardized electronic form and must be maintained manually, in advance. But the integrated API makes sure that a strategy always has access to the trading hours as they are in the database.

On top of that, our analysis framework allows us to easily identify trades that spawn more than one session with a query – one advantage of our approach of keeping all back test results in a database. And, because it is one of the fundamental design decisions we made when creating our Reflexo framework, even longer term strategies must be out of the market on Saturday. Our tests always run in separate independent tasks that start on Sunday and end on the next Saturday and we assume that the strategy is flat on the weekend. As such, a strategy that is not flat at the end of a test interval – is a technical error and shows up as such in a back test.

And it happens again and again that we find strategies and trades that have not been closed according to the rules. Bugs, technical issues that must be fixed. And that totally invalidate the result of any back test. They often show up, for example, because the loss of such a trade is a lot larger than the allowed maximum loss – which indicates that the stop did not execute and a position was not closed in time, and the market moved significantly without a possible trade before opening again at a later time. And most of the time, that was because an error or omission in our historical trading times database – so the strategy was not aware that the market closes early.

Therefore, fellow strategy developer, know your trading times. Also around holidays.