Backtesting a Strategy for long periods of time (e.g. years) can be very time consuming.
You can speed things up during long backtesting runs by adding code to your Java Strategy that will skip over times when your selected Instrument's Market is Closed, like this:


public ITimeDomain curWeekend = null;

long time = bidBar.getTime();
if (engine.getType() == IEngine.Type.TEST) {
if (curWeekend == null) curWeekend = context.getDataService().getOfflineTimeDomain(instrument);
if (time >= curWeekend.getStart() && time < curWeekend.getEnd()) return;
if (time >= curWeekend.getEnd()) curWeekend = context.getDataService().getOfflineTimeDomain(instrument);
}
Traducir a inglés Mostrar original