Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
scenariogeneratorbuilder.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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
24
25#include <boost/algorithm/string.hpp>
26#include <boost/algorithm/string/case_conv.hpp>
27#include <boost/algorithm/string/trim.hpp>
28#include <boost/lexical_cast.hpp>
29#include <boost/tokenizer.hpp>
30
31#include <map>
32
33using namespace ore::data;
34using namespace std;
35
36using namespace QuantExt;
37
38namespace ore {
39namespace analytics {
40
41QuantLib::ext::shared_ptr<ScenarioGenerator>
42ScenarioGeneratorBuilder::build(QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel> model,
43 QuantLib::ext::shared_ptr<ScenarioFactory> scenarioFactory,
44 QuantLib::ext::shared_ptr<ScenarioSimMarketParameters> marketConfig, Date asof,
45 QuantLib::ext::shared_ptr<ore::data::Market> initMarket, const std::string& configuration,
46 const QuantLib::ext::shared_ptr<PathGeneratorFactory>& pf) {
47
48 LOG("ScenarioGeneratorBuilder::build() called");
49
50 QL_REQUIRE(initMarket != NULL, "ScenarioGeneratorBuilder: initMarket is null");
51
52 // enable cache
53 auto process = model->stateProcess();
54 if (auto tmp = QuantLib::ext::dynamic_pointer_cast<CrossAssetStateProcess>(process)) {
55 tmp->resetCache(data_->getGrid()->timeGrid().size() - 1);
56 }
57
58 auto pathGen = pf->build(data_->sequenceType(), process, data_->getGrid()->timeGrid(), data_->seed(),
59 data_->ordering(), data_->directionIntegers());
60
61 return QuantLib::ext::make_shared<CrossAssetModelScenarioGenerator>(model, pathGen, scenarioFactory, marketConfig, asof,
62 data_->getGrid(), initMarket, configuration);
63}
64} // namespace analytics
65} // namespace ore
QuantLib::ext::shared_ptr< ScenarioGeneratorData > data_
QuantLib::ext::shared_ptr< ScenarioGenerator > build(QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > model, QuantLib::ext::shared_ptr< ScenarioFactory > sf, QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > marketConfig, Date asof, QuantLib::ext::shared_ptr< ore::data::Market > initMarket, const std::string &configuration=ore::data::Market::defaultConfiguration, const QuantLib::ext::shared_ptr< PathGeneratorFactory > &pf=QuantLib::ext::make_shared< MultiPathGeneratorFactory >())
Build function.
#define LOG(text)
Build a scenariogenerator.
factory classes for simple scenarios
Date asof(14, Jun, 2018)