Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

ITesterClient not working with 2.11
 Post subject: ITesterClient not working with 2.11 Post rating: 0   New post Posted: Wed 12 Nov, 2014, 15:32 

User rating: 1
Joined: Thu 23 Feb, 2012, 16:38
Posts: 44
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;
         }
      });
   }
}


 
 Post subject: Re: ITesterClient not working with 2.11 Post rating: 0   New post Posted: Mon 17 Nov, 2014, 15:22 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Does this problem persist?


 
 Post subject: Re: ITesterClient not working with 2.11 Post rating: 0   New post Posted: Fri 21 Nov, 2014, 11:20 

User rating: 1
Joined: Thu 23 Feb, 2012, 16:38
Posts: 44
Yes it does!


 
 Post subject: Re: ITesterClient not working with 2.11 Post rating: 0   New post Posted: Mon 24 Nov, 2014, 14:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We couldn't reproduce the problem. Provided application works as expected.


 
 Post subject: Re: ITesterClient not working with 2.11 Post rating: 0   New post Posted: Wed 26 Nov, 2014, 11:56 

User rating: 1
Joined: Thu 23 Feb, 2012, 16:38
Posts: 44
After further investigation I found the problem. There was some redundant dependencies set in my pom.xml. After cleaning that up, everything works fine. In the older versions <2.11 the errors in my pom.xml had no impact.


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com