eddelbuettel / rquantlib

R interface to the QuantLib library
119 stars 50 forks source link

Computing vega with CrankNicolson #75

Closed fcocquemas closed 6 years ago

fcocquemas commented 8 years ago

I need to (numerically) compute the vega of American options when using discrete dividends (and thus CrankNicolson). Inspired by this example, I have written seven lines of codes that do just that. I do not have a proper way of benchmarking at this point, but the values are close enough to the European vega that some papers use as a proxy.

Is there any interest for me to submit this in a PR? The downside is that it requires computing the option price twice more, so there is likely a computing cost for more intensive applications.

eddelbuettel commented 8 years ago

I'd say so, and as it generally new how about running it by the (very friendly) folks over at QuantLib?

Repo is here: https://github.com/lballabio/QuantLib/ and I guess you know about the mailing list(s).

We could also integrate it here first and test and illustrate then bubble up upstream. Deal?

fcocquemas commented 8 years ago

Deal. I don't understand the QL codebase very well at all, but that email from Luigi Ballabio suggests that it might not be something easy to do upstream in a general way.

eddelbuettel commented 8 years ago

Sorry, had not seen the email link.

Hm. If it is hard to do there ... how do plan to attack it here is the two code-bases are so close?

(Sorry, at work, and no time to look in great detail hence quick replies)

fcocquemas commented 8 years ago

Well, Luigi Ballabio claims that it is hard to do for the general case. However he does give a simple example for a particular instance. Basically, you shift volatility by a small increment and compute two prices around the original value, then compute the slope of the secant.

So right now all I do is this:

QuantLib::Spread dvol = 0.0001;
vol->setValue(volatility + dvol);
QuantLib::Real P1 = option.NPV();
vol->setValue(volatility - dvol);
QuantLib::Real P2 = option.NPV();
QuantLib::Real vega = (P1 - P2) / (2 * dvol);
vol->setValue(volatility);
eddelbuettel commented 8 years ago

Right. I have done that somewhere too. Can't remember where though.

eddelbuettel commented 6 years ago

I think this can be closed.