25#ifndef quantlib_basketgeneratingengine_hpp
26#define quantlib_basketgeneratingengine_hpp
68 std::vector<ext::shared_ptr<BlackCalibrationHelper>>
70 const ext::shared_ptr<SwapIndex>& standardSwapBase,
71 const ext::shared_ptr<SwaptionVolatilityStructure>& swaptionVolatility,
107 ext::shared_ptr<Gaussian1dModel> model,
108 ext::shared_ptr<SwapIndex> indexBase,
110 const Real maxMaturity,
122 for (
const auto& i :
swap->fixedLeg()) {
123 ext::shared_ptr<FixedRateCoupon> c =
124 ext::dynamic_pointer_cast<FixedRateCoupon>(i);
126 fixedRate * c->accrualPeriod() * nominal *
130 for (
const auto& i :
swap->floatingLeg()) {
131 ext::shared_ptr<IborCoupon> c = ext::dynamic_pointer_cast<IborCoupon>(i);
135 c->accrualPeriod() * nominal *
139 return (
Real)type * npv;
145 for (
Real val : vals) {
148 return std::sqrt(res / vals.
size());
155 Real nominal = std::fabs(
v[0]);
160 Real fixedRate =
v[2];
180 ext::shared_ptr<SwapIndex> tmpIndexLower, tmpIndexUpper;
181 tmpIndexLower =
indexBase_->clone(lowerPeriod);
182 tmpIndexUpper =
indexBase_->clone(upperPeriod);
183 ext::shared_ptr<VanillaSwap> swapLower =
184 tmpIndexLower->underlyingSwap(
expiry_);
185 ext::shared_ptr<VanillaSwap> swapUpper =
186 tmpIndexUpper->underlyingSwap(
expiry_);
189 alpha *
NPV(swapLower, fixedRate, nominal, -
h_, type) +
191 NPV(swapUpper, fixedRate, nominal, -
h_, type);
193 alpha *
NPV(swapLower, fixedRate, nominal, 0.0, type) +
195 NPV(swapUpper, fixedRate, nominal, 0.0, type);
197 alpha *
NPV(swapLower, fixedRate, nominal,
h_, type) +
199 NPV(swapUpper, fixedRate, nominal,
h_, type);
200 Real delta = (npvu - npvm) / (2.0 *
h_);
201 Real gamma = (npvu - 2.0 * npv + npvm) / (
h_ *
h_);
226 const ext::shared_ptr<Gaussian1dModel>
mdl_;
1-D array used in linear algebra.
Size size() const
dimension of the array
MatchHelper(const Swap::Type type, const Real npv, const Real delta, const Real gamma, ext::shared_ptr< Gaussian1dModel > model, ext::shared_ptr< SwapIndex > indexBase, const Date &expiry, const Real maxMaturity, const Real h)
Real NPV(const ext::shared_ptr< VanillaSwap > &swap, Real fixedRate, Real nominal, Real y, int type) const
Real value(const Array &v) const override
method to overload to compute the cost function value in x
const ext::shared_ptr< SwapIndex > indexBase_
const ext::shared_ptr< Gaussian1dModel > mdl_
Array values(const Array &v) const override
method to overload to compute the cost function values in x
BasketGeneratingEngine(const ext::shared_ptr< Gaussian1dModel > &model, Handle< Quote > oas, Handle< YieldTermStructure > discountCurve)
const Handle< YieldTermStructure > discountCurve_
virtual Real underlyingNpv(const Date &expiry, Real y) const =0
std::vector< ext::shared_ptr< BlackCalibrationHelper > > calibrationBasket(const ext::shared_ptr< Exercise > &exercise, const ext::shared_ptr< SwapIndex > &standardSwapBase, const ext::shared_ptr< SwaptionVolatilityStructure > &swaptionVolatility, CalibrationBasketType basketType=MaturityStrikeByDeltaGamma) const
const Handle< Quote > oas_
virtual const Date underlyingLastDate() const =0
virtual const Array initialGuess(const Date &expiry) const =0
const Handle< Gaussian1dModel > onefactormodel_
@ MaturityStrikeByDeltaGamma
virtual Swap::Type underlyingType() const =0
virtual ~BasketGeneratingEngine()=default
BasketGeneratingEngine(Handle< Gaussian1dModel > model, Handle< Quote > oas, Handle< YieldTermStructure > discountCurve)
Cost function abstract class for optimization problem.
Shared handle to an observable.
Optimization cost function class.
Coupon paying a fixed annual rate.
basic interface for one factor interest rate models
std::size_t Size
size of a container
Coupon paying a Libor-type index.
Real months(const Period &p)
Real years(const Period &p)
void swap(Array &v, Array &w) noexcept
ext::shared_ptr< BlackVolTermStructure > v
Global definitions and compiler switches.
Swaption volatility structure.
Simple fixed-rate vs Libor swap.
Interest-rate term structure.