[R] RQuantlib Array processing applying EuropeanOptionExampleArray

Joe Byers joe-byers at utulsa.edu
Mon May 22 17:57:08 CEST 2006


I am trying to replicate part of the EuropeanOptionExample using my 
date.  I have a data.frame containing all my inputs
atm.vols<-subset(data.vols,moneyness==min);
#Some days have the abs(moneyness) exactly between two strike prices,
#Traders will alway price an option at the higher vol when selling it, 
so we will too.
atm.vols.max<-data.frame(vol.max=tapply(atm.vols$sigma,INDEX=factor(atm.vols$date),max));
#y<-date.mmddyy(as.numeric(row.names(atm.vols)));
#row.names(atm.vols.max)<-date.mmddyy(as.numeric(row.names(atm.vols.max)));
atm.work<-merge(atm.vols,atm.vols.max,by.x="date",by.y="row.names",all=TRUE)
#ok get only the vols we need
atm.work<-subset(atm.work,sigma==vol.max);

atm.work is has 749 rows.

I try and run the EuropeanOption example using atm.work$For_Price as my 
array of underlying prices and the other inputs from row 9 of atm.work.
i<-9;
x<-EuropeanOption(type = "put", underlying = atm.work$For_Price, strike 
= atm.work$K[i],
            dividendYield = atm.work$BEY[i], riskFreeRate = 
atm.work$BEY[i], maturity = atm.work$t_exp[i],
            volatility = atm.work$sigma[i])

x$parameters has the array of underlying prices but the results is only 
a single vector using the first row of atm.work$For_Price.  Is this 
because I am pulling the inputs from data.frame not arrays?

Any help is greatly appreciated.

Thank you
Joe




More information about the R-help mailing list