> Hi,
>
> I am trying to understand the monte carlo in QuantLib. However, I am
> getting errors when i try to call the MCEuropeanEngine.
>
> The error is as follows:
>
> myMC.cpp: In function ‘int main()’:
> myMC.cpp:55: error: expected type-specifier before ‘MCEuropeanEngine’
> myMC.cpp:55: error: expected `)' before ‘MCEuropeanEngine’
> /home/Risco/Cxx/Quant/BoostLib/include/boost-1_38/boost/shared_ptr.hpp:
> In constructor ‘boost::shared_ptr< <template-parameter-1-1>
> >::shared_ptr(Y*) [with Y = int, T =
> QuantLib::PathPricer<QuantLib::Path, double>]’:
> myMC.cpp:57: instantiated from here
> /home/Risco/Cxx/Quant/BoostLib/include/boost-1_38/boost/shared_ptr.hpp:183:
> error: cannot convert ‘int*’ to ‘QuantLib::PathPricer<QuantLib::Path,
> double>*’ in initialization
>
> The error is from this line of the code
>
> boost::shared_ptr<PathPricer<Path> > myPathPricer(new
> MCEuropeanEngine(diffusion, timeSteps, timeStepsPerYear,
> brownianBridge, antitheticVariate, controlVariate,
> requiredSamples, requiredTolerance, maxSamples, seed));
>
> I have also attached the full code below as its very short. I can not
> understand why it says it expected a type specifier before
> MCEuropeanEngine if its a class template within QuantLib:
>
> #include <ql/quantlib.hpp>
> #include <boost/timer.hpp>
> #include <iostream>
> #include <iomanip>
>
> using namespace QuantLib;
>
> int main()
> {
>
> 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 from the BlackScholesMertonProcess
> 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));
>
> 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<PathPricer<Path> > myPathPricer(new
> MCEuropeanEngine(diffusion, timeSteps, timeStepsPerYear,
> brownianBridge, antitheticVariate, controlVariate,
> requiredSamples, requiredTolerance, maxSamples, seed));
>
> return 0;
> }
>
> Thanx in advance..
>
> ------------------------------------------------------------------------
> " Upgrade to Internet Explorer 8 Optimised for MSN. " Download Now
> <
http://extras.uk.msn.com/internet-explorer-8/?ocid=T010MSN07A0716U>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
>
http://p.sf.net/sfu/businessobjects> ------------------------------------------------------------------------
>
> _______________________________________________
> QuantLib-users mailing list
>
QuantLib-users@...
>
https://lists.sourceforge.net/lists/listinfo/quantlib-users>
for externally facing server and web deployment.