[R-SIG-Finance] Cant get this Quantstrat going,

gussinsky sduve at hotmail.com
Sat May 5 12:37:37 CEST 2012


Hello,

I am coming back to my example, and I was able to get rid of the initial
errors, but new ones came up, and I couldnt find any help in other threads
in the forum, my script is attached, here is the error:

> out = try(applyStrategy(strategy=stratCCI, portfolios=port.st,
> parameters=list(n=2)))
Error in .xts(e, .index(e1), .indexCLASS = indexClass(e1), .indexFORMAT =
indexFormat(e1),  : 
  index length must match number of observations

at the same time I checked what is in mktdata:

             Open   High    Low  Close Volume OpenInterest  Month   Else      
CCI CCI.gt..100 CCI.lt.100
1995-01-03 1.6476 1.6491 1.6331 1.6335  28835       127585 199502 0.4994       
NA          NA         NA
1995-01-04 1.6311 1.6366 1.6291 1.6305  30852       123757 199502 0.4964
-66.66667          NA         NA
1995-01-05 1.6266 1.6346 1.6266 1.6337  35708       126672 199502 0.4996
-66.66667           0          0
1995-01-06 1.6366 1.6391 1.6291 1.6293  35477       127964 199502 0.4952 
66.66667           0          0
1995-01-09 1.6261 1.6271 1.6161 1.6174  34237       129668 199502 0.4833
-66.66667           0          0

My question, does the above error have to do with the NA contained in
mktdata?

I also would like to point out, that the calculation of the CCI is wrong,
all through the mktdata it is either -66.66 or 66.66. Having performed a
manual calculation of the CCI with the underlying data from tblox, worked
just fine. 

Best

Sven

http://r.789695.n4.nabble.com/file/n4610898/TestBacktestCCI.R
TestBacktestCCI.R 

--
View this message in context: http://r.789695.n4.nabble.com/Cant-get-this-Quantstrat-going-tp4609350p4610898.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list