[R-SIG-Finance] For loop & CRRBinomial

James jctoll at gmail.com
Mon Oct 1 23:06:26 CEST 2007


Hi,

I've been creating P&L plots of basic option positions.  In order to  
do so, I need to calculate the option prices associated with the  
given range of prices for the underlying.  When using Rmetrics and  
the black scholes model, I can pass in a vector of underlying prices  
and get back a vector of option prices.  That doesn't seem to work  
with the CRRBinomial model.  So I've been using a for loop to fill my  
vector with option prices:

pricesToday<- NULL
for(price in priceRange) {
      pricesToday<-c(pricesToday, CRRBinomialTreeOption 
(TypeFlag="ca",S=price, X=20, Time=1/12, r=.05, b=.05, sigma=.4,  
n=100)@price)
}


It works, but it just seems "cludgey" to me.  Is there a better, more  
"r" way of doing this?  Thanks.

James



More information about the R-SIG-Finance mailing list