2014-01-22 19 views
2

我試圖運行AlgoTrader開源版本中移動平均策略的SimulationStarted類。運行AlgoTrader中的SimulationStarter類

當我開始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(); 
     } 
    } 
} 

回答

3

要解決這個錯誤,你需要打開運行Configuraitons在Eclipse和添加的程序參數和VM參數和ArrayIndexOutOfBoundsException異常將不復存在。

enter image description here

壞消息是,還有另一種錯誤:2014年1月22日11:15:35771 ERROR JDBCExceptionReporter拒絕訪問用戶algouser'@ 'localhost' 的(使用密碼:YES)

我現在要調查的是

+1

http://code.google.com/p/algo-trade/wik/AlgoTraderDocumentation#Install這裏可以找到關於如何配置數據庫的信息。 –

3

爲了運行AlgoTrader,您需要有一個數據庫(MySQL)並在AlgoTrader的源代碼中配置數據庫。沒有數據庫AlgoTrader不起作用。