使用apply.paramset优化Quanstart MACD返回错误

使用apply.paramset优化Quanstart MACD返回错误,r,quantmod,quantstrat,domc,blotter,R,Quantmod,Quantstrat,Domc,Blotter,我试图测试一些涉及数字货币的交易策略。其中一种策略涉及MACD交叉,但我想优化nSlow和nFast参数 下面是一个可复制的示例(运行): 这给了我以下错误,我不确定如何调试: error calling combine function: <simpleError in fun(result.1, result.2, result.3, result.4, result.5, result.6, ... attempt to select less than one element>

我试图测试一些涉及数字货币的交易策略。其中一种策略涉及MACD交叉,但我想优化
nSlow
nFast
参数

下面是一个可复制的示例(运行):

这给了我以下错误,我不确定如何调试:

error calling combine function:
<simpleError in fun(result.1, result.2, result.3, result.4, result.5, result.6, ... attempt to select less than one element>
调用联合收割机函数时出错:
我做错了什么?FWIW,我正在使用Ubuntu 12.04/14.04。非常感谢您的帮助。谢谢

好吧,我想出来了

add.distribution
函数中的
component.label
参数需要与
add.indicator
中的
label
参数匹配。因此,在这个特殊情况下,我将我的
add.indicator
更改为:

add.indicator(strategy.name, name = "MACD", arguments = list(x=quote(Cl(mktdata))), label='MACD')
add.distribution(strategy.name,
                 paramset.label = 'optEMA',
                 component.type = 'indicator',
                 component.label = 'MACD',
                 variable = list(nFast = 60:80),
                 label = 'NFAST')

add.distribution(strategy.name,
                 paramset.label = 'optEMA',
                 component.type = 'indicator',
                 component.label = 'MACD',
                 variable = list(nSlow = 180:200),
                 label = 'NSLOW')
然后将我的
add.distribution
更改为:

add.indicator(strategy.name, name = "MACD", arguments = list(x=quote(Cl(mktdata))), label='MACD')
add.distribution(strategy.name,
                 paramset.label = 'optEMA',
                 component.type = 'indicator',
                 component.label = 'MACD',
                 variable = list(nFast = 60:80),
                 label = 'NFAST')

add.distribution(strategy.name,
                 paramset.label = 'optEMA',
                 component.type = 'indicator',
                 component.label = 'MACD',
                 variable = list(nSlow = 180:200),
                 label = 'NSLOW')

它运行。将此代码留在这里,以防其他人遇到类似错误。

我对这段代码有或多或少相同的问题

################################# MACD PARAMETERS OPTIMIZATION

.fastMA = (30:60)
.slowMA = (50:80)
.nsamples = 10

# Paramset

add.distribution(volStrat,
                 paramset.label = 'optEMA',
                 component.type = 'indicator',
                 component.label = 'macd.out', 
                 variable = list(n = .fastMA),
                 label = 'nFAST'
)

add.distribution(volStrat,
                 paramset.label = 'optEMA',
                 component.type = 'indicator',
                 component.label = 'macd.out', 
                 variable = list(n = .slowMA),
                 label = 'nSLOW'
)

add.distribution.constraint(volStrat,
                            paramset.label = 'optEMA',
                            distribution.label.1 = 'nFAST',
                            distribution.label.2 = 'nSLOW',
                            operator = '<',
                            label = 'optEMA'
)

results <- apply.paramset(volStrat, 
                          paramset.label = 'optEMA', 
                          portfolio = portfolio2.st, 
                          account = account.st, 
                          nsamples = .nsamples, 
                          verbose = TRUE)

stats <- results$tradeStats

print(stats)
我真的不明白如何选择
paramset.label


非常感谢

请不要这样。或者,至少,告诉别人你在交叉发帖,这样他们就不会浪费时间回答一个他们不关注的论坛上已经回答过的问题。@JoshuaUlrich对此表示抱歉。我以后会记下来的。
Error in must.be.paramset(strategy, paramset.label) : 
  optEMA : no such paramset in strategy VIXSPY_MACD