Error: MonteCarloModel

Posted by hrisquo on
URL: http://quantlib.414.s1.nabble.com/Error-MonteCarloModel-tp7534.html

Guys I am trying to understand the quantlib library and the the moment I am struggling badly. Any help will be appreciated.

I have added the following line to my code and now I am getting the following error:

Added lines:
"
Statistics sampleAccumulator;

MonteCarloModel<SingleVariate, PseudoRandom>
           myModel( myPathGenerator, myPathPricer, sampleAccumulator,antitheticVariate);
"

Error:
"
myMC.cpp: In function ‘int main()’:
myMC.cpp:67: error: no matching function for call to ‘QuantLib::MonteCarloModel<QuantLib::SingleVariate, QuantLib::GenericPseudoRandom<QuantLib::MersenneTwisterUniformRng, QuantLib::InverseCumulativeNormal>, QuantLib::GenericRiskStatistics<QuantLib::GenericGaussianStatistics<QuantLib::GeneralStatistics> > >::MonteCarloModel(boost::shared_ptr<QuantLib::PathGenerator<QuantLib::InverseCumulativeRsg<QuantLib::RandomSequenceGenerator<QuantLib::MersenneTwisterUniformRng>, QuantLib::InverseCumulativeNormal> > >&, boost::shared_ptr<QuantLib::MCEuropeanEngine<QuantLib::GenericPseudoRandom<QuantLib::MersenneTwisterUniformRng, QuantLib::InverseCumulativeNormal>, QuantLib::GenericRiskStatistics<QuantLib::GenericGaussianStatistics<QuantLib::GeneralStatistics> > > >&, QuantLib::Statistics&, bool&)’
/home/Risco/Cxx/Quant/QuantLib/include/ql/methods/montecarlo/montecarlomodel.hpp:70: note: candidates are: QuantLib::MonteCarloModel<MC, RNG, S>::MonteCarloModel(const boost::shared_ptr<typename MC<RNG>::path_generator_type>&, const boost::shared_ptr<typename MC<RNG>::path_pricer_type>&, const S&, bool, const boost::shared_ptr<typename MC<RNG>::path_pricer_type>&, typename MC<RNG>::path_pricer_type::result_type, const boost::shared_ptr<typename MC<RNG>::path_generator_type>&) [with MC = QuantLib::SingleVariate, RNG = QuantLib::GenericPseudoRandom<QuantLib::MersenneTwisterUniformRng, QuantLib::InverseCumulativeNormal>, S = QuantLib::GenericRiskStatistics<QuantLib::GenericGaussianStatistics<QuantLib::GeneralStatistics> >]
/home/Risco/Cxx/Quant/QuantLib/include/ql/methods/montecarlo/montecarlomodel.hpp:51: note:                 QuantLib::MonteCarloModel<QuantLib::SingleVariate, QuantLib::GenericPseudoRandom<QuantLib::MersenneTwisterUniformRng, QuantLib::InverseCumulativeNormal>, QuantLib::GenericRiskStatistics<QuantLib::GenericGaussianStatistics<QuantLib::GeneralStatistics> > >::MonteCarloModel(const QuantLib::MonteCarloModel<QuantLib::SingleVariate, QuantLib::GenericPseudoRandom<QuantLib::MersenneTwisterUniformRng, QuantLib::InverseCumulativeNormal>, QuantLib::GenericRiskStatistics<QuantLib::GenericGaussianStatistics<QuantLib::GeneralStatistics> > >&)
"

full source code:

"
#include <ql/quantlib.hpp>
#include <boost/timer.hpp>
#include <iostream>
#include <iomanip>

using namespace QuantLib;

int main()
{
try{
    Calendar calendar = TARGET();
    Date today = Date::todaysDate();
    DayCounter dayCount = Actual365Fixed();
    Rate r_ = 0.05;
    Real s0_ = 0.10;
    Volatility sigma_ = 0.20;
    Size nTimeSteps = 1;
    Time maturity_ = 1.0/12.0;

    Size timeSteps = 1;
    Size timeStepsPerYear = 1000;
    bool antitheticVariate = false;
    bool controlVariate = false;
    Size requiredSamples = 1000;
    Real requiredTolerance = 0.001;
    Size maxSamples = 1000;
    BigNatural seed = 42;

// calculate Input parameters fo the BlackScholesMertonProcess and GeneralizedBlackScholesProcess
    Handle<Quote> stateVariable(
                          boost::shared_ptr<Quote>(new SimpleQuote(s0_)));
    Handle<YieldTermStructure> riskFreeRate(
                          boost::shared_ptr<YieldTermStructure>(
                                      new FlatForward(today, r_, dayCount)));
    Handle<YieldTermStructure> dividendYield(
                          boost::shared_ptr<YieldTermStructure>(
                                      new FlatForward(today, 0.0, dayCount)));
    Handle<BlackVolTermStructure> volatility(
                          boost::shared_ptr<BlackVolTermStructure>(
                               new BlackConstantVol(today, calendar, sigma_, dayCount)));
                                                                                                                                           
 boost::shared_ptr<StochasticProcess1D> diffusion(
                   new BlackScholesMertonProcess(stateVariable, dividendYield,
                                                 riskFreeRate, volatility));

 boost::shared_ptr<GeneralizedBlackScholesProcess> Gdiffusion(
                   new GeneralizedBlackScholesProcess(stateVariable, dividendYield,
                                                 riskFreeRate, volatility));

    PseudoRandom::rsg_type rsg =
        PseudoRandom::make_sequence_generator(nTimeSteps, 0);

    bool brownianBridge = false;

    typedef SingleVariate<PseudoRandom>::path_generator_type generator_type;
    boost::shared_ptr<generator_type> myPathGenerator(new
        generator_type(diffusion, maturity_, nTimeSteps,
                       rsg, brownianBridge));

boost::shared_ptr<MCEuropeanEngine<PseudoRandom,Statistics> > myPathPricer(
                   new MCEuropeanEngine<PseudoRandom, Statistics> (
             Gdiffusion, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate,
                     controlVariate, requiredSamples, requiredTolerance, maxSamples, seed));

Statistics sampleAccumulator;

MonteCarloModel<SingleVariate, PseudoRandom>
           myModel( myPathGenerator, myPathPricer, sampleAccumulator,antitheticVariate);

 return EXIT_SUCCESS;
}
catch (std::exception& e)
   {
       std::cout<<e.what()<<"\n";
       return EXIT_FAILURE;
   }
   catch(...)
   {
                                                                                                                                           
       std::cout<<"unknown error \n";
       return EXIT_FAILURE;
   }

return 0;
}
"


" Upgrade to Internet Explorer 8 Optimised for MSN. " Download Now
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users