如何在 quantStrat 中仅应用长 add.distribution 参数集 - param.combo[[param.label]] 中的简单错误

how to apply long only add.distribution parameterset in quantStrat - simpleError in param.combo[[param.label]]

我正在应用与 luxor-demo 中类似的 add.distribution 规则,而我的策略只有多头头寸。

整个策略有效,但在应用参数集时出现以下错误:

TakeProfitLONG 47 0.047

TakeProfitLONG 47 0.047 result of evaluating expression:

simpleError in param.combo[[param.label]]: subscript out of bounds

got results for task 47 numValues: 47, numResults: 47, stopped: FALSE returning status FALSE evaluation # 48: $param.combo

我正在尝试 运行 一个基于简单止盈规则的分布(从止损或尾随止损获得相同的结果):

.use.takeProfit = TRUE
.takeprofit <- 2.0/100 # actual
.TakeProfit = seq(0.1, 4.8, length.out=48)/100 # parameter set for optimization

## take-profit
add.rule(strategy.st, name = 'ruleSignal',
         arguments=list(sigcol='signal.gt.zero' , sigval=TRUE,
                        replace=FALSE,
                        orderside='long',
                        ordertype='limit', 
                        tmult=TRUE, 
                        threshold=quote(.takeprofit),
                        TxnFees=.txnfees,
                        orderqty='all',
                        orderset='ocolong'
         ),
         type='chain', 
         parent='EnterLONG',
         label='TakeProfitLONG',
         enabled=.use.takeProfit
)

我添加分配如下:

add.distribution(strategy.st,
                 paramset.label = 'TakeProfit',
                 component.type = 'chain',
                 component.label = 'TakeProfitLONG',
                 variable = list(threshold = .TakeProfit),
                 label = 'TakeProfitLONG'
)

并应用集合:

results <- apply.paramset(strategy.st, paramset.label='TakeProfit', portfolio.st=portfolio.st, account.st=account.st, nsamples=.nsamples, verbose=TRUE)

从我有限的调试来看,参数集似乎是一个简单的向量,而在 apply.paramset 中,以下函数失败:

results <- fe %dopar% { ... }

这里我对 R 太陌生了,因为我只有 4 周的时间研究这个,但可能会打电话给:

install.param.combo <- function(strategy, param.combo, paramset.label)

可能会导致错误?

我很抱歉,因为我是新手,但是有没有人遇到过这个或者可以帮助如何在一个长策略中只对一个项目应用分布?

非常感谢!

编辑 1: SessionInfo()

R version 3.1.2 (2014-10-31)
Platform: i486-pc-linux-gnu (32-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lattice_0.20-29               iterators_1.0.7               downloader_0.3
 [4] quantstrat_0.9.1665           foreach_1.4.2                 blotter_0.9.1644
 [7] PerformanceAnalytics_1.4.3574 FinancialInstrument_1.2.0     quantmod_0.4-3
[11] TTR_0.22-0.1                  xts_0.9-7                     zoo_1.7-12

loaded via a namespace (and not attached):
[1] codetools_0.2-9 compiler_3.1.2  digest_0.6.7    grid_3.1.2      tools_3.1.2 

这是与 # 5776. It was fixed for "signal" component types, but not for "chain". It should now be fixed as of revision 1669 on R-Forge 相同的错误。