本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

在 AlgoTrader 中运行 SimulationStarter 类

发布于2021-10-01 23:50     阅读(890)     评论(0)     点赞(10)     收藏(5)


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

当我开始时,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();
        }
    }
}

解决方案


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

在此处输入图片说明

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

我现在要调查的



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.javaheidong.com/blog/article/294560/06220c39f735c037c80a/

来源:java黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

10 0
收藏该文
已收藏

评论内容:(最多支持255个字符)