【问题标题】:Running the SimulationStarter class in the AlgoTrader在 AlgoTrader 中运行 SimulationStarter 类
【发布时间】:2014-02-12 09:44:28
【问题描述】:

我正在尝试在 AlgoTrader 的开源版本中使用移动平均策略运行 SimulationStarted 类。

当我启动SimulationStarter 时,我得到ArrayIndexOutOfBoundsException

我正在尝试通过 Eclipse 运行它。他们从 AlgoTrader 使用以下命令运行它

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

那么是否有可能通过 eclipse 运行它或者这是唯一的方法?

如果有人有任何想法或建议,将不胜感激。

这是SimulationStarterServiceLocator 类的代码。

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();
    }
}

还有服务定位器类

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();
        }
    }
}

【问题讨论】:

    标签: java eclipse algorithm indexoutofboundsexception trading


    【解决方案1】:

    要修复此错误,您需要在 Eclipse 中打开运行配置并添加程序参数和 VM 参数,这样 ArrayIndexOutOfBoundsException 就会消失。

    坏消息是还有另一个错误:2014-01-22 11:15:35,771 ERROR JDBCExceptionReporter Access denied for user 'algouser'@'localhost' (using password: YES)

    我现在要调查的内容

    【讨论】:

    【解决方案2】:

    为了运行 AlgoTrader,您需要有一个数据库 (MySQL) 并在 AlgoTrader 的源代码中配置数据库。没有 DB AlgoTrader 将无法工作。

    【讨论】:

      猜你喜欢
      • 2014-02-24
      • 2014-02-12
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-15
      相关资源
      最近更新 更多