我正在研究 Guy Yollins quantstrat 演示文稿和他的示例。我将以下代码行粘贴到 R 中:
library(blotter)
currency("USD")
get("USD",envir=.instrument)
stock("SPY",currency="USD",multiplier=1)
get("SPY",envir=.instrument)
getSymbols('SPY', from='1998-01-01', to='2011-07-31', adjust=T)
SPY=to.monthly(SPY, indexAt='endof')
SPY$SMA10m <- SMA(Cl(SPY), 10)
#Initialize portfolio and account
b.strategy <- "bFaber"
initPortf(b.strategy,'SPY', initDate='1997-12-31')
initAcct(b.strategy,portfolios=b.strategy, initDate='1997-12-31', initEq=1e6)
全部来自他的介绍。然后我想列出所有变量:
ls(.blotter)
ls(.instrument)
输出如下:
> ls(.blotter)
[1] "account.bFaber" "portfolio.bFaber"
> ls(.instrument)
Error in as.environment(pos) :
no item called ".instrument" on the search list
In addition: Warning message:
In ls(.instrument) : ‘.instrument’ in Zeichenkette konvertiert
我错过了什么?为什么 .instrument 不起作用?