2014-02-12 81 views
0

我已經安裝了AlgoTrader在AlgoTrader使用利布與埃斯佩爾

的開源版本

https://code.google.com/p/algo-trader/

和我工作的發展新戰略「stochF」使用塔里布庫。

http://ta-lib.org/

我是能夠運行從AlgoTrader移動平均例子。

的移動平均線的默認值是

insert into Indicator 
select stat1.average - stat2.average as value 
from Tick(security.isin = underlayingIsin).win:length(movLengthFast).stat:uni(currentValueDouble) as stat1, 
Tick(security.isin = underlayingIsin).win:length(movLengthSlow).stat:uni(currentValueDouble) as stat2 
where stat2.datapoints = movLengthSlow; 

但這不是使用利布庫,並只與埃斯佩爾完成。

爲了與利布均線工作,我用下面的代碼:

// Moving Average using of esper built in functions 
@Name('MOVING_AVERAGE') 
insert into Indicator 
select talib("movingAverage", currentValueDouble, movLengthFast, "Sma") - talib("movingAverage", currentValueDouble, movLengthSlow, "Sma") as value 
from Tick(security.isin = underlayingIsin); 

如果指示燈是一個變量存儲從選擇塔里布結果(「論據」)和蜱是使用數據。

我一直在試圖找到一個關於利布文檔和可惜的是,我發現很少有可用。我已經使用一個是關於Python https://cryptotrader.org/talib

當我嘗試運行那樣

插入件stochF到指示器 選擇塔里布( 「stochF」,2.0,3.0,1.0,3,2,「 SMA「)作爲值從蜱 (security.isin = underlayingIsin);

我收到以下錯誤

1989-12-31 23:00:00,000 DEBUG RuleServiceImpl initialized service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module market-data on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module current-values on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module trades on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module portfolio on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module performance on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module algo on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module ib-market-data on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl deployed module ib-trades on service provider: BASE 
1989-12-31 23:00:00,000 DEBUG RuleServiceImpl initialized service provider: MOV 
Exception in thread "main" com.algoTrader.service.SimulationServiceException: Error performing 'SimulationService.simulateWithCurrentParams()' --> com.algoTrader.service.SimulationServiceException: Error performing 'SimulationService.runByUnderlayings()' --> com.algoTrader.service.RuleServiceException: Error performing 'RuleService.deployAllModules(String strategyName)' --> com.algoTrader.service.RuleServiceException: Error performing 'RuleService.deployModule(String strategyName, String moduleName)' --> com.espertech.esper.client.deploy.DeploymentActionException: Deployment failed in module 'movMain' in module url 'module-mov-main.epl' in expression '//select talib("movingAverage", currentValueDouble...(1293 chars)' : Error validating expression: Failed to resolve property 'indicator.value' to a stream or nested property in a stream [//select talib("movingAverage", currentValueDouble, movLengthFast, "Sma") - talib("movingAverage", currentValueDouble, movLengthSlow, "Sma") as value 


//select values.fastk, values.fastd 
//from Indicator(values != null); 


//first string in algo second in talib enum 
//select talib("movingAverage", currentValueDouble, movLengthFast, "Ema") - talib("movingAverage", currentValueDouble, movLengthSlow, "Ema") as value 
//select talib("trix", currentValueDouble, movLengthFast 10) as values 
//select talib("atr", 3.0, 1.0, 2.0, 10) as value 



//insert into Indicator 
//select stat1.average - stat2.average as value 
//from Tick(security.isin = underlayingIsin).win:length(movLengthFast).stat:uni(currentValueDouble) as stat1, 
//Tick(security.isin = underlayingIsin).win:length(movLengthSlow).stat:uni(currentValueDouble) as stat2 
//where stat2.datapoints = movLengthSlow; 

@Name('OPEN_POSITION') 
@Subscriber(className='com.algoTrader.service.mov.MovServiceImpl$OpenPositionSubscriber') 
select 
engineStrategy.name as strategyName, 
indexTick.security.id as underlayingid, 
indexTick.currentValue as underlayingSpot 
from pattern [every (indexTick=Tick(security.isin=underlayingIsin) -> indicator=Indicator)] 
where indicator.value > 0 
and prior(1, indicator.value) <= 0] 
    at com.algoTrader.service.SimulationServiceBase.simulateWithCurrentParams(SimulationServiceBase.java:246) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
    at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:111) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
    at com.sun.proxy.$Proxy15.simulateWithCurrentParams(Unknown Source) 
    at com.algoTrader.starter.SimulationStarter.main(SimulationStarter.java:29) 
