Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
BondOptionEngineBuilder Class Reference

Engine builder for bond option. More...

#include <ored/portfolio/builders/bondoption.hpp>

+ Inheritance diagram for BondOptionEngineBuilder:
+ Collaboration diagram for BondOptionEngineBuilder:

Public Member Functions

 BondOptionEngineBuilder ()
 
- Public Member Functions inherited from CachingEngineBuilder< T, U, Args >
 CachingEngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
 
QuantLib::ext::shared_ptr< U > engine (Args... params)
 Return a PricingEngine or a FloatingRateCouponPricer. More...
 
void reset () override
 reset the builder (e.g. clear cache) More...
 
- Public Member Functions inherited from EngineBuilder
 EngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
 
virtual ~EngineBuilder ()
 Virtual destructor. More...
 
const string & model () const
 Return the model name. More...
 
const string & engine () const
 Return the engine name. More...
 
const set< string > & tradeTypes () const
 Return the possible trade types. More...
 
const string & configuration (const MarketContext &key)
 Return a configuration (or the default one if key not found) More...
 
virtual void reset ()
 reset the builder (e.g. clear cache) More...
 
void init (const QuantLib::ext::shared_ptr< Market > market, const map< MarketContext, string > &configurations, const map< string, string > &modelParameters, const map< string, string > &engineParameters, const std::map< std::string, std::string > &globalParameters={})
 Initialise this Builder with the market and parameters to use. More...
 
const set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > & modelBuilders () const
 return model builders More...
 
std::string engineParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
 
std::string modelParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
 

Protected Member Functions

virtual std::string keyImpl (const string &id, const Currency &ccy, const string &creditCurveId, const bool hasCreditRisk, const string &securityId, const string &referenceCurveId, const string &volatilityCurveId) override
 
virtual QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engineImpl (const string &id, const Currency &ccy, const string &creditCurveId, const bool hasCreditRisk, const string &securityId, const string &referenceCurveId, const string &volatilityCurveId) override
 
- Protected Member Functions inherited from CachingEngineBuilder< T, U, Args >
virtual T keyImpl (Args...)=0
 
virtual QuantLib::ext::shared_ptr< U > engineImpl (Args...)=0
 

Additional Inherited Members

- Protected Attributes inherited from CachingEngineBuilder< T, U, Args >
map< T, QuantLib::ext::shared_ptr< U > > engines_
 
- Protected Attributes inherited from EngineBuilder
string model_
 
string engine_
 
set< string > tradeTypes_
 
QuantLib::ext::shared_ptr< Marketmarket_
 
map< MarketContext, string > configurations_
 
map< string, string > modelParameters_
 
map< string, string > engineParameters_
 
std::map< std::string, std::string > globalParameters_
 
set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > modelBuilders_
 

Detailed Description

Engine builder for bond option.

Pricing engines are cached by currency, creditCurve, securityId and referenceCurve

Definition at line 47 of file bondoption.hpp.

Constructor & Destructor Documentation

◆ BondOptionEngineBuilder()

Definition at line 51 of file bondoption.hpp.

51: CachingEngineBuilder("Black", "BlackBondOptionEngine", {"BondOption"}) {}
CachingEngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes)

Member Function Documentation

◆ keyImpl()

virtual std::string keyImpl ( const string &  id,
const Currency &  ccy,
const string &  creditCurveId,
const bool  hasCreditRisk,
const string &  securityId,
const string &  referenceCurveId,
const string &  volatilityCurveId 
)
overrideprotectedvirtual

Definition at line 54 of file bondoption.hpp.

56 {
57 // id is _not_ part of the key
58 return ccy.code() + "_" + creditCurveId + "_" + (hasCreditRisk ? "1_" : "0_") + securityId + "_" +
59 referenceCurveId + "_" + volatilityCurveId + "_" + "BondOption";
60 }

◆ engineImpl()

virtual QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engineImpl ( const string &  id,
const Currency &  ccy,
const string &  creditCurveId,
const bool  hasCreditRisk,
const string &  securityId,
const string &  referenceCurveId,
const string &  volatilityCurveId 
)
overrideprotectedvirtual

Definition at line 63 of file bondoption.hpp.

64 {
65
66 Handle<YieldTermStructure> discountCurve =
67 market_->discountCurve(ccy.code(), configuration(MarketContext::pricing));
68 QL_REQUIRE(!volatilityCurveId.empty(), "BondOptionEngineBuilder: volatility curve ID for trade id '"
69 << id << "', security id '" << securityId << "' not given");
70 Handle<QuantLib::SwaptionVolatilityStructure> yieldVola =
71 market_->yieldVol(volatilityCurveId, configuration(MarketContext::pricing));
72 Handle<YieldTermStructure> yts = market_->yieldCurve(referenceCurveId, configuration(MarketContext::pricing));
73 Handle<DefaultProbabilityTermStructure> dpts;
74 // credit curve may not always be used. If credit curve ID is empty proceed without it
75 if (!creditCurveId.empty())
76 dpts =
78 ->curve();
79 Handle<Quote> recovery;
80 try {
81 // try security recovery first
82 recovery = market_->recoveryRate(securityId, configuration(MarketContext::pricing));
83 } catch (...) {
84 // otherwise fall back on curve recovery
85 ALOG("security specific recovery rate not found for security ID "
86 << securityId << ", falling back on the recovery rate for credit curve Id " << creditCurveId);
87 if (!creditCurveId.empty())
88 recovery = market_->recoveryRate(creditCurveId, configuration(MarketContext::pricing));
89 }
90 Handle<Quote> spread;
91 try {
92 // spread is optional, pass empty handle to engine if not given (will be treated as 0 spread there)
93 spread = market_->securitySpread(securityId, configuration(MarketContext::pricing));
94 } catch (...) {
95 }
96
97 if (!hasCreditRisk) {
98 dpts = Handle<DefaultProbabilityTermStructure>();
99 }
100
101 return QuantLib::ext::make_shared<QuantExt::BlackBondOptionEngine>(
102 discountCurve, yieldVola, yts, dpts, recovery, spread, parsePeriod(engineParameter("TimestepPeriod")));
103 };
QuantLib::ext::shared_ptr< Market > market_
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
QuantLib::Handle< QuantExt::CreditCurve > securitySpecificCreditCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &securityId, const std::string &creditCurveId, const std::string &configuration)
Definition: marketdata.cpp:98
+ Here is the call graph for this function: