Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
clonescenariofactory.cpp
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
21#include <ql/errors.hpp>
22
23namespace ore {
24namespace analytics {
25
26CloneScenarioFactory::CloneScenarioFactory(const QuantLib::ext::shared_ptr<Scenario>& baseScenario)
27 : baseScenario_(baseScenario) {
28 QL_REQUIRE(baseScenario_ != NULL, "base scenario pointer must not be NULL");
29}
30
31const QuantLib::ext::shared_ptr<Scenario>
32CloneScenarioFactory::buildScenario(Date asof, bool isAbsolute, const std::string& label, Real numeraire) const {
33 QuantLib::ext::shared_ptr<Scenario> newScen = baseScenario_->clone();
34 QL_REQUIRE(asof == newScen->asof(),
35 "unexpected asof date (" << asof << "), does not match base - " << baseScenario_->asof());
36 newScen->label(label);
37 QL_REQUIRE((label == newScen->label()) || (label == ""), "CloneScenarioFactory has not updated scenario label");
38 if (numeraire != 0.0)
39 newScen->setNumeraire(numeraire);
40 newScen->setAbsolute(isAbsolute);
41 return newScen;
42}
43} // namespace analytics
44} // namespace ore
CloneScenarioFactory(const QuantLib::ext::shared_ptr< Scenario > &baseScenario)
Constructor.
QuantLib::ext::shared_ptr< Scenario > baseScenario_
const QuantLib::ext::shared_ptr< Scenario > buildScenario(Date asof, bool isAbsolute, const std::string &label="", Real numeraire=0.0) const override
returns a new scenario, using the base scenario as a starting point
factory class for cloning a cached scenario
Date asof(14, Jun, 2018)