Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
historicalsimulationvar.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 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
19/*! \file engine/historicalsimulationvar.hpp
20 \brief Perform historical simulation var calculation for a given portfolio
21 \ingroup engine
22*/
23
24#pragma once
25
33
36
38
39#include <ql/math/array.hpp>
40#include <ql/math/matrix.hpp>
41
42#include <map>
43#include <set>
44
45namespace ore {
46namespace analytics {
47using QuantLib::Array;
48using QuantLib::Matrix;
49
51public:
52 HistoricalSimulationVarCalculator(const std::vector<QuantLib::Real>& pnls) : pnls_(pnls) {}
53
54 QuantLib::Real var(QuantLib::Real confidence, const bool isCall = true,
55 const std::set<std::pair<std::string, QuantLib::Size>>& tradeIds = {}) override;
56
57private:
58 const std::vector<QuantLib::Real>& pnls_;
59};
60
61//! HistoricalSimulation VaR Calculator
62/*! This class takes sensitivity data and a covariance matrix as an input and computes a Historical Simulation value at risk. The
63 * output can be broken down by portfolios, risk classes (IR, FX, EQ, ...) and risk types (delta-gamma, vega, ...). */
65public:
67
68 HistoricalSimulationVarReport(const std::string& baseCurrency,
69 const QuantLib::ext::shared_ptr<Portfolio>& portfolio,
70 const std::string& portfolioFilter,
71 const vector<Real>& p, boost::optional<ore::data::TimePeriod> period,
72 const QuantLib::ext::shared_ptr<HistoricalScenarioGenerator>& hisScenGen = nullptr,
73 std::unique_ptr<FullRevalArgs> fullRevalArgs = nullptr, const bool breakdown = false);
74
75protected:
76 void createVarCalculator() override;
77 void handleFullRevalResults(const QuantLib::ext::shared_ptr<MarketRiskReport::Reports>& reports,
78 const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup,
79 const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup) override;
80
81private:
82 std::vector<QuantLib::Real> pnls_;
83};
84
85} // namespace analytics
86} // namespace ore
QuantLib::Real var(QuantLib::Real confidence, const bool isCall=true, const std::set< std::pair< std::string, QuantLib::Size > > &tradeIds={}) override
HistoricalSimulationVarCalculator(const std::vector< QuantLib::Real > &pnls)
void handleFullRevalResults(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) override
const std::vector< Real > & p() const
Class for generating portfolio P&Ls based on historical scenarios.
scenario generator that builds from historical shifts
A class to hold Scenario parameters for scenarioSimMarket.
Class for aggregating SensitivityRecords.
A class to hold the parametrisation for building sensitivity scenarios.
Base class for sensitivity record streamer.
Base class for a var calculation.