Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
creditdefaultswapoption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file portfolio/builders/creditdefaultswapoption.hpp
20\brief Builder that returns an engine to price a credit default swap option
21\ingroup builders
22*/
23
24#pragma once
25
27
29
30namespace ore {
31namespace data {
32
33//! Engine Builder base class for Credit Default Swap Options
34/*! Pricing engines are cached by creditCurveId and cds term.
35 \ingroup portfolio
36*/
37
39 : public CachingPricingEngineBuilder<string, const Currency&, const string&, const string&> {
40
41protected:
42 CreditDefaultSwapOptionEngineBuilder(const std::string& model, const std::string& engine)
43 : CachingEngineBuilder(model, engine, {"CreditDefaultSwapOption"}) {}
44
45 virtual string keyImpl(const Currency&, const string& creditCurveId,
46 const string& term) override {
47 return term.empty() ? creditCurveId : creditCurveId + "-" + term;
48 }
49};
50
51//! Black CDS option engine builder for CDS options.
52/*! This class creates a BlackCdsOptionEngine
53 \ingroup portfolio
54*/
55
57public:
59 : CreditDefaultSwapOptionEngineBuilder("Black", "BlackCdsOptionEngine") {}
60
61protected:
62 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const Currency& ccy, const string& creditCurveId,
63 const string& term) override {
64
65 string curveId = term.empty() ? creditCurveId : creditCurveId + "-" + term;
66 Handle<YieldTermStructure> yts = market_->discountCurve(ccy.code(), configuration(MarketContext::pricing));
67 Handle<QuantExt::CreditVolCurve> vol = market_->cdsVol(curveId, configuration(MarketContext::pricing));
68 Handle<DefaultProbabilityTermStructure> dpts =
69 market_->defaultCurve(creditCurveId, configuration(MarketContext::pricing))->curve();
70 Handle<Quote> recovery = market_->recoveryRate(creditCurveId, configuration(MarketContext::pricing));
71 return QuantLib::ext::make_shared<QuantExt::BlackCdsOptionEngine>(dpts, recovery->value(), yts, vol);
72 }
73};
74
75} // namespace data
76} // namespace ore
Builder that returns an engine to price a credit default swap.
Black CDS option engine builder for CDS options.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &ccy, const string &creditCurveId, const string &term) override
Abstract template EngineBuilder class that can cache engines and coupon pricers.
Engine Builder base class for Credit Default Swap Options.
CreditDefaultSwapOptionEngineBuilder(const std::string &model, const std::string &engine)
virtual string keyImpl(const Currency &, const string &creditCurveId, const string &term) override
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
const string & model() const
Return the model name.
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23