Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cptycalculator.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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/valuationcalculator.hpp
20 \brief The counterparty cube calculator interface
21 \ingroup simulation
22*/
23
24#pragma once
25
26#include <orea/cube/npvcube.hpp>
29
30namespace ore {
31namespace analytics {
32using QuantLib::Date;
33using QuantLib::Real;
34using QuantLib::Size;
35
36//! CounterpartyCalculator interface
38public:
40
41 virtual void calculate(
42 //! The counterparty name
43 const std::string& name,
44 //! Name index for writing to the cube
45 Size nameIndex,
46 //! The market
47 const QuantLib::ext::shared_ptr<SimMarket>& simMarket,
48 //! The cube for data on name level
49 QuantLib::ext::shared_ptr<NPVCube>& outputCube,
50 //! The date
51 const Date& date,
52 //! Date index
53 Size dateIndex,
54 //! Sample
55 Size sample,
56 //! isCloseOut
57 bool isCloseOut = false) = 0;
58
59 virtual void calculateT0(
60 //! The counterparty name
61 const std::string& name,
62 //! Name index for writing to the cube
63 Size nameIndex,
64 //! The market
65 const QuantLib::ext::shared_ptr<SimMarket>& simMarket,
66 //! The cube
67 QuantLib::ext::shared_ptr<NPVCube>& outputCube) = 0;
68};
69
70//! SurvivalProbabilityCalculator
71/*! Calculate the survival probability of a counterparty
72 * If the SurvivalProbabilityCalculator() call throws, we log an exception and write 1 to the cube
73 *
74 */
76public:
78 //! base ccy and index to write to
79 SurvivalProbabilityCalculator(const std::string& configuration, Size index = 0)
80 : configuration_(configuration), index_(index) {}
81
82 virtual void calculate(const std::string& name, Size nameIndex,
83 const QuantLib::ext::shared_ptr<SimMarket>& simMarket, QuantLib::ext::shared_ptr<NPVCube>& outputCube,
84 const Date& date, Size dateIndex, Size sample, bool isCloseOut = false) override;
85
86 virtual void calculateT0(const std::string& name, Size nameIndex,
87 const QuantLib::ext::shared_ptr<SimMarket>& simMarket, QuantLib::ext::shared_ptr<NPVCube>& outputCube) override;
88
89private:
90 Real survProb(const std::string& name,
91 const QuantLib::ext::shared_ptr<SimMarket>& simMarket,
92 const Date& date = Date());
93
94 std::string configuration_;
95 Size index_;
96};
97
98} // namespace analytics
99} // namespace ore
CounterpartyCalculator interface.
virtual void calculateT0(const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube)=0
virtual void calculate(const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube, const Date &date, Size dateIndex, Size sample, bool isCloseOut=false)=0
SurvivalProbabilityCalculator(const std::string &configuration, Size index=0)
base ccy and index to write to
Real survProb(const std::string &name, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, const Date &date=Date())
virtual void calculate(const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube, const Date &date, Size dateIndex, Size sample, bool isCloseOut=false) override
virtual void calculateT0(const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube) override
The base NPV cube class.
A Market class that can be Simulated.