Quantstrat faber_rebal.R演示错误

时间:2013-08-26 10:58:47

标签: r quantstrat

我一直在量子计划中进行演示。我在运行faber_rebal.r时遇到问题。它失败并出现以下错误:

> out<-applyStrategy.rebalancing(strategy='faber' , portfolios='faber')
Error in `colnames<-`(`*tmp*`, value = c("MaxPos", "LongLevels", "MinPos",  : 
length of 'dimnames' [2] not equal to array extent

这是sessionInfo()的输出:

R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_South Africa.1252  LC_CTYPE=English_South Africa.1252   
[3] LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C                         
[5] LC_TIME=English_South Africa.1252    

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

other attached packages:
 [1] quantstrat_0.7.8           foreach_1.4.1              blotter_0.8.15            
 [4] PerformanceAnalytics_1.1.0 FinancialInstrument_1.1    quantmod_0.4-0            
 [7] Defaults_1.1-1             TTR_0.22-0                 xts_0.9-5                 
[10] zoo_1.7-10                 lattice_0.20-23           

loaded via a namespace (and not attached):
[1] codetools_0.2-8 grid_3.0.1      iterators_1.0.6 tools_3.0.1

当函数applyStrategy.rebalancing调用私有函数ruleProc时,会出现问题。

我在使用R 3.0.1的Ubuntu 12.04计算机上也遇到了同样的错误。

任何有助于它运作的帮助将不胜感激。

由于 查尔斯

2 个答案:

答案 0 :(得分:0)

我在使faber_rebal.R演示工作时遇到了一些问题。

首先,您必须设置时区:

ttz<-Sys.getenv('TZ')
Sys.setenv(TZ='UTC')

其次,我可以在add.rule重新平衡中使用以下行:

refprice=quote(last(getPrice(mktdata)[paste('::',timestamp,sep='')][,1])),

所以我改成了:

refprice=quote(last(getPrice(mktdata)[paste('::','20140119',sep='')][,1])),

我希望有所帮助。

最佳, 彼得

答案 1 :(得分:0)

看起来在包的最新更新中修复了demo。尝试更新到Rev。:1595或更高版本