Problem of evolution of time in option calculation

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

Problem of evolution of time in option calculation

dhoorens
Hi I have the following problem with the following code
What I would like to do is to calculate the value of an vanilla stock option month after month.
The underlying is supposed to be constant, the risk free and vol are also constant.
The only variable is time( thus the time between maturity and calculation date) because i'm would like to price the option each month of its life.

It seems not to work because I have for each month the same value.
Is my code correct?
Thank you
David

Here is my code and the corresponding output


///////////////////////////////////////////////////////
void main(){
        try{
                Calendar calendar = TARGET();
                DayCounter dayCounter = Actual360();

                Date startDate (1,Feb, 2009);
                Date today(startDate);

                Handle<Quote> underlyingH (boost::shared_ptr<Quote>(new SimpleQuote(100)));
                Handle<YieldTermStructure> riskFreeTS (boost::shared_ptr<YieldTermStructure>(new FlatForward(today, 0.04, dayCounter)));
                Handle<YieldTermStructure> dividendTS (boost::shared_ptr<YieldTermStructure>(new FlatForward(today, 0.0, dayCounter)));
                Handle<BlackVolTermStructure> blackVolTS(boost::shared_ptr<BlackVolTermStructure>(new BlackConstantVol(today, calendar, 0.2, dayCounter)));
                boost::shared_ptr<BlackScholesMertonProcess> bsmProcess(new BlackScholesMertonProcess(underlyingH, dividendTS,riskFreeTS, blackVolTS));

                boost::shared_ptr<StrikedTypePayoff> payoff (new PlainVanillaPayoff(Option::Type::Put, 90));
               
                Date maturity(15,Aug, 2009);

                boost::shared_ptr<Exercise> exercise = boost::shared_ptr<Exercise>(new EuropeanExercise(maturity));
               
                VanillaOption o(payoff, exercise);
                o.setPricingEngine(boost::shared_ptr<PricingEngine>(new AnalyticEuropeanEngine(bsmProcess)));
               
                for (int nbMonth = 0 ; nbMonth <10; nbMonth++){
                        today = calendar.advance(startDate,nbMonth,Months);
                        Settings::instance().evaluationDate() = today;
                        std::cout << "option @ " << today << "  = " << o.NPV() << std::endl;
                }
        }
        catch(...){
                std::cout << "Error" << std::endl;
        }
}

////////////////////////////////////////

The output is:


option @ February 2nd, 2009  = 1.48158
option @ March 2nd, 2009  = 1.48158
option @ April 1st, 2009  = 1.48158
option @ May 4th, 2009  = 1.48158
option @ June 1st, 2009  = 1.48158
option @ July 1st, 2009  = 1.48158
option @ August 3rd, 2009  = 1.48158
option @ September 1st, 2009  = 0
option @ October 1st, 2009  = 0
option @ November 2nd, 2009  = 0
Press any key to continue


//////////////////////////////////////////
Reply | Threaded
Open this post in threaded view
|

Re: Problem of evolution of time in option calculation

Luigi Ballabio
On Fri, 2009-02-06 at 02:20 -0800, dhoorens wrote:

> What I would like to do is to calculate the value of an vanilla stock
> option
> month after month.
> The underlying is supposed to be constant, the risk free and vol are
> also
> constant.
> The only variable is time( thus the time between maturity and
> calculation
> date) because i'm would like to price the option each month of its
> life.
>
> It seems not to work because I have for each month the same value.
> Is my code correct?

No, you have to set up the curves so that their reference date moves
when you change evaluation date. For instance, instead of

FlatForward(today, 0.04, dayCounter)

use

FlatForward(0, calendar, 0.04, dayCounter)

The same goes for the other yield and vol curves. After I change those,
I get

option @ February 2nd, 2009  = 1.47396
option @ March 2nd, 2009  = 1.25327
option @ April 1st, 2009  = 1.00036
option @ May 4th, 2009  = 0.703008
option @ June 1st, 2009  = 0.440119
option @ July 1st, 2009  = 0.170427
option @ August 3rd, 2009  = 0.00173811
option @ September 1st, 2009  = 0
option @ October 1st, 2009  = 0
option @ November 2nd, 2009  = 0

Luigi



--

Age is an issue of mind over matter. If you don't mind, it doesn't
matter.
-- Mark Twain



------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users