34 class ImpliedVolHelper {
37 const CdsOption& cdsoption,
38 const Handle<DefaultProbabilityTermStructure>& probability,
40 const Handle<YieldTermStructure>& termStructure,
44 Handle<Quote> h(vol_);
45 engine_ = ext::shared_ptr<PricingEngine>(
46 new BlackCdsOptionEngine(probability, recoveryRate,
48 cdsoption.setupArguments(
engine_->getArguments());
51 dynamic_cast<const Instrument::results*
>(
62 ext::shared_ptr<SimpleQuote>
vol_;
70 const ext::shared_ptr<Exercise>& exercise,
73 swap_(
swap), knocksOut_(knocksOut) {
75 "receiver CDS options must knock out");
76 QL_REQUIRE(!
swap->upfront(),
"underlying must be running-spread only");
90 swap_->setupArguments(args);
111 return swap_->fairSpread();
134 ImpliedVolHelper
f(*
this, probability, recoveryRate,
135 termStructure, targetValue);
138 return solver.
solve(
f, accuracy, guess, minVol, maxVol);
151 Option::results::reset();
Black credit default swap option engine.
ext::shared_ptr< SimpleQuote > vol_
ext::shared_ptr< PricingEngine > engine_
const Instrument::results * results_
Arguments for CDS-option calculation
ext::shared_ptr< CreditDefaultSwap > swap
void validate() const override
Results from CDS-option calculation
Real riskyAnnuity() const
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
returns whether the instrument might have value greater than zero.
CdsOption(const ext::shared_ptr< CreditDefaultSwap > &swap, const ext::shared_ptr< Exercise > &exercise, bool knocksOut=true)
Volatility impliedVolatility(Real price, const Handle< YieldTermStructure > &termStructure, const Handle< DefaultProbabilityTermStructure > &, Real recoveryRate, Real accuracy=1.e-4, Size maxEvaluations=100, Volatility minVol=1.0e-7, Volatility maxVol=4.0) const
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
ext::shared_ptr< CreditDefaultSwap > swap_
void validate() const override
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
virtual void fetchResults(const PricingEngine::results *) const
virtual void setupExpired() const
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
ext::shared_ptr< Exercise > exercise
void validate() const override
void setupArguments(PricingEngine::arguments *) const override
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_ENSURE(condition, message)
throw an error if the given post-condition is not verified
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
Real Volatility
volatility
std::size_t Size
size of a container
void swap(Array &v, Array &w) noexcept
normal, cumulative and inverse cumulative distributions
Payoffs for various options.
ext::shared_ptr< YieldTermStructure > r
Interest-rate term structure.