27 class JamshidianSwaptionEngine::rStarFinder {
29 rStarFinder(
const ext::shared_ptr<OneFactorAffineModel>& model,
33 std::vector<Time> fixedPayTimes,
34 const std::vector<Real>& amounts)
35 :
strike_(nominal), maturity_(maturity), valueTime_(valueTime),
36 times_(
std::move(fixedPayTimes)), amounts_(amounts), model_(model) {}
40 Real B = model_->discountBond(maturity_, valueTime_, x);
41 Size size = times_.size();
42 for (
Size i=0; i<size; i++) {
44 model_->discountBond(maturity_, times_[i], x) / B;
45 value -= amounts_[i]*dbValue;
51 Time maturity_,valueTime_;
52 std::vector<Time> times_;
53 const std::vector<Real>& amounts_;
54 const ext::shared_ptr<OneFactorAffineModel>& model_;
60 "cash settled (ParYieldCurve) swaptions not priced with "
61 "JamshidianSwaptionEngine");
64 "cannot use the Jamshidian decomposition "
65 "on exotic swaptions");
70 "non-constant nominals are not supported yet");
77 ext::shared_ptr<TermStructureConsistentModel> tsmodel =
78 ext::dynamic_pointer_cast<TermStructureConsistentModel>(*
model_);
79 if (tsmodel !=
nullptr) {
80 referenceDate = tsmodel->termStructure()->referenceDate();
81 dayCounter = tsmodel->termStructure()->dayCounter();
87 std::vector<Real> amounts(
arguments_.fixedCoupons);
93 std::vector<Time> fixedPayTimes(
arguments_.fixedPayDates.size());
95 for (
Size i=0; i<fixedPayTimes.size(); i++)
96 fixedPayTimes[i] = dayCounter.
yearFraction(referenceDate,
100 fixedPayTimes, amounts);
102 Rate minStrike = -10.0;
103 Rate maxStrike = 10.0;
107 Rate rStar = s1d.
solve(finder, 1e-8, 0.05, minStrike, maxStrike);
113 Real B =
model_->discountBond(maturity, valueTime, rStar);
114 for (
Size i=0; i<size; i++) {
123 w, strike, maturity, valueTime,
125 value += amounts[i]*dboValue;
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Handle< OneFactorAffineModel > model_
bool empty() const
checks if the contained shared pointer points to anything
void calculate() const override
Handle< YieldTermStructure > termStructure_
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
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Swaption engine using Jamshidian's decomposition Concerning the start delay cf. http://ssrn....