20#include <ql/exercise.hpp>
21#include <ql/pricingengines/blackformula.hpp>
30 const Handle<YieldTermStructure>& discount,
31 const QuantLib::Handle<QuantExt::CreditVolCurve>& volatility)
32 : probability_(probability), recovery_(recovery), discount_(discount), volatility_(volatility) {
58 " of single name options quoted in terms of strike price.");
65 results_.additionalResults = cds.additionalResults();
68 Real forward = cds.fairSpreadClean();
69 results_.additionalResults[
"forwardSpread"] = forward;
71 results_.additionalResults[
"strikeSpread"] = strike;
76 Real rpv01 = std::abs(cds.couponLegNPV() + cds.accrualRebateNPV()) / (cds.notional() * cds.runningSpread());
77 results_.additionalResults[
"riskyAnnuity"] = rpv01;
80 const Date& exerciseDate =
arguments_.exercise->dates().front();
81 Real underlyingLength =
volatility_->dayCounter().yearFraction(exerciseDate, cds.maturity());
83 Real stdDev = vol * std::sqrt(
volatility_->timeFromReference(exerciseDate));
84 results_.additionalResults[
"volatility"] = vol;
85 results_.additionalResults[
"standardDeviation"] = stdDev;
88 Option::Type callPut = cds.side() == Protection::Buyer ? Option::Call : Option::Put;
89 results_.additionalResults[
"callPut"] = callPut == Option::Call ? string(
"Call") : string(
"Put");
92 results_.value = rpv01 * cds.notional() * blackFormula(callPut, strike, forward, stdDev, 1.0);
96 if (!
arguments_.knocksOut && cds.side() == Protection::Buyer) {
98 DiscountFactor disc =
discount_->discount(exerciseDate);
99 results_.additionalResults[
"discountToExercise"] = disc;
101 Probability sp =
probability_->survivalProbability(exerciseDate);
102 results_.additionalResults[
"survivalProbabilityToExercise"] = sp;
104 Real nonKoPv = disc * sp * (1 -
recovery_);
105 results_.additionalResults[
"nonKnockoutPv"] = nonKoPv;
Black credit default swap option engine.
const Instrument::results * results_
const QuantLib::Handle< QuantLib::YieldTermStructure > discount() const
QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > probability_
const QuantLib::Handle< QuantExt::CreditVolCurve > volatility() const
void calculate() const override
QuantLib::Real recovery() const
QuantLib::Handle< QuantLib::YieldTermStructure > discount_
BlackCdsOptionEngine(const QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > &probability, QuantLib::Real recovery, const QuantLib::Handle< QuantLib::YieldTermStructure > &discount, const QuantLib::Handle< QuantExt::CreditVolCurve > &volatility)
QuantLib::Handle< QuantExt::CreditVolCurve > volatility_
const QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > & probability() const
Swap::arguments * arguments_