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

Brian G. Peterson brian at braverock.com
Sat Dec 11 20:46:14 CET 2010


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:
> 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
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.

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



More information about the R-SIG-Finance mailing list