Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
sensitivitycubestream.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 orea/engine/sensitivitycubestream.hpp
20 \brief Class for streaming SensitivityRecords from a SensitivityCube
21 */
22
23#pragma once
24
27
28#include <map>
29#include <set>
30#include <string>
31
32namespace ore {
33namespace analytics {
34
35/*! Class for streaming SensitivityRecords from a SensitivityCube
36 */
38public:
39 /*! Constructor providing the sensitivity \p cube and currency of the sensitivities */
40 SensitivityCubeStream(const QuantLib::ext::shared_ptr<SensitivityCube>& cube, const std::string& currency);
41 /*! Constructor providing the sensitivity \p cubes and currency of the sensitivities */
42 SensitivityCubeStream(const std::vector<QuantLib::ext::shared_ptr<SensitivityCube>>& cubes, const std::string& currency);
43
44 /*! Returns the next SensitivityRecord in the stream
45
46 \warning the cube must not change during successive calls to next()!
47 */
48 SensitivityRecord next() override;
49
50 //! Resets the stream so that SensitivityRecord objects can be streamed again
51 void reset() override;
52
53private:
54 void updateForNewTrade();
55
56 //! Handle on the SensitivityCubes
57 std::vector<QuantLib::ext::shared_ptr<SensitivityCube>> cubes_;
58 //! Currency of the sensitivities in the SensitivityCubes
59 std::string currency_;
60
61 //! Current cube index in vector
63
64 //! Current delta risk factor keys to process and iterators
65 std::set<RiskFactorKey> currentDeltaKeys_;
66 std::set<std::pair<RiskFactorKey,RiskFactorKey>> currentCrossGammaKeys_;
67
68 std::set<RiskFactorKey>::const_iterator currentDeltaKey_;
69 std::set<std::pair<RiskFactorKey,RiskFactorKey>>::const_iterator currentCrossGammaKey_;
70
71 //! Current trade iterator
72 std::map<std::string, QuantLib::Size>::const_iterator tradeIdx_;
73
74 //! Can only compute gamma if the up and down risk factors align
76};
77
78} // namespace analytics
79} // namespace ore
std::string currency_
Currency of the sensitivities in the SensitivityCubes.
std::set< std::pair< RiskFactorKey, RiskFactorKey > > currentCrossGammaKeys_
std::map< std::string, QuantLib::Size >::const_iterator tradeIdx_
Current trade iterator.
std::set< RiskFactorKey >::const_iterator currentDeltaKey_
std::vector< QuantLib::ext::shared_ptr< SensitivityCube > > cubes_
Handle on the SensitivityCubes.
bool canComputeGamma_
Can only compute gamma if the up and down risk factors align.
std::set< std::pair< RiskFactorKey, RiskFactorKey > >::const_iterator currentCrossGammaKey_
std::set< RiskFactorKey > currentDeltaKeys_
Current delta risk factor keys to process and iterators.
Size currentCubeIdx_
Current cube index in vector.
void reset() override
Resets the stream so that SensitivityRecord objects can be streamed again.
Base Class for streaming SensitivityRecords.
holds a grid of NPVs for a list of trades under various scenarios
Base class for sensitivity record streamer.