Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在带有Esper的AlgoTrader中使用Talib_Java_Python_Eclipse_Algorithm_Esper - Fatal编程技术网

Java 在带有Esper的AlgoTrader中使用Talib

Java 在带有Esper的AlgoTrader中使用Talib,java,python,eclipse,algorithm,esper,Java,Python,Eclipse,Algorithm,Esper,我已经安装了AlgoTrader的开源版本 我正在利用塔利布图书馆开发新的战略“stochF” 我能够运行AlgoTrader的移动平均线示例 移动平均线的默认值为 insert into Indicator select stat1.average - stat2.average as value from Tick(security.isin = underlayingIsin).win:length(movLengthFast).stat:uni(currentValueDouble)

我已经安装了AlgoTrader的开源版本

我正在利用塔利布图书馆开发新的战略“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一起工作,我使用以下代码:

// 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);
其中,Indicator是一个用于存储select talib(“参数”)结果的变量,Tick是正在使用的数据

我一直试图找到一份关于塔利布的文档,不幸的是,我发现几乎没有什么可用的。我一直在使用的是关于Python的

当我试着像那样管理stochF的时候

插入指示器 选择talib(“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
平均真实范围正在运行,但没有交易,因为它只显示从最低点到最高点的范围

如果有人对Talib或/和Esper以及战略发展有任何不满,我将非常感谢任何信息、链接和书籍,因为我已经在这方面停留了几天,找不到任何有用的事情可以做。非常感谢你。我真的很想在AlgoTrader中与Talib/Esper一起开发一个策略,并在回溯测试模式下运行它

问候

Nema

查看

另外,试着像这样重新编写您的声明:

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))];
选择
engineStrategy.name作为strategyName,
index.security.id作为underlayingid,
indexTick.currentValue作为参考底图点
从模式[every(indexTick=Tick(security.isin=underlayingIsin)->indicator=indicator(indicator.value>0,prior(1,indicator.value))
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))];