[R] RQuantlib Array processing applying EuropeanOptionExampleArray

Dirk Eddelbuettel edd at debian.org
Tue May 23 04:13:51 CEST 2006


On 22 May 2006 at 10:57, Joe Byers wrote:
| 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?

If I understand correctly what you are trying to do, then there may simply be
a misunderstanding on your part.

EuropeanOption(), like all but one [ more on that in the next paragraph ] of
the other RQuantLib functions, expects _scalars_ for all its inputs. But you
seem to expect that it magically vectorises things automatically for you. It
doesn't, and that's why you get errors or unexpected results.

There is however one convenience function -- mostly as a proof of concept --
which unrolls vectors (or sequences) in any of its arguments.  See 

	> help(EuropeanOptionArrays)

and

	> example(EuropeanOptionArrays)

where the results are shown in terms of two sequences of values for the
underlying and the volatility.

As always, there will be many more clever ways for doing this. Suggestions
and patches welcome.

| Any help is greatly appreciated.

Hope this helps. 

Regards, Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison



More information about the R-help mailing list