Skip to content

adjustedPrice or raw Price in blotter

2 messages · Lei Jin, Brian G. Peterson

#
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
#
blotter calls getPrice.  If you look at the documentation and code for
getPrice, you can pass a 'prefer' argument to use whatever column you want.

The way that you've adjusted it means that it will get the adjusted price,
though.  I don't think you need to do anything else.

If your adjusted series is named for the symbol, then that is the price
that blotter will find.  You can of course verify this by calling that
code:

getPrice(get(symbol, envir=as.environment(.GlobalEnv)))

and I think you will see the adjusted price.  If not, experiment with the
prefer= argument or provide us with a reproducible example we can work from
to help you further.

Regards,

  - Brian

Regards,

  - Brian
On Sat, 11 Dec 2010 11:12:07 -0800, Lei Jin <leijin56 at gmail.com> wrote:
=================================================================================
=================================================================================