38 ext::shared_ptr<IborIndex> index,
39 const Period& fixedLegTenor,
51 endDate_(
Null<
Date>()), maturity_(maturity), length_(length), fixedLegTenor_(fixedLegTenor),
52 index_(
std::move(index)), termStructure_(
std::move(termStructure)),
53 fixedLegDayCounter_(
std::move(fixedLegDayCounter)),
54 floatingLegDayCounter_(
std::move(floatingLegDayCounter)),
strike_(strike), nominal_(nominal),
55 settlementDays_(settlementDays), averagingMethod_(averagingMethod) {
63 ext::shared_ptr<IborIndex> index,
64 const Period& fixedLegTenor,
76 endDate_(
Null<
Date>()), maturity_(0 *
Days), length_(length), fixedLegTenor_(fixedLegTenor),
77 index_(
std::move(index)), termStructure_(
std::move(termStructure)),
78 fixedLegDayCounter_(
std::move(fixedLegDayCounter)),
79 floatingLegDayCounter_(
std::move(floatingLegDayCounter)),
strike_(strike), nominal_(nominal),
80 settlementDays_(settlementDays), averagingMethod_(averagingMethod) {
88 ext::shared_ptr<IborIndex> index,
89 const Period& fixedLegTenor,
101 endDate_(endDate), maturity_(0 *
Days), length_(0 *
Days), fixedLegTenor_(fixedLegTenor),
102 index_(
std::move(index)), termStructure_(
std::move(termStructure)),
103 fixedLegDayCounter_(
std::move(fixedLegDayCounter)),
104 floatingLegDayCounter_(
std::move(floatingLegDayCounter)),
strike_(strike), nominal_(nominal),
105 settlementDays_(settlementDays), averagingMethod_(averagingMethod) {
115 std::vector<Time> swaptionTimes =
119 times.insert(times.end(),
120 swaptionTimes.begin(), swaptionTimes.end());
132 ext::shared_ptr<PricingEngine> engine;
135 engine = ext::make_shared<BlackSwaptionEngine>(
139 engine = ext::make_shared<BachelierSwaptionEngine>(
159 index_->businessDayConvention());
162 startDate =
index_->valueDate(
index_->fixingCalendar().adjust(exerciseDate));
164 startDate = calendar.
advance(exerciseDate,
166 index_->businessDayConvention());
172 index_->businessDayConvention());
174 index_->businessDayConvention(),
175 index_->businessDayConvention(),
177 Schedule floatSchedule(startDate, endDate,
index_->tenor(), calendar,
178 index_->businessDayConvention(),
179 index_->businessDayConvention(),
182 auto swapEngine = ext::make_shared<DiscountingSwapEngine>(
termStructure_,
false);
186 auto temp =
makeSwap(fixedSchedule, floatSchedule, 0.0, type);
187 temp->setPricingEngine(swapEngine);
188 Real forward = temp->fairRate();
196 swap_->setPricingEngine(swapEngine);
205 auto onIndex = ext::dynamic_pointer_cast<OvernightIndex>(
index_);
207 return ext::make_shared<OvernightIndexedSwap>(
209 std::move(floatSchedule), onIndex, 0.0, 0,
Following,
212 return ext::make_shared<VanillaSwap>(type,
nominal_, std::move(fixedSchedule), exerciseRate,
Black-formula swaption engine.
Actual/365 (Fixed) day count convention.
liquid Black76 market instrument used during calibration
void performCalculations() const override
const VolatilityType volatilityType_
ext::shared_ptr< PricingEngine > engine_
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
std::vector< Time > mandatoryTimes() const override
Shared handle to an observable.
virtual void calculate() const
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
market element returning a stored value
Arguments for swaption calculation
ext::shared_ptr< Swaption > swaption_
void performCalculations() const override
ext::shared_ptr< FixedVsFloatingSwap > makeSwap(Schedule fixedSchedule, Schedule floatSchedule, Rate exerciseRate, Swap::Type type) const
const ext::shared_ptr< IborIndex > index_
Real blackPrice(Volatility volatility) const override
Black or Bachelier price given a volatility.
const Period fixedLegTenor_
Real modelValue() const override
returns the price of the instrument according to the model
const Natural settlementDays_
void addTimesTo(std::list< Time > ×) const override
SwaptionHelper(const Period &maturity, const Period &length, const Handle< Quote > &volatility, ext::shared_ptr< IborIndex > index, const Period &fixedLegTenor, DayCounter fixedLegDayCounter, DayCounter floatingLegDayCounter, Handle< YieldTermStructure > termStructure, CalibrationErrorType errorType=RelativePriceError, Real strike=Null< Real >(), Real nominal=1.0, VolatilityType type=ShiftedLognormal, Real shift=0.0, Natural settlementDays=Null< Size >(), RateAveraging::Type averagingMethod=RateAveraging::Compound)
ext::shared_ptr< FixedVsFloatingSwap > swap_
const DayCounter floatingLegDayCounter_
const Handle< YieldTermStructure > termStructure_
const DayCounter fixedLegDayCounter_
const RateAveraging::Type averagingMethod_
Discretized swaption class.
#define QL_FAIL(message)
throw an error (possibly with file and line information)
unsigned QL_INTEGER Natural
positive integer
Real Volatility
volatility
base class for Inter-Bank-Offered-Rate indexes
Overnight index swap paying compounded overnight vs. fixed.
Swaption calibration helper.
Simple fixed-rate vs Libor swap.