Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
deltascenariofactory.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
24
25#include <ql/errors.hpp>
26
27namespace ore {
28namespace analytics {
29
30DeltaScenarioFactory::DeltaScenarioFactory(const QuantLib::ext::shared_ptr<ore::analytics::Scenario>& baseScenario,
31 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioFactory>& scenarioFactory)
32 : baseScenario_(baseScenario), scenarioFactory_(scenarioFactory) {
33 QL_REQUIRE(baseScenario_ != nullptr, "DeltaScenarioFactory: base scenario pointer must not be NULL");
34 QL_REQUIRE(scenarioFactory_ != nullptr, "DeltaScenarioFactory: scenario factory must not be NULL");
35}
36
37const QuantLib::ext::shared_ptr<ore::analytics::Scenario>
38DeltaScenarioFactory::buildScenario(QuantLib::Date asof, bool isAbsolute, const std::string& label,
39 QuantLib::Real numeraire) const {
40 QL_REQUIRE(asof == baseScenario_->asof(),
41 "unexpected asof date (" << asof << "), does not match base - " << baseScenario_->asof());
42 QuantLib::ext::shared_ptr<ore::analytics::Scenario> incremental =
43 scenarioFactory_->buildScenario(asof, isAbsolute, label, numeraire);
44 QL_REQUIRE((label == incremental->label()) || (label == ""), "DeltaScenarioFactory has not updated scenario label");
45 return QuantLib::ext::make_shared<DeltaScenario>(baseScenario_, incremental);
46}
47} // namespace sensitivity
48} // namespace ore
const QuantLib::ext::shared_ptr< ore::analytics::Scenario > buildScenario(QuantLib::Date asof, bool isAbsolute, const std::string &label="", QuantLib::Real numeraire=0.0) const override
returns a new scenario, using the base scenario as a starting point
DeltaScenarioFactory(const QuantLib::ext::shared_ptr< ore::analytics::Scenario > &baseScenario, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioFactory > &scenarioFactory=QuantLib::ext::make_shared< ore::analytics::SimpleScenarioFactory >(false))
Constructor.
QuantLib::ext::shared_ptr< ore::analytics::ScenarioFactory > scenarioFactory_
QuantLib::ext::shared_ptr< ore::analytics::Scenario > baseScenario_
Delta scenario class.
factory class for cloning a cached scenario
Simple scenario class.
Date asof(14, Jun, 2018)