仪器类构造函数中的Quantstrat错误

时间:2015-02-15 09:41:12

标签: r stock quantstrat

我正在尝试从Ilya Kipnis"量子测试I"的螺母和螺栓中复制代码。我加载了以下代码:

 require(quantstrat)
 require(PerformanceAnalytics)
 initDate="1990-01-01"
 from="2003-01-01"
 to="2012-12-31"
 options(width=70)

 options("getSymbols.warning4.0"=FALSE)
 currency=('USD')
 Sys.setenv(TZ="UTC")

 symbols<- c("XLB","XLE","XLF","XLP".....
  if(!"XLB" %in% ls()) { 
  suppressMessages(getSymbols(symbols, from=from, to=to, src="yahoo",    adjust=TRUE))  
  }

 stock(symbols, currency="USD", multiplier=1)

但是出现以下错误?

  Error in instrument(primary_id = primary_id, currency = currency,   multiplier = multiplier,  : 
  currency USD must be defined first

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:2)

定义货币

应该使用

currency(‘USD’)而不是

currency=(‘USD’)与您上面的代码一样