Problem of evolution of time in option calculation

Posted by dhoorens on
URL: http://quantlib.414.s1.nabble.com/Problem-of-evolution-of-time-in-option-calculation-tp1271.html

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


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