[R-SIG-Finance] adjustedPrice or raw Price in blotter

Lei Jin leijin56 at gmail.com
Sat Dec 11 20:12:07 CET 2010


Hi,

I would like to get some advice on what Price should I use in
backtesting with blotter.  For example, I just ran a script with
adjustedPrice.  In my script, I have

symbol<-adjustOHLC(symbol,use.Adjusted=T)

But I noticed that blotter function updatePosPL() gets its price using
the rawPrice.  Therefore, it seems to me that I can't use adjustOHLC
with blotter.  But then, how do you adjust for event like split,
dividend, in the script.


=================================================================================
.updatePosPL <- function(Portfolio, Symbol, Dates=NULL, Prices=NULL,
ConMult=NULL, ...)
{ # @author Peter Carl, Brian Peterson
	rmfirst=FALSE
    pname<-Portfolio
    Portfolio<-getPortfolio(pname)
	p.ccy.str<-attr(Portfolio,'currency')
	if(is.null(p.ccy.str)) p.ccy.str<-'NA'
    tmp_instr<-try(getInstrument(Symbol))
    if(inherits(tmp_instr,"try-error") | !is.instrument(tmp_instr)){
	    warning(paste("Instrument",Symbol," not found, things may break"))
    }
	
	if(is.null(Prices)){
		prices=getPrice(get(Symbol, envir=as.environment(.GlobalEnv)))
              <======= gets the raw price
	}

=================================================================================

Thanks,
-lji



More information about the R-SIG-Finance mailing list