[R-SIG-Finance] [R] Quantstrat package question

Brian G. Peterson brian at braverock.com
Sat Aug 27 16:37:17 CEST 2011


On Sat, 2011-08-27 at 22:20 +0900, 이원재 wrote:
> Hi, 
> I am working on Quantstrat package. 
> I would like to ask if it is possible to use reference data in the qunatstrat packages.

Of course you can.

> For example, my market data for trading is 'intra-day' data, and I need to use daily indicators which are computed with 'daily' index data like S&P 500.

You'll need to have your indicator function look up and merge for you.

> But, in this packages, every data has to be a trading symbol in order to be called by functions such as 'add.indicator' and 'add.signal'.

The trading data is all symbols that you will trade, correct, but your
indicator and signal functions can take any arguments.

> Is is possible to use indicators from reference data, especially in a different time frame with trading symbols?


I think you're going to want to write a quick custom indicator,
something like:

indMerge <- function(mktdata=quote(mktdata),x){
    if (!is.xts(x)) x <- getSymbols(x, auto.assign = FALSE)
    x <- cbind(mktdata, x[paste(first(index(mktdata)) , 		
	       last(index(mktdata)) , sep='/')])
    x <- na.locf(x)
    x
}

This works for me to merge in the columns of SPY from yahoo to a tick
data series.

I often do similar things for strategy parameters that can change daily,
I just merge them and na.locf so that they'll be availabe at every
timestamp internally.  Not the most memory-efficient, but simplifies
many other things so that I don't have to write some many custom
functions later in the stack.
 
Regards,

   - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list