inline boost::shared_ptr<LongstaffSchwartzMultiPathPricer> MCAmericanPathEngine<RNG>::lsmPathPricer() const { boost::shared_ptr<StochasticProcessArray> processArray = boost::dynamic_pointer_cast<StochasticProcessArray>(this->process_); QL_REQUIRE(processArray && processArray->size()>0, "Stochastic process array required"); boost::shared_ptr<GeneralizedBlackScholesProcess> process = boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>( processArray->process(0)); QL_REQUIRE(process, "generalized Black-Scholes process required"); const TimeGrid theTimeGrid = this->timeGrid(); const std::vector<Time> & times = theTimeGrid.mandatoryTimes(); const Size numberOfTimes = times.size(); const std::vector<Date> & fixings = this->arguments_.fixingDates; QL_REQUIRE(fixings.size() == numberOfTimes, "Invalid dates/times"); std::vector<Size> timePositions(numberOfTimes); Array discountFactors(numberOfTimes); std::vector<Handle<YieldTermStructure> > forwardTermStructures(numberOfTimes); const Handle<YieldTermStructure> & riskFreeRate = process->riskFreeRate(); for (Size i = 0; i < numberOfTimes; ++i) { timePositions[i] = theTimeGrid.index(times[i]); discountFactors[i] = riskFreeRate->discount(times[i]); forwardTermStructures[i] = Handle<YieldTermStructure>( boost::make_shared<ImpliedTermStructure>(riskFreeRate, fixings[i])); } const Size polynomialOrder = 2; const LsmBasisSystem::PolynomType polynomType = LsmBasisSystem::Monomial; return boost::shared_ptr<LongstaffSchwartzMultiPathPricer> ( new LongstaffSchwartzMultiPathPricer(this->arguments_.payoff, timePositions, forwardTermStructures, discountFactors, polynomialOrder, polynomType)); }
inline boost::shared_ptr<typename MCPathBasketEngine<RNG,S>::path_pricer_type> MCPathBasketEngine<RNG,S>::pathPricer() const { boost::shared_ptr<PathPayoff> payoff = arguments_.payoff; QL_REQUIRE(payoff, "non-basket payoff given"); boost::shared_ptr<GeneralizedBlackScholesProcess> process = boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>( process_->process(0)); QL_REQUIRE(process, "Black-Scholes process required"); const TimeGrid theTimeGrid = timeGrid(); const std::vector<Time> & times = theTimeGrid.mandatoryTimes(); const Size numberOfTimes = times.size(); const std::vector<Date> & fixings = this->arguments_.fixingDates; QL_REQUIRE(fixings.size() == numberOfTimes, "Invalid dates/times"); std::vector<Size> timePositions(numberOfTimes); Array discountFactors(numberOfTimes); std::vector<Handle<YieldTermStructure> > forwardTermStructures(numberOfTimes); const Handle<YieldTermStructure> & riskFreeRate = process->riskFreeRate(); for (Size i = 0; i < numberOfTimes; ++i) { timePositions[i] = theTimeGrid.index(times[i]); discountFactors[i] = riskFreeRate->discount(times[i]); forwardTermStructures[i] = Handle<YieldTermStructure>( new ImpliedTermStructure(riskFreeRate, fixings[i])); } return boost::shared_ptr< typename MCPathBasketEngine<RNG,S>::path_pricer_type>( new EuropeanPathMultiPathPricer(payoff, timePositions, forwardTermStructures, discountFactors)); }