Caused by: com.espertech.esper.client.deploy.DeploymentItemException: Error validating expression: Failed to resolve property 'indicator.value' to a stream or nested property in a stream [//select talib("movingAverage", currentValueDouble, movLengthFast, "Sma") - talib("movingAverage", currentValueDouble, movLengthSlow, "Sma") as value 


//select values.fastk, values.fastd 
//from Indicator(values != null); 


//first string in algo second in talib enum 
//select talib("movingAverage", currentValueDouble, movLengthFast, "Ema") - talib("movingAverage", currentValueDouble, movLengthSlow, "Ema") as value 
//select talib("trix", currentValueDouble, movLengthFast 10) as values 
//select talib("atr", 3.0, 1.0, 2.0, 10) as value 



//insert into Indicator 
//select stat1.average - stat2.average as value 
//from Tick(security.isin = underlayingIsin).win:length(movLengthFast).stat:uni(currentValueDouble) as stat1, 
//Tick(security.isin = underlayingIsin).win:length(movLengthSlow).stat:uni(currentValueDouble) as stat2 
//where stat2.datapoints = movLengthSlow; 

@Name('OPEN_POSITION') 
@Subscriber(className='com.algoTrader.service.mov.MovServiceImpl$OpenPositionSubscriber') 
select 
engineStrategy.name as strategyName, 
indexTick.security.id as underlayingid, 
indexTick.currentValue as underlayingSpot 
from pattern [every (indexTick=Tick(security.isin=underlayingIsin) -> indicator=Indicator)] 
where indicator.value > 0 
and prior(1, indicator.value) <= 0] 
    at com.espertech.esper.core.deploy.EPDeploymentAdminImpl.deployInternal(EPDeploymentAdminImpl.java:181) 
    at com.espertech.esper.core.deploy.EPDeploymentAdminImpl.deploy(EPDeploymentAdminImpl.java:97) 
    at com.algoTrader.service.RuleServiceImpl.handleDeployModule(RuleServiceImpl.java:180) 
    at com.algoTrader.service.RuleServiceBase.deployModule(RuleServiceBase.java:281) 
    at com.algoTrader.service.RuleServiceImpl.handleDeployAllModules(RuleServiceImpl.java:196) 
    at com.algoTrader.service.RuleServiceBase.deployAllModules(RuleServiceBase.java:314) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
    at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:111) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
    at com.sun.proxy.$Proxy17.deployAllModules(Unknown Source) 
    at com.algoTrader.service.SimulationServiceImpl.handleRunByUnderlayings(SimulationServiceImpl.java:140) 
    at com.algoTrader.service.SimulationServiceBase.runByUnderlayings(SimulationServiceBase.java:216) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
    at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:111) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
    at com.sun.proxy.$Proxy15.runByUnderlayings(Unknown Source) 
    at com.algoTrader.service.SimulationServiceImpl.handleSimulateWithCurrentParams(SimulationServiceImpl.java:183) 
    at com.algoTrader.service.SimulationServiceBase.simulateWithCurrentParams(SimulationServiceBase.java:242) 
    ... 14 more 

我試圖運行例如

select talib("atr", 3.0, 1.0, 2.0, 10) as value 

平均真實範圍運行不同的指標,但沒有交易,因爲它只會顯示範圍從最低點到最高點。

如果有人對Talib或/和Esper和戰略發展有任何期望,我會非常欣賞任何信息,鏈接,書籍,因爲我一直在這裏呆了幾天,而且我找不到任何有用的事情去做。非常感謝你。我真的想發展與利布/埃斯佩爾在AlgoTrader戰略和回溯測試模式下運行它。

問候

的Nema

回答

0

看一看在AlgoTrader GenericTALibFunction javadoc

另外,嘗試重新寫你的聲明是這樣的:

select 
engineStrategy.name as strategyName, 
indexTick.security.id as underlayingid, 
indexTick.currentValue as underlayingSpot 
from pattern [every (indexTick=Tick(security.isin=underlayingIsin) -> indicator=Indicator(indicator.value > 0, prior(1, indicator.value) <= 0))]; 

希望這有助於