21#include <ql/errors.hpp>
29 const QuantLib::ext::shared_ptr<ore::analytics::Scenario>& incrementalScenario)
30 : baseScenario_(baseScenario), delta_(incrementalScenario) {
32 baseScenario->isAbsolute() == incrementalScenario->isAbsolute(),
33 "DeltaScenario(): base and incremental scenario must be both absolute or both difference, got isAbsolute = "
34 << std::boolalpha << baseScenario->isAbsolute() <<
", " << incrementalScenario->isAbsolute());
38 QL_REQUIRE(
baseScenario_->has(key),
"base scenario must also possess key");
53 QuantLib::ext::shared_ptr<Scenario> newDelta =
delta_->clone();
54 return QuantLib::ext::make_shared<DeltaScenario>(
baseScenario_, newDelta);
58 Real deltaNum =
delta_->getNumeraire();
65 if (
auto d = QuantLib::ext::dynamic_pointer_cast<DeltaScenario>(s)) {
67 (
delta_.get() == d->delta_.get() ||
delta_->isCloseEnough(s));
QuantLib::ext::shared_ptr< Scenario > baseScenario_
QuantLib::ext::shared_ptr< Scenario > clone() const override
clones a scenario and returns a pointer to the new object
void add(const ore::analytics::RiskFactorKey &key, Real value) override
Add an element to the scenario.
DeltaScenario()
Constructor.
QuantLib::ext::shared_ptr< Scenario > delta_
bool isCloseEnough(const QuantLib::ext::shared_ptr< Scenario > &s) const override
checks for equality up to numerical differences
Real get(const ore::analytics::RiskFactorKey &key) const override
Get an element from the scenario.
Real getNumeraire() const override
Get Numeraire ratio n = N(t) / N(0) so that Price(0) = N(0) * E [Price(t) / N(t) ].
Data types stored in the scenario class.
virtual bool isCloseEnough(const QuantLib::ext::shared_ptr< Scenario > &s) const
checks for equality up to numerical differences
SafeStack< ValueType > value