34#include <ql/pricingengine.hpp>
36#include <ql/shared_ptr.hpp>
54class ReferenceDataManager;
131 void init(
const QuantLib::ext::shared_ptr<Market> market,
const map<MarketContext, string>& configurations,
132 const map<string, string>& modelParameters,
const map<string, string>& engineParameters,
133 const std::map<std::string, std::string>& globalParameters = {}) {
145 std::string
engineParameter(
const std::string& p,
const std::vector<std::string>& qualifiers = {},
146 const bool mandatory =
true,
const std::string& defaultValue =
"")
const;
148 std::string
modelParameter(
const std::string& p,
const std::vector<std::string>& qualifiers = {},
149 const bool mandatory =
true,
const std::string& defaultValue =
"")
const;
160 set<std::pair<string, QuantLib::ext::shared_ptr<QuantExt::ModelBuilder>>>
modelBuilders_;
169 const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) = 0;
174class EngineBuilderFactory :
public QuantLib::Singleton<EngineBuilderFactory, std::integral_constant<bool, true>> {
176 std::vector<std::function<QuantLib::ext::shared_ptr<EngineBuilder>(
const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel>& cam,
177 const std::vector<Date>& grid)>>
179 std::vector<std::function<QuantLib::ext::shared_ptr<EngineBuilder>(
const QuantLib::ext::shared_ptr<ore::data::ModelCG>& model,
180 const std::vector<Date>& grid)>>
186 void addEngineBuilder(
const std::function<QuantLib::ext::shared_ptr<EngineBuilder>()>& builder,
187 const bool allowOverwrite =
false);
189 const std::function<QuantLib::ext::shared_ptr<EngineBuilder>(
const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel>& cam,
190 const std::vector<Date>& grid)>& builder,
191 const bool allowOverwrite =
false);
193 const std::function<QuantLib::ext::shared_ptr<EngineBuilder>(
const QuantLib::ext::shared_ptr<ore::data::ModelCG>& model,
194 const std::vector<Date>& grid)>& builder,
195 const bool allowOverwrite =
false);
196 void addLegBuilder(
const std::function<QuantLib::ext::shared_ptr<LegBuilder>()>& builder,
197 const bool allowOverwrite =
false);
200 std::vector<QuantLib::ext::shared_ptr<EngineBuilder>>
202 const std::vector<Date>& grid)
const;
203 std::vector<QuantLib::ext::shared_ptr<EngineBuilder>>
205 const std::vector<Date>& grid)
const;
228 const QuantLib::ext::shared_ptr<EngineData>&
data,
230 const QuantLib::ext::shared_ptr<Market>&
market,
232 const map<MarketContext, string>&
configurations = std::map<MarketContext, string>(),
234 const QuantLib::ext::shared_ptr<ReferenceDataManager>&
referenceData =
nullptr,
238 const std::vector<QuantLib::ext::shared_ptr<EngineBuilder>> extraEngineBuilders = {},
240 const bool allowOverwrite =
false);
243 const QuantLib::ext::shared_ptr<Market>&
market()
const {
return market_; };
257 void registerBuilder(
const QuantLib::ext::shared_ptr<EngineBuilder>&
builder,
const bool allowOverwrite =
false);
269 QuantLib::ext::shared_ptr<EngineBuilder>
builder(
const string& tradeType);
275 QuantLib::ext::shared_ptr<LegBuilder>
legBuilder(
const string& legType);
280 void addExtraBuilders(
const std::vector<QuantLib::ext::shared_ptr<EngineBuilder>> extraEngineBuilders,
281 const std::vector<QuantLib::ext::shared_ptr<LegBuilder>> extraLegBuilders,
282 const bool allowOverwrite =
false);
291 set<std::pair<string, QuantLib::ext::shared_ptr<QuantExt::ModelBuilder>>>
modelBuilders()
const;
297 map<tuple<string, string, set<string>>, QuantLib::ext::shared_ptr<EngineBuilder>>
builders_;
310 const string& configuration,
const QuantLib::Date& openEndDateReplacement = Null<Date>(),
311 const bool useXbsCurves =
false)
const = 0;
Delegating Engine Builder.
virtual QuantLib::ext::shared_ptr< ore::data::Trade > build(const ore::data::Trade *, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory)=0
virtual std::string effectiveTradeType() const =0
Engine/ Leg Builder Factory - notice that both engine and leg builders are allowed to maintain a stat...
std::vector< std::function< QuantLib::ext::shared_ptr< LegBuilder >()> > legBuilderBuilders_
void addEngineBuilder(const std::function< QuantLib::ext::shared_ptr< EngineBuilder >()> &builder, const bool allowOverwrite=false)
std::vector< QuantLib::ext::shared_ptr< EngineBuilder > > generateAmcEngineBuilders(const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &cam, const std::vector< Date > &grid) const
void addAmcEngineBuilder(const std::function< QuantLib::ext::shared_ptr< EngineBuilder >(const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &cam, const std::vector< Date > &grid)> &builder, const bool allowOverwrite=false)
std::vector< QuantLib::ext::shared_ptr< EngineBuilder > > generateEngineBuilders() const
std::vector< QuantLib::ext::shared_ptr< LegBuilder > > generateLegBuilders() const
void addAmcCgEngineBuilder(const std::function< QuantLib::ext::shared_ptr< EngineBuilder >(const QuantLib::ext::shared_ptr< ore::data::ModelCG > &model, const std::vector< Date > &grid)> &builder, const bool allowOverwrite=false)
std::vector< std::function< QuantLib::ext::shared_ptr< EngineBuilder >()> > engineBuilderBuilders_
std::vector< std::function< QuantLib::ext::shared_ptr< EngineBuilder >(const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &cam, const std::vector< Date > &grid)> > amcEngineBuilderBuilders_
std::vector< QuantLib::ext::shared_ptr< EngineBuilder > > generateAmcCgEngineBuilders(const QuantLib::ext::shared_ptr< ore::data::ModelCG > &model, const std::vector< Date > &grid) const
boost::shared_mutex mutex_
std::vector< std::function< QuantLib::ext::shared_ptr< EngineBuilder >(const QuantLib::ext::shared_ptr< ore::data::ModelCG > &model, const std::vector< Date > &grid)> > amcCgEngineBuilderBuilders_
void addLegBuilder(const std::function< QuantLib::ext::shared_ptr< LegBuilder >()> &builder, const bool allowOverwrite=false)
Base PricingEngine Builder class for a specific model and engine.
QuantLib::ext::shared_ptr< Market > market_
virtual ~EngineBuilder()
Virtual destructor.
const string & engine() const
Return the engine name.
const set< string > & tradeTypes() const
Return the possible trade types.
map< string, string > engineParameters_
const string & model() const
Return the model name.
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.
const set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > & modelBuilders() const
return model builders
std::string modelParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
virtual void reset()
reset the builder (e.g. clear cache)
map< MarketContext, string > configurations_
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
EngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes)
set< string > tradeTypes_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > modelBuilders_
std::map< std::string, std::string > globalParameters_
map< string, string > modelParameters_
Pricing Engine Factory class.
const QuantLib::ext::shared_ptr< Market > & market() const
Return the market used by this EngineFactory.
QuantLib::ext::shared_ptr< Market > market_
const IborFallbackConfig & iborFallbackConfig() const
Return the ibor fallback config.
const map< MarketContext, string > & configurations() const
Return the market configurations used by this EngineFactory.
QuantLib::ext::shared_ptr< EngineBuilder > builder(const string &tradeType)
Get a builder by trade type.
map< string, QuantLib::ext::shared_ptr< LegBuilder > > legBuilders_
QuantLib::ext::shared_ptr< LegBuilder > legBuilder(const string &legType)
Get a leg builder by leg type.
QuantLib::ext::shared_ptr< EngineData > engineData_
set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > modelBuilders() const
return model builders
void addDefaultBuilders()
Add a set of default engine and leg builders.
map< MarketContext, string > configurations_
const QuantLib::ext::shared_ptr< EngineData > engineData() const
Return the EngineData parameters.
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
void clear()
Clear all builders.
IborFallbackConfig iborFallbackConfig_
QuantLib::ext::shared_ptr< ReferenceDataManager > referenceData_
const QuantLib::ext::shared_ptr< ReferenceDataManager > & referenceData() const
Return the reference data used by this EngineFactory.
void addExtraBuilders(const std::vector< QuantLib::ext::shared_ptr< EngineBuilder > > extraEngineBuilders, const std::vector< QuantLib::ext::shared_ptr< LegBuilder > > extraLegBuilders, const bool allowOverwrite=false)
Add a set of default engine and leg builders, overwrite existing builders with same key if specified.
map< tuple< string, string, set< string > >, QuantLib::ext::shared_ptr< EngineBuilder > > builders_
void registerBuilder(const QuantLib::ext::shared_ptr< EngineBuilder > &builder, const bool allowOverwrite=false)
Register a builder with the factory.
void registerLegBuilder(const QuantLib::ext::shared_ptr< LegBuilder > &legBuilder, const bool allowOverwrite=false)
Register a leg builder with the factory.
static IborFallbackConfig defaultConfig()
virtual Leg buildLeg(const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &, RequiredFixings &requiredFixings, const string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const =0
const string & legType() const
LegBuilder(const string &legType)
Serializable object holding leg data.
static const string defaultConfiguration
Default configuration label.
A class to hold pricing engine parameters.
ibor fallback configuration
leg data model and serialization
interface for model against which a script can be run
Serializable Credit Default Swap.