问题:
xts对象difv,能看到值,但是想引用计算却报错:
Error: object 'difV' not found
请问是怎么回事?
- require(quantmod)
- getSymbols('SPY',index.class=c("POSIXt","POSIXct"))
- d20 <- first(SPY,20)
- x <- Cl(d20)
- currentV <- runSD(x, 3, sample=T)
- difv <- Delt(currentV)
- difv[is.na(difv)] <- 0
- lookback <- difV #这里开始报错
- for( i in 4:NROW(d20)){
- if( i == 4){
- lookback2[i] <- 20*(1+difv[i])
- }
- else{
- lookback2[i] <- lookback[i-1]*(1+difv[i])
- }
-
- lookBack2 <- min(lookBack2,ceiling);
- lookBack2 <- max(lookBack2,floor);
- }
复制代码
以下是单步检查的截图:
|