[R-SIG-Finance] A quick custom data question
Michael Chen
mwc4120 at hotmail.com
Sat Apr 8 10:58:48 CEST 2017
Hi,
I didn't get a satisfactory answer after searching the archives. I just like to know how do we access market data other than OHLC? for example:
head(J.DCE)
Open High Low Close Volume hmmState
2010-01-04 2886.193 2886.193 2811.193 2833.193 0 1
2010-01-05 2886.193 2886.193 2811.193 2833.193 0 1
2010-01-06 2886.193 2886.193 2811.193 2833.193 0 1
2010-01-07 2886.193 2886.193 2811.193 2833.193 0 1
2010-01-08 2886.193 2886.193 2811.193 2833.193 0 1
2010-01-11 2886.193 2886.193 2811.193 2833.193 0 1
In my quantstrat set up, I simply set up this as an indicator:
add.indicator(strategy.st, name = "getHMM",
arguments = list(x = quote(getPrice( mktdata, prefer = "hmmState"))),
label = "HMMState")
getHMM is a simple function I wrote to pass on the data as an indicator, anyhow the error occurs at the getting data part:
> test <- applyIndicators(strategy.st, OHLC(J.DCE))
[cid:8fd55500-6086-462a-9497-66ddfba6c0e0] Show Traceback
[cid:f10ca1b2-aa9d-4283-afe3-337661d8b54a] Rerun with Debug
Error in getPrice(mktdata, prefer = "hmmState") :
subscript out of bounds, no price was discernible from the data
The data was converted to an xts for quantstrat. I am probably making a simple error somewhere, would someone please point it out to me, thanks. Also, is there a better way to or a more correct way to access custom data easily for quantstrat indicators/signals??
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20170408/1ba52578/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 98 bytes
Desc: pastedImage.png
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20170408/1ba52578/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 180 bytes
Desc: pastedImage.png
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20170408/1ba52578/attachment-0001.png>
More information about the R-SIG-Finance
mailing list