【问题标题】:Quantstrat faber_rebal.R demo errorQuantstrat faber_rebal.R 演示错误
【发布时间】:2013-08-26 10:58:46
【问题描述】:

我一直在 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 机器上也遇到了同样的错误。

我们将不胜感激。

谢谢 查尔斯

【问题讨论】:

  • 不需要包含整个演示,因为它包含在软件包中。但是,您需要包含的是实际错误和sessionInfo() 的输出。
  • 谢谢,已包含 sessionInfo() 输出。
  • 使用来自 braverock 的最新提交,r-forge link。还需要记住设置时区。

标签: r quantstrat


【解决方案1】:

我在让 faber_rebal.R 演示也能正常工作时遇到了一些问题。

首先,您必须设置时区:

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

其次,我可以让 add.rule rebalance 中的以下行起作用:

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

所以我把它改成了:

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

希望对你有帮助。

最好, 彼得

【讨论】:

    【解决方案2】:

    看起来演示已在软件包的最新更新中修复。尝试更新到 Rev.:1595 或更高版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-04
      • 1970-01-01
      相关资源
      最近更新 更多