FlatForward and its referenceDate

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

FlatForward and its referenceDate

obeck
Hi,

I am new to QuantLib and I have got a very basic problem with the interest rate calculations performed by FlatForward (FlatForward (const Date &referenceDate, Rate forward, const DayCounter &dayCounter, Compounding compounding=Continuous, Frequency frequency=Annual)). The following question I could not find answered neither in the QuantLib docu, nor in the user groups:
1) In the above constructor 'forward' specifies a forward rate for the period starting at 'referenceDate' and ending at 'referenceDate' + '1/frequency'? Is this correct?
2) What is the variable 'referenceDate' good for in the context of FlatForward anyway? If forward rates are equal (flat) for all time periods in the future, obviously the spot zero rates should be identical for all maturities, too. The other way round, if zero spot rates are identical for all maturities, forward rates will also be 'flat'. What information does 'referenceDate' provide in this context?
3) Given that it is correct that FlatForward describes a flat interest rate (or dividend yield) term structure, a change of the variable 'referenceDate' should not alter the net present value calculation of options. However the npv-calculation are affected by changes in the 'referenceDate' of FlatForward. Why is that the case? I have attached a simple code fragment mainly taken from the QuantLib examples to illustrate the effect of using different referenceDates in FlatForward on NPV calculations.

Any help or hints are much appreciated!

Thank you and best regards,

Oliver

//--------------------------------------------------------------------------------------
//My problem can be illustrated by changing the variable 'flatTermStructure1' to 'flatTermStructure2' in the definition of the //stochastic process, which affects NPV calculation (but should not?). Both term structtures solely differ in its //referenceDate.

        QuantLib::Real underlying = 1300;
        QuantLib::Rate riskFreeRate = 0.02;
        QuantLib::Rate dividendYield = 0.01;
        QuantLib::Real volatility = 0.2;
        QuantLib::Option::Type type1 = QuantLib::Option::Call;
        QuantLib::Real strike = 1350;

        QDate today = QDate::currentDate(); //QT date: QT simply used for convenience
        QDate day1 = today.addDays(1); //tomorrow
        QDate day2 = today.addDays(2); //in two days
        QDate day5 = today.addDays(5); // in 5 days
        QDate day10 = today.addDays(10); //in 10 days
        QDate day20 = today.addDays(20); //in 20 days
        QDate day30 = today.addDays(30); // in 30 days

        QuantLib::Settings::instance().evaluationDate() = QuantLib::Date(today.day(), (QuantLib::Month) today.month(), today.year());

        boost::shared_ptr<QuantLib::StrikedTypePayoff> payoff = boost::shared_ptr<QuantLib::StrikedTypePayoff>(new QuantLib::PlainVanillaPayoff(type1, strike));

        QuantLib::Date maturity = QuantLib::Date(day20.day(), (QuantLib::Month) day20.month(), day20.year());
        boost::shared_ptr<QuantLib::Exercise> europeanExercise = boost::shared_ptr<QuantLib::Exercise>(new QuantLib::EuropeanExercise(maturity)); // option should expire in 20 days
       
        //two reference dates
        QuantLib::Date referenceDate1 = QuantLib::Date(today.day(), (QuantLib::Month) today.month(), today.year());
        QuantLib::Date referenceDate2 = QuantLib::Date(day2.day(), (QuantLib::Month) day2.month(), day2.year());

        //day counter
        QuantLib::DayCounter dayCounter = QuantLib::Actual365Fixed();

        //flat interest rate term structure with reference date being today
        QuantLib::Handle<QuantLib::YieldTermStructure> flatTermStructure = QuantLib::Handle<QuantLib::YieldTermStructure>( boost::shared_ptr<QuantLib::YieldTermStructure>(new QuantLib::FlatForward(referenceDate1, riskFreeRate, dayCounter)));
        //flat interets rate term structure with reference date being in two days
        QuantLib::Handle<QuantLib::YieldTermStructure> flatTermStructure2 = QuantLib::Handle<QuantLib::YieldTermStructure>( boost::shared_ptr<QuantLib::YieldTermStructure>(new QuantLib::FlatForward(referenceDate2, riskFreeRate, dayCounter)));

        // flat dividend yield term structure
        QuantLib::Handle<QuantLib::YieldTermStructure> flatDividendTS = QuantLib::Handle<QuantLib::YieldTermStructure>( boost::shared_ptr<QuantLib::YieldTermStructure>(new QuantLib::FlatForward(referenceDate1, dividendYield, dayCounter)));
        //flat volatility term structure
        QuantLib::Handle<QuantLib::BlackVolTermStructure> flatVolTS( boost::shared_ptr<QuantLib::BlackVolTermStructure>(
                        new QuantLib::BlackConstantVol(referenceDate1, volatility, dayCounter)));

       
        QuantLib::Handle<QuantLib::Quote> 
                        underlyingQL(boost::shared_ptr<QuantLib::Quote>(new QuantLib::SimpleQuote(underlying)));
       
