The code and the Strategy Log are attached.
The question is:
If the line 31 of the code is correct why does the line 37 (with the same code) throw an exception?
package jforex;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;
import java.io.PrintStream;
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;
public class JFTestGetBarsOnWeekend implements IStrategy {
@Override
public void onStart(IContext context) throws JFException {
PrintStream out = context.getConsole().getOut();
IHistory history = context.getHistory();
Instrument instrument = Instrument.GBPUSD;
Period period = Period.ONE_MIN;
context.setSubscribedInstruments(EnumSet.of(instrument), true);
out.println(context.getSubscribedInstruments());
long to = history.getBarStart(period, System.currentTimeMillis());
long from = to - 10 * period.getInterval();
out.println("#1 " + history.getBars(instrument, period, OfferSide.BID, from, to)); // this line is correct
try {
TimeUnit.MINUTES.sleep(1);
} catch (InterruptedException ex) {
out.println(ex);
}
out.println("#2 " + history.getBars(instrument, period, OfferSide.BID, from, to)); // this line throws exception
context.stop();
}
@Override
public void onTick(Instrument instrument, ITick tick) throws JFException {}
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
@Override
public void onMessage(IMessage message) throws JFException {}
@Override
public void onAccount(IAccount account) throws JFException {}
@Override
public void onStop() throws JFException {}
}