Running the SimulationStarter class in the AlgoTrader

I am trying to run the SimulationStarted class with the moving average strategy in the open source edition of AlgoTrader.

When I start the SimulationStarter I get ArrayIndexOutOfBoundsException.

I am trying to run it through eclipse. From AlgoTrader they run it with the following command

java.exe -cp target/classes;../../AlgoTrader/code/target/classes;../../AlgoTrader/code/lib/*;target/* -Dsimulation=true -DdataSource.dataSet=1year com.algoTrader.starter.SimulationStarter simulateWithCurrentParams

So is it even possible to run it through eclipse or this is the only way?

If anyone has any ideas or suggestions it will be much appreciated.

Here is the code for the SimulationStarter and ServiceLocator classes.

package com.algoTrader.starter;

import org.apache.commons.math.*;
import org.apache.log4j.Logger;



import com.algoTrader.ServiceLocator;
import com.algoTrader.service.SimulationServiceImpl;
import com.algoTrader.util.MyLogger;

public class SimulationStarter {

    private static Logger logger = MyLogger.getLogger(SimulationServiceImpl.class.getName());

    public static void main(String[] args) throws ConvergenceException, FunctionEvaluationException {

        ServiceLocator.serverInstance().init("beanRefFactorySimulation.xml");

        if ("simulateWithCurrentParams".equals(args[0])) {

            ServiceLocator.serverInstance().getSimulationService().simulateWithCurrentParams();

        } else if ("optimizeSingleParamLinear".equals(args[0])) {

            String strategyName = args[1];
            for (int i = 2; i < args.length; i++) {
                String[] params = args[i].split(":");
                String parameter = params[0];
                double min = Double.parseDouble(params[1]);
                double max = Double.parseDouble(params[2]);
                double increment = Double.parseDouble(params[3]);

                ServiceLocator.serverInstance().getSimulationService().optimizeSingleParamLinear(strategyName, parameter, min, max, increment);

            }
        }

        ServiceLocator.serverInstance().shutdown();
    }
}

And the service locator class

package com.algoTrader;

import com.algoTrader.entity.StrategyImpl;
import com.algoTrader.util.ConfigurationUtil;

public class ServiceLocator {

    private static boolean simulation = ConfigurationUtil.getBaseConfig().getBoolean("simulation");
    private static String strategyName = ConfigurationUtil.getBaseConfig().getString("strategyName");

    public static CommonServiceLocator commonInstance() {

        if (!simulation && !StrategyImpl.BASE.equals(strategyName)) {
            return RemoteServiceLocator.instance();
        } else {
            return ServerServiceLocator.instance();
        }
    }

    public static ServerServiceLocator serverInstance() {

        if (!simulation && !StrategyImpl.BASE.equals(strategyName)) {
            throw new IllegalArgumentException("serverInstance cannot be called from the client");
        } else {
            return ServerServiceLocator.instance();
        }
    }
}
Answer:1

Is it possible to display a web applet inside a java application's window? It would be preferable if you could give an example code, as I am rather newbish with java.

I have two scroll panes that I am trying to set the scroll bars to always be visible. For some reason when I try to use the code (scroll code) below, I get an error that "The method ...

I have a spring boot application which reads some passwords from an xml while, which is not part of the jar. It has to be in a separate folder. How can I add this xml file to the classpath so that ...

I need to get a Google map key for my application and, for this, I need the MD5 signature of my certificate. As seen on the Internet, I use "keytool" to get it : keytool -list -alias mykey -keystore ...