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

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

+ Inheritance diagram for CboMCEngineBuilder:
+ Collaboration diagram for CboMCEngineBuilder:

Public Member Functions

 CboMCEngineBuilder ()
 constructor that builds a usual pricing engine More...
 
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engine (const QuantLib::ext::shared_ptr< QuantLib::Pool > &pool)
 
- 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
 

Additional Inherited Members

- 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

Definition at line 32 of file cbo.hpp.

Constructor & Destructor Documentation

◆ CboMCEngineBuilder()

constructor that builds a usual pricing engine

Definition at line 35 of file cbo.hpp.

35: EngineBuilder("OneFactorCopula", "MonteCarloCBOEngine", {"CBO"}) {};
EngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes)

Member Function Documentation

◆ engine()

QuantLib::ext::shared_ptr< PricingEngine > engine ( const QuantLib::ext::shared_ptr< QuantLib::Pool > &  pool)

Definition at line 40 of file cbo.cpp.

40 {
41
42 // get parameter
43 Size samples = parseInteger(engineParameter("Samples"));
44 Size bins = parseInteger(engineParameter("Bins"));
45 long seed = parseInteger(engineParameter("Seed"));
46 double corr = parseReal(engineParameter("Correlation"));
47
48 double errorTolerance = parseReal(engineParameter("ErrorTolerance", {}, false, "1.0e-6"));
49
50 string lossDistributionPeriods_str = engineParameter("LossDistributionPeriods");
51 std::vector<string> lossDistributionPeriods_vec = parseListOfValues(lossDistributionPeriods_str);
52 std::vector<QuantLib::Period> lossDistributionPeriods;
53 for (Size i = 0; i < lossDistributionPeriods_vec.size(); i++)
54 lossDistributionPeriods.push_back(parsePeriod(lossDistributionPeriods_vec[i]));
55
56 QuantLib::ext::shared_ptr<SimpleQuote> correlationQuote(new SimpleQuote(corr));
57 Handle<Quote> correlationHandle = Handle<Quote>(correlationQuote);
58 QuantLib::ext::shared_ptr<OneFactorCopula> gaussianCopula(new OneFactorGaussianCopula(correlationHandle));
59 RelinkableHandle<OneFactorCopula> copula(gaussianCopula);
60
61 vector<DefaultProbKey> keys(pool->size(), dummyDefaultProbKey());
62
63 QuantLib::ext::shared_ptr<RandomDefaultModel> rdm(new GaussianRandomDefaultModel(pool, keys, copula, 1.e-6, seed));
64
65 return QuantLib::ext::make_shared<QuantExt::MonteCarloCBOEngine>(rdm, samples, bins, errorTolerance,
66 lossDistributionPeriods);
67};
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
std::vector< string > parseListOfValues(string s, const char escape, const char delim, const char quote)
Definition: parsers.cpp:639
+ Here is the call graph for this function: