Student T - 4 months ago 53

R Question

This is the function declaration (

`fOptions::GBSGreeks`

`function (Selection = c("Delta", "Theta", "Vega", "Rho", "Lambda",`

"Gamma", "CofC"), TypeFlag = c("c", "p"), S, X, Time, r,

b, sigma)

I want to try various

`Selection`

`library(fOptions)`

greeks <- lapply(Selection=list('Delta', 'Gamma', 'Vega', 'Theta', 'Rho'),

FUN=fOptions::GBSGreeks, TypeFlag='p', S=100.0, X=100.0, Time=1.0, r=0.05, b=0, sigma=0.05)

but the result is just a single element:

`[[1]]`

[1] -0.4661285

Answer

Try

```
greeks <- lapply(list('Delta', 'Gamma', 'Vega', 'Theta', 'Rho'),
function(a) GBSGreeks(Selection = a,
TypeFlag='p',
S=100.0, X=100.0,
Time=1.0, r=0.05, b=0, sigma=0.05))
```