[R] RQuantlib Array processing applying EuropeanOptionExampleArray

Joe Byers joe-byers at utulsa.edu
Tue May 23 05:03:20 CEST 2006


Dirk,

Thank you.  Shortly after I sent this email off, I discovered that I 
left the Array off the function name.  It worked fine.

My ignorance and oversight.

Thanx for the help.

Joe


Dirk Eddelbuettel wrote:
> 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
>
>   


More information about the R-help mailing list