The ITesterClient hangs as soon as the startStrategy-method is called in Version 2.11 (it is working with 2.10.1). To reproduce the problem, you can use the following dummy code (please add a valid username/password).
package org.dummyclient;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IContext;
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.LoadingProgressListener;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;
import com.dukascopy.api.system.ITesterClient;
import com.dukascopy.api.system.ITesterClient.DataLoadingMethod;
import com.dukascopy.api.system.TesterFactory;
public class DummyClient {
private static final Logger LOGGER = LoggerFactory.getLogger(DummyClient.class);
public static void main(String[] args) throws Exception {
LOGGER.info("starting");
ITesterClient client = TesterFactory.getDefaultInstance();
LOGGER.info("starting connection");
client.connect("https://www.dukascopy.com/client/demo/jclient/jforex.jnlp", username, password);
LOGGER.info("connection done");
// wait for it to connect
int i = 10; // wait max ten seconds
while (i > 0 && !client.isConnected()) {
Thread.sleep(1000);
i--;
LOGGER.info("waiting for connection...");
}
if (!client.isConnected()) {
System.exit(1);
}
LOGGER.info("client connected");
client.setProcessingStatsEnabled(true);
client.setEventLogEnabled(true);
// set instruments that will be used in testing
Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Instrument.AUDCAD);
client.setSubscribedInstruments(instruments);
// setting initial deposit
client.setInitialDeposit(Instrument.EURUSD.getSecondaryJFCurrency(), 1000000);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
Period testInterval = Period.TICK;
OfferSide offerSide = OfferSide.BID;
ITesterClient.InterpolationMethod ipMethod = ITesterClient.InterpolationMethod.CUBIC_SPLINE;
Date startTestDate;
Date endTestDate = new Date();
try {
startTestDate = df.parse("2014-06-02 00:00:00");
endTestDate = df.parse("2014-06-03 00:00:00");
if (!testInterval.equals(Period.TICK)) {
client.setDataInterval(testInterval, offerSide, ipMethod, startTestDate.getTime(), endTestDate.getTime());
} else {
client.setDataInterval(DataLoadingMethod.ALL_TICKS,startTestDate.getTime(), endTestDate.getTime());
}
} catch (ParseException e1) {
e1.printStackTrace();
System.exit(1);
}
IStrategy strategy = new IStrategy() {
@Override
public void onAccount(IAccount arg0) throws JFException {
// TODO Auto-generated method stub
}
@Override
public void onBar(Instrument arg0, Period arg1, IBar arg2, IBar arg3) throws JFException {
// TODO Auto-generated method stub
LOGGER.info("onBar");
}
@Override
public void onMessage(IMessage arg0) throws JFException {
// TODO Auto-generated method stub
}
@Override
public void onStart(IContext arg0) throws JFException {
LOGGER.info("started");
}
@Override
public void onStop() throws JFException {
// TODO Auto-generated method stub
LOGGER.info("stopped");
}
@Override
public void onTick(Instrument arg0, ITick arg1) throws JFException {
// TODO Auto-generated method stub
LOGGER.info("onTick");
}
};
Thread.sleep(6*1000);
LOGGER.info("downloading data");
Future<?> future = client.downloadData(null);
// wait for downloading to complete
future.get();
LOGGER.info("starting strategy");
long pid = client.startStrategy(strategy, new LoadingProgressListener() {
public void dataLoaded(long startTime, long endTime, long currentTime, String information) {
LOGGER.info("dataLoaded: "+information);
}
public void loadingFinished(boolean allDataLoaded, long startTime, long endTime, long currentTime) {
LOGGER.info("loading finished");
}
public boolean stopJob() {
// LOGGER.info("Loading stopped");
return false;
}
});
}
}