Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
amcvaluationengine.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file engine/amcvaluationengine.hpp
20 \brief valuation engine for amc
21 \ingroup engine
22*/
23
24#pragma once
25
26#include <orea/cube/npvcube.hpp>
28
33
35
36namespace ore {
37namespace analytics {
38
39using std::string;
40
41//! AMC Valuation Engine
43public:
44 //! Constructor for single-threaded runs
45 AMCValuationEngine(const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel>& model,
46 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioGeneratorData>& scenarioGeneratorData,
47 const QuantLib::ext::shared_ptr<ore::data::Market>& market, const std::vector<string>& aggDataIndices,
48 const std::vector<string>& aggDataCurrencies, const Size aggDataNumberCreditStates);
49
50 //! Constructor for multi threaded runs
52 const QuantLib::Size nThreads, const QuantLib::Date& today, const QuantLib::Size nSamples,
53 const QuantLib::ext::shared_ptr<ore::data::Loader>& loader,
54 const QuantLib::ext::shared_ptr<ScenarioGeneratorData>& scenarioGeneratorData,
55 const std::vector<string>& aggDataIndices, const std::vector<string>& aggDataCurrencies,
56 const Size aggDataNumberCreditStates, const QuantLib::ext::shared_ptr<CrossAssetModelData>& crossAssetModelData,
57 const QuantLib::ext::shared_ptr<ore::data::EngineData>& engineData,
58 const QuantLib::ext::shared_ptr<ore::data::CurveConfigurations>& curveConfigs,
59 const QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>& todaysMarketParams,
60 const std::string& configurationLgmCalibration, const std::string& configurationFxCalibration,
61 const std::string& configurationEqCalibration, const std::string& configurationInfCalibration,
62 const std::string& configurationCrCalibration, const std::string& configurationFinalModel,
63 const QuantLib::ext::shared_ptr<ore::data::ReferenceDataManager>& referenceData = nullptr,
65 const bool handlePseudoCurrenciesTodaysMarket = true,
66 const std::function<QuantLib::ext::shared_ptr<ore::analytics::NPVCube>(
67 const QuantLib::Date&, const std::set<std::string>&, const std::vector<QuantLib::Date>&,
68 const QuantLib::Size)>& cubeFactory = {},
69 const QuantLib::ext::shared_ptr<Scenario>& offSetScenario = nullptr,
70 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters>& simMarketParams = nullptr);
71
72 //! build cube in single threaded run
73 void buildCube(const QuantLib::ext::shared_ptr<ore::data::Portfolio>& portfolio,
74 QuantLib::ext::shared_ptr<ore::analytics::NPVCube>& outputCube);
75
76 //! build cube in multi threaded run
77 void buildCube(const QuantLib::ext::shared_ptr<ore::data::Portfolio>& portfolio);
78
79 // result output cubes for multi threaded runs (mini-cubes, one per thread)
80 std::vector<QuantLib::ext::shared_ptr<ore::analytics::NPVCube>> outputCubes() const { return miniCubes_; }
81
82 //! Set aggregation data
83 QuantLib::ext::shared_ptr<ore::analytics::AggregationScenarioData>& aggregationScenarioData() { return asd_; }
84
85 //! Get aggregation data
86 const QuantLib::ext::shared_ptr<ore::analytics::AggregationScenarioData>& aggregationScenarioData() const { return asd_; }
87
88private:
89 // set / get via additional methods
90 QuantLib::ext::shared_ptr<ore::analytics::AggregationScenarioData> asd_;
91
92 // running in single or multi threaded mode?
93 bool useMultithreading_ = false;
94
95 // shared inputs
96 const std::vector<string> aggDataIndices_, aggDataCurrencies_;
98 QuantLib::ext::shared_ptr<ScenarioGeneratorData> scenarioGeneratorData_;
99
100 // inputs for single-threaded run
101 const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel> model_;
102 const QuantLib::ext::shared_ptr<ore::data::Market> market_;
103
104 // inputs for muulti-threaded run
105 QuantLib::Size nThreads_;
106 QuantLib::Date today_;
107 QuantLib::Size nSamples_;
108 QuantLib::ext::shared_ptr<ore::data::Loader> loader_;
109 QuantLib::ext::shared_ptr<CrossAssetModelData> crossAssetModelData_;
110 QuantLib::ext::shared_ptr<ore::data::EngineData> engineData_;
111 QuantLib::ext::shared_ptr<ore::data::CurveConfigurations> curveConfigs_;
112 QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters> todaysMarketParams_;
119 QuantLib::ext::shared_ptr<ore::data::ReferenceDataManager> referenceData_;
122 std::function<QuantLib::ext::shared_ptr<ore::analytics::NPVCube>(const QuantLib::Date&, const std::set<std::string>&,
123 const std::vector<QuantLib::Date>&, const QuantLib::Size)>
125 QuantLib::ext::shared_ptr<Scenario> offsetScenario_;
126 QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> simMarketParams_;
127 // result cubes for multi-threaded run
128 std::vector<QuantLib::ext::shared_ptr<ore::analytics::NPVCube>> miniCubes_;
129};
130
131} // namespace analytics
132} // namespace ore
QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > curveConfigs_
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams_
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > model_
const QuantLib::ext::shared_ptr< ore::analytics::AggregationScenarioData > & aggregationScenarioData() const
Get aggregation data.
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams_
std::vector< QuantLib::ext::shared_ptr< ore::analytics::NPVCube > > miniCubes_
std::vector< QuantLib::ext::shared_ptr< ore::analytics::NPVCube > > outputCubes() const
void buildCube(const QuantLib::ext::shared_ptr< ore::data::Portfolio > &portfolio, QuantLib::ext::shared_ptr< ore::analytics::NPVCube > &outputCube)
build cube in single threaded run
QuantLib::ext::shared_ptr< ore::analytics::AggregationScenarioData > asd_
QuantLib::ext::shared_ptr< ScenarioGeneratorData > scenarioGeneratorData_
const QuantLib::ext::shared_ptr< ore::data::Market > market_
QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > referenceData_
QuantLib::ext::shared_ptr< Scenario > offsetScenario_
ore::data::IborFallbackConfig iborFallbackConfig_
AMCValuationEngine(const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &model, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioGeneratorData > &scenarioGeneratorData, const QuantLib::ext::shared_ptr< ore::data::Market > &market, const std::vector< string > &aggDataIndices, const std::vector< string > &aggDataCurrencies, const Size aggDataNumberCreditStates)
Constructor for single-threaded runs.
QuantLib::ext::shared_ptr< CrossAssetModelData > crossAssetModelData_
QuantLib::ext::shared_ptr< ore::analytics::AggregationScenarioData > & aggregationScenarioData()
Set aggregation data.
const std::vector< string > aggDataCurrencies_
QuantLib::ext::shared_ptr< ore::data::Loader > loader_
const std::vector< string > aggDataIndices_
std::function< QuantLib::ext::shared_ptr< ore::analytics::NPVCube >(const QuantLib::Date &, const std::set< std::string > &, const std::vector< QuantLib::Date > &, const QuantLib::Size)> cubeFactory_
QuantLib::ext::shared_ptr< ore::data::EngineData > engineData_
static IborFallbackConfig defaultConfig()
The base NPV cube class.
Scenario generator configuration.