Dukascopy
 
 
Wiki JStore Search Login

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

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

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

Problem with setLeverage for ITesterClient in JFxSDK
 Post subject: Problem with setLeverage for ITesterClient in JFxSDK Post rating: 0   New post Posted: Thu 05 Jun, 2014, 14:34 
User avatar

User rating: 0
Joined: Sun 10 Mar, 2013, 16:32
Posts: 6
Location: United Kingdom, slough
Hi,

I cant change leverage to 1:200 from default 1:100 in any example Testers.

I did all as its showed in the wiki. And it still testing with 1:100 leverage.

Are there any tips how to do it properly? Please help

Kind regards
Sirru


 
 Post subject: Re: Problem with setLeverage for ITesterClient in JFxSDK Post rating: 0   New post Posted: Thu 12 Jun, 2014, 10:25 
User avatar

User rating: 0
Joined: Sun 10 Mar, 2013, 16:32
Posts: 6
Location: United Kingdom, slough
Hi again,

No one has this problem when setting leverage to be 1:200 tester still testing with 1:100?

Just take any tester given along with JfxSDK and add this
client.setLeverage(80);


I basically did add all of the given functionalities by wiki and all work fine besides setLeverage(200);

Any thoughts?


 
 Post subject: Re: Problem with setLeverage for ITesterClient in JFxSDK Post rating: 0   New post Posted: Fri 13 Jun, 2014, 14:51 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Make sure you call the method before the test start, see the javadocs, it works just fine in our example program:
package singlejartest;

import java.util.EnumSet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dukascopy.api.*;
import com.dukascopy.api.system.ITesterClient;
import com.dukascopy.api.system.TesterFactory;

public class TesterMainAccountLeverage {
   private static final Logger LOGGER = LoggerFactory.getLogger(TesterMainAccountLeverage.class);

   public static void main(String[] args) throws Exception {
      // get the instance of the IClient interface
      final ITesterClient client = TesterFactory.getDefaultInstance();

      LOGGER.info("Connecting...");
      client.connect("https://www.dukascopy.com/client/demo/jclient/jforex.jnlp", "mzd", "mzd");

      int i = 10; // wait max ten seconds for successful connection
      while (i-- > 0 && !client.isConnected()) {
         Thread.sleep(1000);
      }
      if (!client.isConnected()) {
         LOGGER.error("Failed to connect Dukascopy servers");
         System.exit(1);
      }

      client.setSubscribedInstruments(EnumSet.of(Instrument.EURUSD));
      client.setInitialDeposit(Instrument.EURUSD.getSecondaryJFCurrency(), 50000);
      client.setLeverage(200);
      LOGGER.info("Downloading data");
      // wait for downloading to complete
      client.downloadData(null).get();

      client.startStrategy(new IStrategy(){

         @Override
         public void onStart(IContext context) throws JFException {
            System.out.println("Leverage: " + context.getAccount().getLeverage());
            context.stop();
         }

         public void onTick(Instrument instrument, ITick tick) throws JFException {}
         public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
         public void onMessage(IMessage message) throws JFException {}
         public void onAccount(IAccount account) throws JFException {}
         public void onStop() throws JFException {}});
   }
}


 

Jump to:  

cron
  © 1998-2025 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