When a strategy is disconnected and reconnected, would i be able to get the missed ticks from IHistory? logically i think yes but i cant. The code is below:
package singlejartest;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
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.Period;
import static com.dukascopy.api.Instrument.EURUSD;
import java.util.List;
import java.util.Set;
public class ABC implements IStrategy{
IConsole console;
IHistory history;
long BeginTime;
@Override
public void onStart(IContext context) throws JFException {
history = context.getHistory();
console = context.getConsole();
context.setSubscribedInstruments(Set.of(EURUSD), true);
BeginTime=-1;
}
@Override
public void onTick(Instrument instrument, ITick tick) throws JFException {
if (instrument.equals(EURUSD)){
long LastTime = history.getTimeOfLastTick(instrument);
if (BeginTime!=-1){
List<ITick> ticks;
try {
ticks = history.getTicks(instrument, BeginTime, LastTime);
int size = ticks.size();
console.getOut().println(
"Size,"+size
);
} catch (JFException e) {
}
}
BeginTime = LastTime;
}
}
@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 {
}
}
If there is no disconnection, the size prints 2, which is correct.
But when i tried to turn off my internet and turn back on, the size would sometime also print 2 or 3, never the full number of the ticks i missed (of course i did check that the market indeed moved during the disconnection).