Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ZeroToParShiftConverter Class Reference

#include <orea/engine/zerotoparshift.hpp>

+ Collaboration diagram for ZeroToParShiftConverter:

Public Member Functions

 ZeroToParShiftConverter (const QuantLib::Date &asof, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > &simMarketParams, const ore::analytics::SensitivityScenarioData &sensitivityData, const std::set< ore::analytics::RiskFactorKey::KeyType > &typesDisabled, const std::set< ore::analytics::RiskFactorKey::KeyType > &parTypes, const std::set< ore::analytics::RiskFactorKey > &relevantRiskFactors, const bool continueOnError, const std::string &marketConfiguration, const QuantLib::ext::shared_ptr< ScenarioSimMarket > &simMarket)
 
 ZeroToParShiftConverter (const ParSensitivityInstrumentBuilder::Instruments &instruments_, const QuantLib::ext::shared_ptr< ScenarioSimMarket > &simMarket)
 
std::unordered_map< RiskFactorKey, double > parShifts (QuantLib::ext::shared_ptr< Scenario > scenario) const
 

Private Member Functions

std::unordered_map< RiskFactorKey, double > parRates () const
 

Private Attributes

ParSensitivityInstrumentBuilder::Instruments instruments_
 
ext::shared_ptr< ScenarioSimMarketsimMarket_
 
std::unordered_map< RiskFactorKey, double > baseValues_
 

Detailed Description

Definition at line 30 of file zerotoparshift.hpp.

Constructor & Destructor Documentation

◆ ZeroToParShiftConverter() [1/2]

ZeroToParShiftConverter ( const QuantLib::Date &  asof,
const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > &  simMarketParams,
const ore::analytics::SensitivityScenarioData sensitivityData,
const std::set< ore::analytics::RiskFactorKey::KeyType > &  typesDisabled,
const std::set< ore::analytics::RiskFactorKey::KeyType > &  parTypes,
const std::set< ore::analytics::RiskFactorKey > &  relevantRiskFactors,
const bool  continueOnError,
const std::string &  marketConfiguration,
const QuantLib::ext::shared_ptr< ScenarioSimMarket > &  simMarket 
)

Definition at line 33 of file zerotoparshift.cpp.

41 : simMarket_(simMarket) {
42 ParSensitivityInstrumentBuilder().createParInstruments(instruments_, asof, simMarketParams, sensitivityData,
43 typesDisabled, parTypes, relevantRiskFactors,
44 continueOnError, marketConfiguration, simMarket);
45};
ext::shared_ptr< ScenarioSimMarket > simMarket_
ParSensitivityInstrumentBuilder::Instruments instruments_
Date asof(14, Jun, 2018)
+ Here is the call graph for this function:

◆ ZeroToParShiftConverter() [2/2]

ZeroToParShiftConverter ( const ParSensitivityInstrumentBuilder::Instruments instruments_,
const QuantLib::ext::shared_ptr< ScenarioSimMarket > &  simMarket 
)

Definition at line 47 of file zerotoparshift.cpp.

49 : instruments_(instruments_), simMarket_(simMarket) {
50 QL_REQUIRE(simMarket_ != nullptr, "ZeroToParShiftConverter: need a simmarket");
51 simMarket_->reset();
52
53 if (ObservationMode::instance().mode() == ObservationMode::Mode::Disable) {
54 for (auto it : instruments_.parHelpers_)
55 it.second->deepUpdate();
56 for (auto it : instruments_.parCaps_)
57 it.second->deepUpdate();
58 for (auto it : instruments_.parYoYCaps_)
59 it.second->deepUpdate();
60 }
62};
std::unordered_map< RiskFactorKey, double > parRates() const
std::unordered_map< RiskFactorKey, double > baseValues_
std::map< ore::analytics::RiskFactorKey, QuantLib::ext::shared_ptr< QuantLib::Instrument > > parHelpers_
par helpers (all except cap/floors)
std::map< ore::analytics::RiskFactorKey, QuantLib::ext::shared_ptr< QuantLib::CapFloor > > parCaps_
par helpers: IR cap / floors
std::map< ore::analytics::RiskFactorKey, QuantLib::ext::shared_ptr< QuantLib::YoYInflationCapFloor > > parYoYCaps_
+ Here is the call graph for this function:

Member Function Documentation

◆ parShifts()

std::unordered_map< RiskFactorKey, double > parShifts ( QuantLib::ext::shared_ptr< Scenario scenario) const

Definition at line 77 of file zerotoparshift.cpp.

77 {
78 QL_REQUIRE(simMarket_ != nullptr, "ZeroToParShiftConverter: need a simmarket");
79 SimMarketReseter market(simMarket_);
80
81 market.market()->applyScenario(scenario);
82
83 if (ObservationMode::instance().mode() == ObservationMode::Mode::Disable) {
84 for (auto it : instruments_.parHelpers_)
85 it.second->deepUpdate();
86 for (auto it : instruments_.parCaps_)
87 it.second->deepUpdate();
88 for (auto it : instruments_.parYoYCaps_)
89 it.second->deepUpdate();
90 }
91
92 auto scenarioValues = parRates();
93 // Check if both maps have same keys;
94 QL_REQUIRE(baseValues_.size() == scenarioValues.size(),
95 "ZeroToParShiftConverter: internal error, both maps should have the same entries");
96 bool sameKeys = std::equal(baseValues_.begin(), baseValues_.end(), scenarioValues.begin(),
97 [](const auto& a, const auto& b) { return a.first == b.first; });
98 QL_REQUIRE(sameKeys, "ZeroToParShiftConverter: internal error, both maps should have the same entries");
99 std::unordered_map<RiskFactorKey, double> shifts;
100 for (const auto& [key, amount] : baseValues_) {
101 shifts[key] = scenarioValues[key] - amount;
102 }
103 return shifts;
104}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parRates()

std::unordered_map< RiskFactorKey, double > parRates ( ) const
private

Definition at line 106 of file zerotoparshift.cpp.

106 {
107 std::unordered_map<RiskFactorKey, double> results;
108 for (const auto& [key, parInstrument] : instruments_.parHelpers_) {
109 results[key] = impliedQuote(parInstrument);
110 }
111 for (const auto& [key, cap] : instruments_.parCaps_) {
112 results[key] = impliedVolatility(key, instruments_);
113 }
114 for (const auto& [key, cap] : instruments_.parYoYCaps_) {
115 results[key] = impliedVolatility(key, instruments_);
116 }
117 return results;
118}
Volatility impliedVolatility(const QuantLib::CapFloor &cap, Real targetValue, const Handle< YieldTermStructure > &d, Volatility guess, VolatilityType type, Real displacement)
Real impliedQuote(const QuantLib::ext::shared_ptr< Instrument > &i)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ instruments_

Definition at line 49 of file zerotoparshift.hpp.

◆ simMarket_

ext::shared_ptr<ScenarioSimMarket> simMarket_
private

Definition at line 50 of file zerotoparshift.hpp.

◆ baseValues_

std::unordered_map<RiskFactorKey, double> baseValues_
private

Definition at line 51 of file zerotoparshift.hpp.