Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
csvloader.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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 ored/marketdata/csvloader.hpp
20 \brief Market Datum Loader Implementation
21 \ingroup marketdata
22*/
23
24#pragma once
25
26#include <map>
28
29namespace ore {
30namespace data {
31
32//! Utility class for loading market quotes and fixings from a file
33/*!
34 Data is loaded with the call to the constructor.
35 Inspectors can be called to then retrieve quotes and fixings.
36
37 TODO implementation has large overlap with inmemoryloader.?pp, factor this out
38
39 \ingroup marketdata
40 */
41class CSVLoader : public Loader {
42public:
43 //! Constructor
45
46 CSVLoader( //! Quote file name
47 const string& marketFilename,
48 //! Fixing file name
49 const string& fixingFilename,
50 //! Enable/disable implying today's fixings
51 bool implyTodaysFixings = false,
52 //! Load fixings up to this date
53 Date fixingCutOffDate = Date());
54
55 CSVLoader( //! Quote file name
56 const vector<string>& marketFiles,
57 //! Fixing file name
58 const vector<string>& fixingFiles,
59 //! Enable/disable implying today's fixings
60 bool implyTodaysFixings = false,
61 //! Load fixings up to this date
62 Date fixingCutOffDate = Date());
63
64 CSVLoader( //! Quote file name
65 const string& marketFilename,
66 //! Fixing file name
67 const string& fixingFilename,
68 //! Dividend file name
69 const string& dividendFilename,
70 //! Enable/disable implying today's fixings
71 bool implyTodaysFixings = false,
72 //! Load fixings up to this date
73 Date fixingCutOffDate = Date());
74
75 CSVLoader( //! Quote file name
76 const vector<string>& marketFiles,
77 //! Fixing file name
78 const vector<string>& fixingFiles,
79 //! Dividend file name
80 const vector<string>& dividendFiles,
81 //! Enable/disable implying today's fixings
82 bool implyTodaysFixings = false,
83 //! Load fixings up to this date
84 Date fixingCutOffDate = Date());
85
86 std::vector<QuantLib::ext::shared_ptr<MarketDatum>> loadQuotes(const QuantLib::Date&) const override;
87
88 QuantLib::ext::shared_ptr<MarketDatum> get(const string& name, const QuantLib::Date& d) const override;
89 std::set<QuantLib::ext::shared_ptr<MarketDatum>> get(const std::set<std::string>& names,
90 const QuantLib::Date& asof) const override;
91 //! get quotes matching a wildcard
92 std::set<QuantLib::ext::shared_ptr<MarketDatum>> get(const Wildcard& wildcard, const QuantLib::Date& asof) const override;
93
94 //! Load fixings
95 std::set<Fixing> loadFixings() const override { return fixings_; }
96 //! Load dividends
97 std::set<QuantExt::Dividend> loadDividends() const override { return dividends_; }
98 //@}
99
100private:
101 enum class DataType { Market, Fixing, Dividend };
102 void loadFile(const string&, DataType);
103
105 std::map<QuantLib::Date, std::set<QuantLib::ext::shared_ptr<MarketDatum>, SharedPtrMarketDatumComparator>> data_;
106 std::set<Fixing> fixings_;
107 std::set<QuantExt::Dividend> dividends_;
109};
110} // namespace data
111} // namespace ore
Utility class for loading market quotes and fixings from a file.
Definition: csvloader.hpp:41
std::set< QuantExt::Dividend > loadDividends() const override
Load dividends.
Definition: csvloader.hpp:97
std::set< QuantExt::Dividend > dividends_
Definition: csvloader.hpp:107
std::set< Fixing > fixings_
Definition: csvloader.hpp:106
QuantLib::ext::shared_ptr< MarketDatum > get(const string &name, const QuantLib::Date &d) const override
get quote by its unique name, throws if not existent, override in derived classes for performance
Definition: csvloader.cpp:199
std::set< Fixing > loadFixings() const override
Load fixings.
Definition: csvloader.hpp:95
CSVLoader()
Constructor.
Definition: csvloader.hpp:44
std::vector< QuantLib::ext::shared_ptr< MarketDatum > > loadQuotes(const QuantLib::Date &) const override
get all quotes, TODO change the return value to std::set
Definition: csvloader.cpp:192
std::map< QuantLib::Date, std::set< QuantLib::ext::shared_ptr< MarketDatum >, SharedPtrMarketDatumComparator > > data_
Definition: csvloader.hpp:105
void loadFile(const string &, DataType)
Definition: csvloader.cpp:100
Market data loader base class.
Definition: loader.hpp:47
Market Datum Loader Interface.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string name