Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
varcalculator.hpp
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
19/*! \file engine/varcalculator.hpp
20 \brief Base class for a var calculation
21 \ingroup engine
22*/
23
24#pragma once
25
28
29namespace ore {
30namespace analytics {
31
32//! VaR Calculator
34public:
36 virtual ~VarCalculator() {}
37
38 virtual QuantLib::Real var(QuantLib::Real confidence, const bool isCall = true,
39 const std::set<std::pair<std::string, QuantLib::Size>>& tradeIds = {}) = 0;
40};
41
43public:
44 VarReport(const std::string& baseCurrency,
45 const QuantLib::ext::shared_ptr<Portfolio> & portfolio,
46 const std::string& portfolioFilter,
47 const vector<Real>& p, boost::optional<ore::data::TimePeriod> period,
48 const QuantLib::ext::shared_ptr<HistoricalScenarioGenerator>& hisScenGen = nullptr,
49 std::unique_ptr<SensiRunArgs> sensiArgs = nullptr, std::unique_ptr<FullRevalArgs> fullRevalArgs = nullptr,
50 const bool breakdown = false);
51
52 void createReports(const QuantLib::ext::shared_ptr<MarketRiskReport::Reports>& reports) override;
53
54 const std::vector<Real>& p() const { return p_; }
55
56protected:
57 QuantLib::ext::shared_ptr<VarCalculator> varCalculator_;
58
59 virtual void createVarCalculator() = 0;
60 void writeReports(const QuantLib::ext::shared_ptr<MarketRiskReport::Reports>& report,
61 const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup,
62 const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup) override;
63
64 std::vector<ore::data::TimePeriod> timePeriods() override { return {period_.get()}; }
65
66private:
67 std::vector<Real> p_;
68};
69
70} // namespace analytics
71} // namespace ore
boost::optional< ore::data::TimePeriod > period_
virtual QuantLib::Real var(QuantLib::Real confidence, const bool isCall=true, const std::set< std::pair< std::string, QuantLib::Size > > &tradeIds={})=0
QuantLib::ext::shared_ptr< VarCalculator > varCalculator_
std::vector< ore::data::TimePeriod > timePeriods() override
void createReports(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) override
std::vector< Real > p_
const std::vector< Real > & p() const
void writeReports(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &report, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) override
virtual void createVarCalculator()=0
Base class for a market risk report.