36 class IrregularImpliedVolHelper {
38 IrregularImpliedVolHelper(
const IrregularSwaption&,
39 Handle<YieldTermStructure> discountCurve,
47 ext::shared_ptr<SimpleQuote>
vol_;
51 IrregularImpliedVolHelper::IrregularImpliedVolHelper(
52 const IrregularSwaption& swaption,
53 Handle<YieldTermStructure> discountCurve,
56 vol_(ext::make_shared<SimpleQuote>(-1.0)) {
58 Handle<Quote> h(
vol_);
59 engine_ = ext::shared_ptr<PricingEngine>(
new
61 swaption.setupArguments(
engine_->getArguments());
64 dynamic_cast<const Instrument::results*
>(
engine_->getResults());
67 Real IrregularImpliedVolHelper::operator()(Volatility x)
const {
68 if (x!=
vol_->value()) {
75 Real IrregularImpliedVolHelper::derivative(Volatility x)
const {
76 if (x!=
vol_->value()) {
80 auto vega_ =
results_->additionalResults.find(
"vega");
83 return ext::any_cast<Real>(vega_->second);
90 case IrregularSettlement::Physical:
91 return out <<
"Delivery";
92 case IrregularSettlement::Cash:
99 IrregularSwaption::IrregularSwaption(ext::shared_ptr<IrregularSwap> swap,
100 const ext::shared_ptr<Exercise>& exercise,
103 settlementType_(delivery) {
113 swap_->setupArguments(args);
141 IrregularImpliedVolHelper
f(*
this, discountCurve, targetValue);
145 return solver.
solve(
f, accuracy, guess, minVol, maxVol);
Maps any to either the boost or std implementation.
Black-formula swaption engine.
const YieldTermStructure & discountCurve_
ext::shared_ptr< SimpleQuote > vol_
ext::shared_ptr< PricingEngine > engine_
const Instrument::results * results_
virtual bool hasOccurred(const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const
returns true if an event has already occurred before a date
Shared handle to an observable.
void calculate() const override
void validate() const override
Arguments for irregular-swaption calculation
ext::shared_ptr< IrregularSwap > swap
IrregularSettlement::Type settlementType
void validate() const override
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
returns whether the instrument might have value greater than zero.
IrregularSettlement::Type settlementType_
ext::shared_ptr< IrregularSwap > swap_
Volatility impliedVolatility(Real price, const Handle< YieldTermStructure > &discountCurve, Volatility guess, Real accuracy=1.0e-4, Natural maxEvaluations=100, Volatility minVol=1.0e-7, Volatility maxVol=4.0) const
implied volatility
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
ext::shared_ptr< Exercise > exercise
ext::shared_ptr< Exercise > exercise_
Abstract base class for option payoffs.
void setMaxEvaluations(Size evaluations)
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)
Option exercise classes and payoff function.
unsigned QL_INTEGER Natural
positive integer
Real Volatility
volatility
QL_INTEGER Integer
integer number
Handle< YieldTermStructure > discountCurve_
ext::shared_ptr< SimpleQuote > vol_
ext::shared_ptr< PricingEngine > engine_
const Instrument::results * results_
Irregular swaption class.
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
void swap(Array &v, Array &w) noexcept
Safe (bracketed) Newton 1-D solver.