我已经安装了AlgoTrader的开源版本
https://code.google.com/p/algo-trader/
我正在使用Talib库开发新策略“stochF”。在
我可以运行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;
但这并不是使用Talib库,只使用Esper完成。在
为了使移动平均线与talib一起工作,我使用以下代码:
^{pr2}$其中Indicator是存储select talib(“arguments”)结果的变量,Tick是使用的数据。在
我一直试图找到一份关于talib的文档,不幸的是,我发现几乎没有可用的文档。我一直在使用的是关于Pythonhttps://cryptotrader.org/talib
当我试着像那样管理公司的时候
插入指示器 选择talib(“stochF”,2.0,3.0,1.0,3,2,“Sma”)作为值 从滴答声(安全.isin=底层isin)
我得到以下错误
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中用Talib/Esper开发一个策略,并在回溯测试模式下运行它。在
问候
Nema公司
看看AlgoTrader GenericTALibFunction javadoc
另外,试着这样写你的陈述:
希望这有帮助
相关问题 更多 >
编程相关推荐