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

Base PricingEngine Builder class for a specific model and engine. More...

#include <ored/portfolio/enginefactory.hpp>

+ Inheritance diagram for EngineBuilder:
+ Collaboration diagram for EngineBuilder:

Public Member Functions

 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 Attributes

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

Base PricingEngine Builder class for a specific model and engine.

The EngineBuilder is responsible for building pricing engines for a specific Model and Engine.

Each builder should implement a method with a signature

QuantLib::ext::shared_ptr<PricingEngine> engine (...);
const string & engine() const
Return the engine name.

The exact parameters of each method can vary depending on the type of engine.

An EngineBuilder can cache engines and return the same PricingEngine multiple times, alternatively the Builder can build a unique PricingEngine each time it is called.

For example a swap engine builder can have the interface

QuantLib::ext::shared_ptr<PricingEngine> engine (const Currency&);

and so returns the same (cached) engine every time it is asked for a particular currency.

The interface of each type of engine builder can be different, then there can be further sub-classes for different models and engines.

EngineBuilders are registered in an EngineFactory, multiple engine builders for the same trade type can be registered with the EngineFactory and it will select the appropriate one based on configuration.

Each EngineBuilder must return it's Model and Engine.

Definition at line 95 of file enginefactory.hpp.

Constructor & Destructor Documentation

◆ EngineBuilder()

EngineBuilder ( const string &  model,
const string &  engine,
const set< string > &  tradeTypes 
)

Constructor that takes a model and engine name

Parameters
modelthe model name
enginethe engine name
tradeTypesa set of trade types

Definition at line 102 of file enginefactory.hpp.

const set< string > & tradeTypes() const
Return the possible trade types.
const string & model() const
Return the model name.

◆ ~EngineBuilder()

virtual ~EngineBuilder ( )
virtual

Virtual destructor.

Definition at line 106 of file enginefactory.hpp.

106{}

Member Function Documentation

◆ model()

const string & model ( ) const

Return the model name.

Definition at line 109 of file enginefactory.hpp.

109{ return model_; }
+ Here is the caller graph for this function:

◆ engine()

const string & engine ( ) const

Return the engine name.

Definition at line 111 of file enginefactory.hpp.

111{ return engine_; }
+ Here is the caller graph for this function:

◆ tradeTypes()

const set< string > & tradeTypes ( ) const

Return the possible trade types.

Definition at line 113 of file enginefactory.hpp.

113{ return tradeTypes_; }

◆ configuration()

const string & configuration ( const MarketContext key)

Return a configuration (or the default one if key not found)

Definition at line 116 of file enginefactory.hpp.

116 {
117 if (configurations_.count(key) > 0) {
118 return configurations_.at(key);
119 } else {
121 }
122 }
map< MarketContext, string > configurations_
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
+ Here is the caller graph for this function:

◆ reset()

virtual void reset ( )
virtual

reset the builder (e.g. clear cache)

Reimplemented in CachingEngineBuilder< T, U, Args >.

Definition at line 125 of file enginefactory.hpp.

125{}

◆ init()

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.

This method should not be called directly, it is called by the EngineFactory before it is returned.

Definition at line 131 of file enginefactory.hpp.

133 {}) {
134 market_ = market;
135 configurations_ = configurations;
136 modelParameters_ = modelParameters;
137 engineParameters_ = engineParameters;
138 globalParameters_ = globalParameters;
139 }
QuantLib::ext::shared_ptr< Market > market_
map< string, string > engineParameters_
std::map< std::string, std::string > globalParameters_
map< string, string > modelParameters_

◆ modelBuilders()

const set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > & modelBuilders ( ) const

return model builders

Definition at line 142 of file enginefactory.hpp.

142{ return modelBuilders_; }
set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > modelBuilders_

◆ engineParameter()

std::string engineParameter ( const std::string &  p,
const std::vector< std::string > &  qualifiers = {},
const bool  mandatory = true,
const std::string &  defaultValue = "" 
) const

retrieve engine parameter p, first look for p_qualifier, if this does not exist fall back to p

Definition at line 55 of file enginefactory.cpp.

56 {
57 return getParameter(engineParameters_, p, qualifiers, mandatory, defaultValue);
58}
+ Here is the caller graph for this function:

◆ modelParameter()

std::string modelParameter ( const std::string &  p,
const std::vector< std::string > &  qualifiers = {},
const bool  mandatory = true,
const std::string &  defaultValue = "" 
) const

retrieve model parameter p, first look for p_qualifier, if this does not exist fall back to p

Definition at line 60 of file enginefactory.cpp.

61 {
62 return getParameter(modelParameters_, p, qualifiers, mandatory, defaultValue);
63}
+ Here is the caller graph for this function:

Member Data Documentation

◆ model_

string model_
protected

Definition at line 152 of file enginefactory.hpp.

◆ engine_

string engine_
protected

Definition at line 153 of file enginefactory.hpp.

◆ tradeTypes_

set<string> tradeTypes_
protected

Definition at line 154 of file enginefactory.hpp.

◆ market_

QuantLib::ext::shared_ptr<Market> market_
protected

Definition at line 155 of file enginefactory.hpp.

◆ configurations_

map<MarketContext, string> configurations_
protected

Definition at line 156 of file enginefactory.hpp.

◆ modelParameters_

map<string, string> modelParameters_
protected

Definition at line 157 of file enginefactory.hpp.

◆ engineParameters_

map<string, string> engineParameters_
protected

Definition at line 158 of file enginefactory.hpp.

◆ globalParameters_

std::map<std::string, std::string> globalParameters_
protected

Definition at line 159 of file enginefactory.hpp.

◆ modelBuilders_

set<std::pair<string, QuantLib::ext::shared_ptr<QuantExt::ModelBuilder> > > modelBuilders_
protected

Definition at line 160 of file enginefactory.hpp.