DiscreteAveragingAsianOption: problem with past fixings

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

DiscreteAveragingAsianOption: problem with past fixings

javit
I have problems in setting up the past fixings for an average price option. When use in this from:

        DiscreteAveragingAsianOption option(averageType, runningSum,
                                            pastFixings, fixingDates,
                                            payoff, exercise);

I believe that runningSum and pastFixings are running sum of the past underlying values and number of such past observations. However, when I increase the runningSum (at a line prior to the one above) to an incredibly high value, I don't get a different result. I'm not sure if I'm doing the right thing. Thank you for your help. Here is the code and the output:

    struct DiscreteAverageData {
        Option::Type type;
        Real underlying;
        Real strike;
        Rate dividendYield;
        Rate riskFreeRate;
        Time first; //time to first fixing
        Time length; //total time to be divided by (the number of fixings-1)
        Size fixings;
        Volatility volatility;
        bool controlVariate;
        Real result;
    };




int main(){
    cout <<"Using Monte Carlo discrete arithmetic average-price algorithm"<<endl;



    DiscreteAverageData cases4[] = {
        { Option::Put, 10.26, 15.6878, 0.0, 0.04640385, 0.869444444, 5/360.0, 6.0,
          0.3841501487, true, 5.126487319 },
        { Option::Call, 1520.27, 1451.19, 0.02222527473, 0.0501932988, 16.0/360.0, 4.0/12.0, 5.0,
          0.2357478633, true, 57.73700198 },
        { Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0/12.0, 8,
          0.13, true,1.66970673 }
 
   };

    DayCounter dc = Actual360();
    Date today = Date::todaysDate();

    boost::shared_ptr<SimpleQuote> spot(new SimpleQuote(100.0));
    boost::shared_ptr<SimpleQuote> qRate(new SimpleQuote(0.03));
    boost::shared_ptr<YieldTermStructure> qTS = flatRate(today, qRate, dc);
    boost::shared_ptr<SimpleQuote> rRate(new SimpleQuote(0.06));
    boost::shared_ptr<YieldTermStructure> rTS = flatRate(today, rRate, dc);
    boost::shared_ptr<SimpleQuote> vol(new SimpleQuote(0.20));
    boost::shared_ptr<BlackVolTermStructure> volTS = flatVol(today, vol, dc);



    Average::Type averageType = Average::Arithmetic;
    Real runningSum = 0.0;
    Size pastFixings = 0;

    for (Size l=0; l<LENGTH(cases4); l++) {

        boost::shared_ptr<StrikedTypePayoff> payoff(new
            PlainVanillaPayoff(cases4[l].type, cases4[l].strike));

        Time dt = cases4[l].length/(cases4[l].fixings-1);
        std::vector<Time> timeIncrements(cases4[l].fixings);
        std::vector<Date> fixingDates(cases4[l].fixings);
        timeIncrements[0] = cases4[l].first;
        fixingDates[0] = today + Integer(timeIncrements[0]*360+0.5);
        for (Size i=1; i<cases4[l].fixings; i++) {
            timeIncrements[i] = i*dt + cases4[l].first;
            fixingDates[i] = today + Integer(timeIncrements[i]*360+0.5);
        }
        boost::shared_ptr<Exercise> exercise(new
            EuropeanExercise(fixingDates[cases4[l].fixings-1]));

                if (l==1) {
                        runningSum =  8.0*1498.91;
                        pastFixings = 8;
                }
                else {
                        runningSum = 0.0;
                pastFixings = 0;
                }

        cout <<"l : " <<l<<" runningSum : " <<runningSum<<endl;

        spot ->setValue(cases4[l].underlying);
        qRate->setValue(cases4[l].dividendYield);
        rRate->setValue(cases4[l].riskFreeRate);
        vol  ->setValue(cases4[l].volatility);

        boost::shared_ptr<BlackScholesMertonProcess> stochProcess(new
            BlackScholesMertonProcess(Handle<Quote>(spot),
                                      Handle<YieldTermStructure>(qTS),
                                      Handle<YieldTermStructure>(rTS),
                                      Handle<BlackVolTermStructure>(volTS)));


        boost::shared_ptr<PricingEngine> engine =
            MakeMCDiscreteArithmeticAPEngine<LowDiscrepancy>(stochProcess)
            .withStepsPerYear(360)
            .withSamples(10000)
            .withControlVariate();

        DiscreteAveragingAsianOption option(averageType, runningSum,
                                            pastFixings, fixingDates,
                                            payoff, exercise);
        option.setPricingEngine(engine);

        Real calculated = option.NPV();
        Real expected = cases4[l].result;
        Real tolerance = 2.0e-2;
 
                std::cout<< "average type: "<<averageType<<std::endl<<"spot value: "<<spot->value()<<std::endl<<
                        "dividend yield rate: "<<qRate->value()<<std::endl<<" risk-free rate: " <<rRate->value()<<std::endl<<
                        "today is: "<<today<<std::endl<<
                        "volatility: "<<vol->value()<<std::endl<<"test value: "<<expected<<std::endl<<
                        "calculated value: "<< calculated<<endl<<
                        "______________________________________________________"<<endl;
    }

}

OUTPUT:


Using Monte Carlo discrete arithmetic average-price algorithm
l : 0 runningSum : 0
average type: Arithmetic
spot value: 10.26
dividend yield rate: 0
 risk-free rate: 0.0464039
today is: October 28th, 2008
volatility: 0.38415
test value: 5.12649
calculated value: 5.12292
______________________________________________________
l : 1 runningSum : 11991.3
average type: Arithmetic
spot value: 1520.27
dividend yield rate: 0.0222253
 risk-free rate: 0.0501933
today is: October 28th, 2008
volatility: 0.235748
test value: 57.737
calculated value: 99.0865
______________________________________________________
l : 2 runningSum : 0
average type: Arithmetic
spot value: 90
dividend yield rate: 0.06
 risk-free rate: 0.025
today is: October 28th, 2008
volatility: 0.13
test value: 1.66971
calculated value: 1.67106
______________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: DiscreteAveragingAsianOption: problem with past fixings

Luigi Ballabio
On Tue, 2008-10-28 at 12:15 -0700, javit wrote:
> I have problems in setting up the past fixings for an average price option.

You're right. It should be fixed now. Thanks for the report.

Luigi


--

There is no likelihood man can ever tap the power of the atom.
-- Robert Millikan, Nobel Prize in Physics, 1923



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users