// !!!!PROBLEM can be illustrated by changing the variable 'flatTermStructure1' to 'flatTermStructure2', which affects NPV calculation!!!!
//Black Scholes process
  boost::shared_ptr<QuantLib::StochasticProcess> 
  stochasticProcess(new QuantLib::BlackScholesMertonProcess(underlyingQL,flatDividendTS,flatTermStructure1,flatVolTS));

    // plain Vanilla european option
        QuantLib::VanillaOption
                europeanOption(stochasticProcess, payoff, europeanExercise);

    // Black-Scholes for European
        europeanOption.setPricingEngine(boost::shared_ptr<QuantLib::PricingEngine>( new QuantLib::AnalyticEuropeanEngine));
       
        //net present value of option
        qDebug() << "NPV: " << europeanOption.NPV();at effect. //qDebug from QT used for printing to screen

Reply | Threaded
Open this post in threaded view
|

Re: FlatForward and its referenceDate

Luigi Ballabio
Hi Oliver,

On Wed, 2008-02-13 at 02:22 -0800, obeck wrote:
> I am new to QuantLib and I have got a very basic problem with the interest
> rate calculations performed by FlatForward (FlatForward (const Date
> &referenceDate, Rate forward, const DayCounter &dayCounter, Compounding
> compounding=Continuous, Frequency frequency=Annual)). The following question
> I could not find answered neither in the QuantLib docu, nor in the user
> groups:
> 1) In the above constructor 'forward' specifies a forward rate for the
> period starting at 'referenceDate' and ending at 'referenceDate' +
> '1/frequency'? Is this correct?

Correct (the forward rate is the annualized one, of course.)

> 2) What is the variable 'referenceDate' good for in the context of
> FlatForward anyway? If forward rates are equal (flat) for all time periods
> in the future, obviously the spot zero rates should be identical for all
> maturities, too. The other way round, if zero spot rates are identical for
> all maturities, forward rates will also be 'flat'. What information does
> 'referenceDate' provide in this context?

As you say, the rates will be identical for all dates. However, the
FlatForward curve (like all yield term structures) can also provide
discounts. The given reference date is the date at which the discount
equals 1. Depending on the conventions used on your desk for NPV
calculation, it can be today's date or the spot date (two business days
from today for Euribor rates.)

> 3) Given that it is correct that FlatForward describes a flat interest rate
> (or dividend yield) term structure, a change of the variable 'referenceDate'
> should not alter the net present value calculation of options. However the
> npv-calculation are affected by changes in the 'referenceDate' of
> FlatForward. Why is that the case? I have attached a simple code fragment
> mainly taken from the QuantLib examples to illustrate the effect of using
> different referenceDates in FlatForward on NPV calculations.

Same as (2). In the exp(-rt) you have in the Black-Scholes formula, r is
the same regardless of the reference date. However, t changes depending
on where you set it, hence the change of NPV.

Luigi


--

I am extraordinarily patient, provided I get my own way in the end.
-- Margaret Thatcher



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users