Logo
Reference manual - version ored_version
EngineBuilder Class Reference

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

#include <ored/portfolio/enginefactory.hpp>

Inheritance diagram for EngineBuilder:

Public Member Functions

 EngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
virtual ~EngineBuilder ()
 Virtual destructor.
const stringmodel () const
 Return the model name.
const stringengine () const
 Return the engine name.
const set< string > & tradeTypes () const
 Return the possible trade types.
const stringconfiguration (const MarketContext &key) const
 Return a configuration (or the default one if key not found).
virtual void reset ()
 reset the builder (e.g. clear cache)
void init (EngineFactory *const engineFactory, 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.
virtual std::string engineParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
virtual std::string modelParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const std::map< std::string, std::string > globalParameters () const
EngineFactoryengineFactory () const
 return model builders

Protected Member Functions

std::string getParameter (const std::map< std::string, std::string > &m, const std::string &p, const std::vector< std::string > &qs, const bool mandatory, const std::string &defaultValue) const

Protected Attributes

string model_
string engine_
set< stringtradeTypes_
EngineFactoryengineFactory_
QuantLib::ext::shared_ptr< Marketmarket_
map< MarketContext, stringconfigurations_
map< string, stringmodelParameters_
map< string, stringengineParameters_
std::map< std::string, std::string > globalParameters_

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 (...);

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.

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

Member Function Documentation

◆ reset()

◆ init()

void init ( EngineFactory *const engineFactory,
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.

◆ engineParameter()

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

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

Reimplemented in ScriptedTradeEngineBuilder.

◆ modelParameter()

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

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

Reimplemented in ScriptedTradeEngineBuilder.

◆ globalParameters()

const std::map< std::string, std::string > globalParameters ( ) const

return global parameters