42 class LinearTsrPricer::integrand_f {
43 const LinearTsrPricer* pricer;
45 explicit integrand_f(
const LinearTsrPricer* pricer) : pricer(pricer) {}
47 return pricer->integrand(x);
58 ext::shared_ptr<Integrator> integrator)
60 couponDiscountCurve_(
std::move(couponDiscountCurve)), settings_(settings),
61 volDayCounter_(swaptionVol->dayCounter()), integrator_(
std::move(integrator)) {
68 ext::make_shared<GaussKronrodNonAdaptive>(1E-10, 5000, 1E-10);
82 const Real strike)
const {
126 Real couponCurvePaymentDiscount;
130 couponCurvePaymentDiscount = 1.0;
149 if (
auto on = ext::dynamic_pointer_cast<OvernightIndexedSwapIndex>(
swapIndex_)) {
156 Leg swapFixedLeg =
swap_->fixedLeg();
158 ext::shared_ptr<SmileSection> sectionTmp =
164 if(sectionTmp->volatilityType() ==
Normal) {
185 Real gx = 0.0, gy = 0.0;
186 for (
const auto& i : swapFixedLeg) {
187 ext::shared_ptr<Coupon> c = ext::dynamic_pointer_cast<Coupon>(i);
188 Real yf = c->accrualPeriod();
195 Real gamma = gx / gy;
196 Date lastd = swapFixedLeg.back()->date();
210 Real referenceStrike)
const {
212 Real a,
b, min, max, k;
215 min = referenceStrike;
224 max = referenceStrike;
232 k = solver.
solve(h, 1.0E-5, (a +
b) / 2.0, a,
b);
238 return std::min(std::max(k, min), max);
242 Real referenceStrike)
const {
244 Real a,
b, min, max, k;
247 min = referenceStrike;
256 max = referenceStrike;
269 return std::min(std::max(k, min), max);
282 Real lower = strike, upper = strike;
322 Real lowerTmp, upperTmp;
324 upperTmp = (atm + shift) *
326 0.5 * atmVol * atmVol *
329 lowerTmp = (atm + shift) *
331 0.5 * atmVol * atmVol *
337 upperTmp = atm + tmp;
338 lowerTmp = atm - tmp;
355 if (tmpBound > lower) {
356 result += (*integrator_)(integrand_f(
this),
360 if (upper > tmpBound) {
361 result += (*integrator_)(integrand_f(
this),
384 const Rate Rs = std::max(
404 const Rate Rs = std::max(
433 atmCapletPrice - atmFloorletPrice) +
smile section that allows for explicit / alternate specification of atm level
const ext::shared_ptr< SwapIndex > & swapIndex() const
base pricer for vanilla CMS coupons
Handle< SwaptionVolatilityStructure > swaptionVolatility() const
Date date() const override
Time accrualPeriod() const
accrual period as fraction of year
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.
base floating-rate coupon class
virtual Date fixingDate() const
fixing date
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
Spread spread() const
spread paid over the fixing of the underlying index
Shared handle to an observable.
const CmsCoupon * coupon_
Real couponDiscountRatio_
Real capletPrice(Rate effectiveCap) const override
Rate floorletRate(Rate effectiveFloor) const override
Handle< YieldTermStructure > discountCurve_
Real singularTerms(Option::Type type, Real strike) const
Real strikeFromPrice(Real price, Option::Type optionType, Real referenceStrike) const
Handle< Quote > meanReversion_
LinearTsrPricer(const Handle< SwaptionVolatilityStructure > &swaptionVol, Handle< Quote > meanReversion, Handle< YieldTermStructure > couponDiscountCurve=Handle< YieldTermStructure >(), const Settings &settings=Settings(), ext::shared_ptr< Integrator > integrator=ext::shared_ptr< Integrator >())
ext::shared_ptr< SmileSection > smileSection_
void initialize(const FloatingRateCoupon &coupon) override
ext::shared_ptr< Integrator > integrator_
DayCounter volDayCounter_
ext::shared_ptr< SwapIndex > swapIndex_
static const Real defaultLowerBound
Real integrand(Real strike) const
Real strikeFromVegaRatio(Real ratio, Option::Type optionType, Real referenceStrike) const
static const Real defaultUpperBound
ext::shared_ptr< FixedVsFloatingSwap > swap_
Handle< YieldTermStructure > couponDiscountCurve_
Real GsrG(const Date &d) const
Real discountCurvePaymentDiscount_
Rate swapletRate() const override
Real floorletPrice(Rate effectiveFloor) const override
Real meanReversion() const override
Handle< YieldTermStructure > forwardCurve_
Real swapletPrice() const override
Real optionletPrice(Option::Type optionType, Real strike) const
Rate capletRate(Rate effectiveCap) const override
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
static Settings & instance()
access to the unique instance
Real solve(const F &f, Real accuracy, Real guess, Real step) const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
ext::function< Real(Real)> b
Coupon paying a fixed annual rate.
Coupon paying a Libor-type index.
base class for Inter-Bank-Offered-Rate indexes
Integral of a 1-dimensional function using the Gauss-Kronrod method.
linear terminal swap rate model for cms coupon pricing
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Overnight index swap paying compounded overnight vs. fixed.
Simple fixed-rate vs Libor swap.
Interest-rate term structure.