Question about EuropeanOption with Quantlib

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about EuropeanOption with Quantlib

gilles herzog
Good afternoon,
I begin with quantlib and I try to understant EuropeanOption.cpp ( example
in quantlib default's directory )
I have several questions.

What is the operator () ??
What is nuT ?
-----------
Real operator()(Real x) const {
           Real nuT = (r_-q_-0.5*sigma_*sigma_)*maturity_;
           return std::exp(-r_*maturity_)
               *PlainVanillaPayoff(type_, strike_)(s0_*std::exp(x))
               *std::exp(-(x - nuT)*(x -nuT)/(2*sigma_*sigma_*maturity_))
               /std::sqrt(2.0*M_PI*sigma_*sigma_*maturity_);
        }
----------
What is the interest of the class PlainVanillaPayoff ? You can't compute a
payoff without knowing the value of the asset because it is Max(St-K,0) for
the call .
I just use quantlib for a project, it is hard to understand how it
functions...
Thank you

_________________________________________________________________
MSN Hotmail : créez votre adresse e-mail gratuite & à vie !
http://www.imagine-msn.com/Messenger/?locale=fr-fr



Reply | Threaded
Open this post in threaded view
|

Re: Question about EuropeanOption with Quantlib

Luigi Ballabio
On 1/18/06, gilles herzog <[hidden email]> wrote:
> I begin with quantlib and I try to understant EuropeanOption.cpp ( example
> in quantlib default's directory )
> I have several questions.
>
> What is the operator () ??

The part of the code you quoted is a leftover---it is no longer used
in the example. However, adding an operator() to a class makes it
possible to use instances in the same way as functions. Namely, if Foo
is a class with an operator() and f is a Foo instance, it is possible
to write f(x). This calls Foo::operator() passing x as the argument.

> What is the interest of the class PlainVanillaPayoff ? You can't compute a
> payoff without knowing the value of the asset because it is Max(St-K,0) for
> the call .

Right. The payoff as you wrote it is a function of two variables,
namely, S and K.
A PlainVanillaPayoff instance is a curried version of the above, i.e.,
the strike is fixed (it is passed to the constructor) and the created
object can be used as a function of the asset value only. Hmm, I'm not
being very clear. Here's an example:

// you fix a given K when you create the payoff object...
PlainVanillaPayoff p(Option::Call, K);
// ...and now it can give you the payoff for any value of the asset, as in:
double p1 = p(S1);
double p2 = p(S2);
// where S1 and S2 are different values of the asset at maturity.

Note that in the above, I've been able to write p(S). This is because
I gave the payoff class an operator().

Later,
    Luigi