Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
historicalscenariofilereader.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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/scenario/historicalscenariofilereader.hpp
20 \brief Class for reading historical scenarios from file
21 \ingroup scenario
22*/
23
24#pragma once
25
27
30#include <string>
31#include <vector>
32
33namespace ore {
34namespace analytics {
35
36//! Class for reading historical scenarios from a csv file
38public:
39 /*! Constructor where \p filename gives the path to the file from which to
40 read the scenarios and \p scenarioFactory is a factory for building Scenarios
41 */
42 HistoricalScenarioFileReader(const std::string& fileName,
43 const QuantLib::ext::shared_ptr<ScenarioFactory>& scenarioFactory);
44 //! Destructor
46 //! Return true if there is another Scenario to read and move to it
47 bool next() override;
48 //! Return the current scenario's date if reader is still valid and `Null<Date>()` otherwise
49 QuantLib::Date date() const override;
50 //! Return the current scenario if reader is still valid and `nullptr` otherwise
51 QuantLib::ext::shared_ptr<Scenario> scenario() const override;
52
53private:
54 //! Scenario factory
55 QuantLib::ext::shared_ptr<ScenarioFactory> scenarioFactory_;
56 //! Handle on the csv file
58 //! The risk factor keys of the scenarios in the file
59 std::vector<RiskFactorKey> keys_;
60 //! Flag indicating if the reader has no more scenarios to read
62};
63
64} // namespace analytics
65} // namespace ore
Class for reading historical scenarios from a csv file.
ore::data::CSVFileReader file_
Handle on the csv file.
QuantLib::ext::shared_ptr< Scenario > scenario() const override
Return the current scenario if reader is still valid and nullptr otherwise.
bool finished_
Flag indicating if the reader has no more scenarios to read.
std::vector< RiskFactorKey > keys_
The risk factor keys of the scenarios in the file.
QuantLib::Date date() const override
Return the current scenario's date if reader is still valid and Null<Date>() otherwise.
QuantLib::ext::shared_ptr< ScenarioFactory > scenarioFactory_
Scenario factory.
bool next() override
Return true if there is another Scenario to read and move to it.
Base Class for reading historical scenarios.
historical scenario reader
factory classes for scenarios