Quantcast

Using Monte Carlo method to price European Basket Options

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

Using Monte Carlo method to price European Basket Options

Pedro Milet

Hi all,

 

I’m trying to use Quantlib’s MCEuropeanBasketEngine to price a simple basket option put so far have not been able to do so.

I’m using a C# SWIG compilation of Quantlib, and tried the following:

 

            _exercise = new EuropeanExercise(_maturity);

 

            var stochasticVector = new StochasticProcessVector((int)numAssets);

            for (int i = 0; i < numAssets; i++)

            {

                stochasticVector.Add(new GeneralizedBlackScholesProcess(

                    new QuoteHandle(_spotQuotes[i]),

                    new YieldTermStructureHandle(_dividendCurves[i].TermStructure),

                    new YieldTermStructureHandle(_riskFreeCurves[0].TermStructure),

                    new BlackVolTermStructureHandle(_volMatrices[i].TermStructure)

                    ));

            }

 

            var stochasticProcessArray = new StochasticProcessArray(stochasticVector, _correlationMatrix);

 

            //Since quantlib uses the exponential formula for the Monte Carlo, only one time step is needed for european options.

            uint timeSteps = 1;

            uint QL_NULL_INTEGER = 0x7fffffff;

            bool brownianBridge = false;

            //Increases precision by sampling -x whenever x is sampled.

            bool antitheticVariate = true;

            int requiredSamples = 10000;

            double requiredTolerance = 1e-3;

            int maxSamples = 1000000;

            //int seed;

 

            _engine = new MCEuropeanBasketEngine(stochasticProcessArray, "pseudorandom", timeSteps, QL_NULL_INTEGER,

                brownianBridge, antitheticVariate, requiredSamples, requiredTolerance, maxSamples);

            _basketOption = new BasketOption(_payoff, _exercise);

            _basketOption.setPricingEngine(_engine);

 

 

This compiles fine, but using _basketOption.NPV() for a basket of a single asset (when it should approximately match the Black & Scholes price) consistently overpriced the option (i.e., the average of a large number of runs was consistently above the B&S price). I suspected it either had to do with the single time step (but since it’s an European option I thought this should work anyway) or with something I did not do regarding the random number generation.

 

What am I doing wrong?

 

Thanks,

 

Pedro Milet

 

 

 

 

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Monte Carlo method to price European Basket Options

Ioannis Rigopoulos

Hi Pedro,

I have tested a basket option with your data and I have also observed a consistent overpricing or underpricing, depending on the value of seed.

I went through every step with the debugger and I can confirm the pricing is correct. The final price is also always within the reported error estimate. As one increases the number of samples, one observes convergence to the Black Scholes price as expected.

What you noticed, is clearly due to the way the sequence of random numbers is generated, as you have already suspected anyway. This is why the underpricing alternates with overpricing as you change the seed.

It is interesting that I observed a very good match when I used "Low Discrepancy" instead of "Pseudo Random", although the reported error estimate stays the same.

I hope that helps.

Take care,

Yannis

On 26.01.2017 17:12, Pedro Milet wrote:

Hi all,

 

I’m trying to use Quantlib’s MCEuropeanBasketEngine to price a simple basket option put so far have not been able to do so.

I’m using a C# SWIG compilation of Quantlib, and tried the following:

 

            _exercise = new EuropeanExercise(_maturity);

 

            var stochasticVector = new StochasticProcessVector((int)numAssets);

            for (int i = 0; i < numAssets; i++)

            {

                stochasticVector.Add(new GeneralizedBlackScholesProcess(

                    new QuoteHandle(_spotQuotes[i]),

                    new YieldTermStructureHandle(_dividendCurves[i].TermStructure),

                    new YieldTermStructureHandle(_riskFreeCurves[0].TermStructure),

                    new BlackVolTermStructureHandle(_volMatrices[i].TermStructure)

                    ));

            }

 

            var stochasticProcessArray = new StochasticProcessArray(stochasticVector, _correlationMatrix);

 

            //Since quantlib uses the exponential formula for the Monte Carlo, only one time step is needed for european options.

            uint timeSteps = 1;

            uint QL_NULL_INTEGER = 0x7fffffff;

            bool brownianBridge = false;

            //Increases precision by sampling -x whenever x is sampled.

            bool antitheticVariate = true;

            int requiredSamples = 10000;

            double requiredTolerance = 1e-3;

            int maxSamples = 1000000;

            //int seed;

 

            _engine = new MCEuropeanBasketEngine(stochasticProcessArray, "pseudorandom", timeSteps, QL_NULL_INTEGER,

                brownianBridge, antitheticVariate, requiredSamples, requiredTolerance, maxSamples);

            _basketOption = new BasketOption(_payoff, _exercise);

            _basketOption.setPricingEngine(_engine);

 

 

This compiles fine, but using _basketOption.NPV() for a basket of a single asset (when it should approximately match the Black & Scholes price) consistently overpriced the option (i.e., the average of a large number of runs was consistently above the B&S price). I suspected it either had to do with the single time step (but since it’s an European option I thought this should work anyway) or with something I did not do regarding the random number generation.

 

What am I doing wrong?

 

Thanks,

 

Pedro Milet

 

 

 
















 

 



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot


_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users




Avast logo

This email has been checked for viruses by Avast antivirus software.
www.avast.com



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Loading...