inline Real EuropeanHestonPathPricer::operator()( const MultiPath& multiPath) const { const Path& path = multiPath[0]; const Size n = multiPath.pathSize(); QL_REQUIRE(n>0, "the path cannot be empty"); return payoff_(path.back()) * discount_; }
Real EuropeanMultiPathPricer::operator()(const MultiPath& multiPath) const { Size n = multiPath.pathSize(); QL_REQUIRE(n>0, "the path cannot be empty"); Size numAssets = multiPath.assetNumber(); QL_REQUIRE(numAssets>0, "there must be some paths"); Size j; // calculate the final price of each asset Array finalPrice(numAssets, 0.0); for (j = 0; j < numAssets; j++) finalPrice[j] = multiPath[j].back(); return (*payoff_)(finalPrice) * discount_; }
Real EverestMultiPathPricer::operator()(const MultiPath& multiPath) const { Size n = multiPath.pathSize(); QL_REQUIRE(n>0, "the path cannot be empty"); Size numAssets = multiPath.assetNumber(); QL_REQUIRE(numAssets>0, "there must be some paths"); // We search the yield min Real minYield = multiPath[0].back() / multiPath[0].front() - 1.0; for (Size j=1; j<numAssets; ++j) { Rate yield = multiPath[j].back() / multiPath[j].front() - 1.0; minYield = std::min(minYield, yield); } return (1.0 + minYield + guarantee_) * notional_ * discount_; }
Real PagodaMultiPathPricer::operator()(const MultiPath& multiPath) const { Size numAssets = multiPath.assetNumber(); Size numSteps = multiPath.pathSize(); Real averagePerformance = 0.0; for (Size i = 1; i < numSteps; i++) { for (Size j = 0; j < numAssets; j++) { averagePerformance += multiPath[j].front() * (multiPath[j][i]/multiPath[j][i-1] - 1.0); } } averagePerformance /= numAssets; return discount_ * fraction_ * std::max<Real>(0.0, std::min(roof_, averagePerformance)); }