27 class Gaussian1dJamshidianSwaptionEngine::rStarFinder {
29 rStarFinder(
const ext::shared_ptr<Gaussian1dModel>& model,
31 const Date& maturityDate,
32 const Date& valueDate,
33 std::vector<Date> fixedPayDates,
34 const std::vector<Real>& amounts,
35 const Size startIndex)
36 :
strike_(nominal), maturityDate_(maturityDate), valueDate_(valueDate),
37 startIndex_(startIndex), times_(
std::move(fixedPayDates)), amounts_(amounts),
42 Size size = times_.size();
43 for (
Size i = startIndex_; i < size; i++) {
44 Real dbValue = model_->zerobond(times_[i], maturityDate_,
y) /
45 model_->zerobond(valueDate_, maturityDate_,
y);
46 value -= amounts_[i] * dbValue;
53 Date maturityDate_, valueDate_;
55 std::vector<Date> times_;
56 const std::vector<Real> &amounts_;
57 const ext::shared_ptr<Gaussian1dModel> &model_;
63 "cash settled (ParYieldCurve) swaptions not priced with "
64 "Gaussian1dJamshidianSwaptionEngine");
67 "cannot use the Jamshidian decomposition "
68 "on exotic swaptions");
71 "non zero spread (" <<
arguments_.swap->spread()
75 "non-constant nominals are not supported yet");
80 referenceDate =
model_->termStructure()->referenceDate();
81 dayCounter =
model_->termStructure()->dayCounter();
83 std::vector<Real> amounts(
arguments_.fixedCoupons);
86 Size startIndex = std::upper_bound(
arguments_.fixedResetDates.begin(),
95 arguments_.fixedPayDates, amounts, startIndex);
97 Rate minStrike = -8.0;
102 Rate rStar = s1d.
solve(finder, 1e-8, 0.00, minStrike,
110 for (
Size i = startIndex; i < size; i++) {
122 value += amounts[i] * dboValue;
void calculate() const override
Handle< Gaussian1dModel > model_
template class providing a null value for a given type.
void setMaxEvaluations(Size evaluations)
void setLowerBound(Real lowerBound)
sets the lower bound for the function domain
Real solve(const F &f, Real accuracy, Real guess, Real step) const
void setUpperBound(Real upperBound)
sets the upper bound for the function domain
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Swaption engine using Jamshidian's decomposition.
std::size_t Size
size of a container