Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
marketdataloader.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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/app/marketdataloader.hpp
20 \brief Market Data Loader
21*/
22
23#pragma once
24
28
29namespace ore {
30namespace analytics {
31
32typedef std::map<QuantLib::Date, std::set<std::string>> QuoteMap;
33typedef std::map<std::string, RequiredFixings::FixingDates> FixingMap;
34
35//! Utility class for Structured Fixing warnings
37public:
38 StructuredFixingWarningMessage(const std::string& fixingId, const QuantLib::Date& fixingDate,
39 const std::string& exceptionType, const std::string& exceptionWhat)
40 : StructuredMessage(Category::Warning, Group::Fixing, exceptionWhat,
41 std::map<std::string, std::string>({{"exceptionType", exceptionType},
42 {"fixingId", fixingId},
43 {"fixingDate", ore::data::to_string(fixingDate)}})) {}
44};
45
47public:
50
51 //! load corporate action data
52 virtual void loadCorporateActionData(QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
53 const std::map<std::string, std::string>& equities) = 0;
54
55 //! retrieve market data
56 virtual void retrieveMarketData(const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
57 const QuoteMap& quotes,
58 const QuantLib::Date& requestDate = QuantLib::Date()) = 0;
59
60 //! retrieve fixings
61 virtual void retrieveFixings(const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader, FixingMap fixings = {},
62 std::map<std::pair<std::string, QuantLib::Date>, std::set<QuantLib::Date>> lastAvailableFixingLookupMap = {}) = 0;
63};
64
66public:
67 MarketDataLoader(const QuantLib::ext::shared_ptr<InputParameters>& inputs, QuantLib::ext::shared_ptr<MarketDataLoaderImpl> impl)
68 : inputs_(inputs), impl_(impl) {
69 loader_ = QuantLib::ext::make_shared<ore::data::InMemoryLoader>();
70 }
71 virtual ~MarketDataLoader() {}
72
73 /*! Populate a market data \p loader. Gathers all the quotes needed based on the configs provided and calls the
74 marketdata and fixing services
75 */
76 void populateLoader(const std::vector<QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>>& todaysMarketParameters,
77 const std::set<QuantLib::Date>& loaderDates);
78
79 virtual void
80 populateFixings(const std::vector<QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>>& todaysMarketParameters,
81 const std::set<QuantLib::Date>& loaderDates = {});
82
83 virtual void addRelevantFixings(const std::pair<std::string, RequiredFixings::FixingDates>& fixing,
84 std::map<std::pair<std::string, QuantLib::Date>, std::set<QuantLib::Date>>& lastAvailableFixingLookupMap);
85
86 //! clear the loader
87 void resetLoader() { loader_ = QuantLib::ext::make_shared<ore::data::InMemoryLoader>(); };
88
89 //! getters
90 const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader() const { return loader_; };
91 QuoteMap quotes() { return quotes_; }
92
93protected:
94 QuantLib::ext::shared_ptr<InputParameters> inputs_;
95 QuantLib::ext::shared_ptr<ore::data::InMemoryLoader> loader_;
98
99 const QuantLib::ext::shared_ptr<MarketDataLoaderImpl>& impl() const;
100
101private:
102 QuantLib::ext::shared_ptr<MarketDataLoaderImpl> impl_;
103};
104
105} // namespace analytics
106} // namespace ore
virtual void populateFixings(const std::vector< QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > > &todaysMarketParameters, const std::set< QuantLib::Date > &loaderDates={})
QuantLib::ext::shared_ptr< MarketDataLoaderImpl > impl_
MarketDataLoader(const QuantLib::ext::shared_ptr< InputParameters > &inputs, QuantLib::ext::shared_ptr< MarketDataLoaderImpl > impl)
void populateLoader(const std::vector< QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > > &todaysMarketParameters, const std::set< QuantLib::Date > &loaderDates)
virtual void addRelevantFixings(const std::pair< std::string, RequiredFixings::FixingDates > &fixing, std::map< std::pair< std::string, QuantLib::Date >, std::set< QuantLib::Date > > &lastAvailableFixingLookupMap)
void resetLoader()
clear the loader
QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > loader_
const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > & loader() const
getters
QuantLib::ext::shared_ptr< InputParameters > inputs_
const QuantLib::ext::shared_ptr< MarketDataLoaderImpl > & impl() const
virtual void retrieveFixings(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, FixingMap fixings={}, std::map< std::pair< std::string, QuantLib::Date >, std::set< QuantLib::Date > > lastAvailableFixingLookupMap={})=0
retrieve fixings
virtual void loadCorporateActionData(QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::map< std::string, std::string > &equities)=0
load corporate action data
virtual void retrieveMarketData(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const QuoteMap &quotes, const QuantLib::Date &requestDate=QuantLib::Date())=0
retrieve market data
Utility class for Structured Fixing warnings.
StructuredFixingWarningMessage(const std::string &fixingId, const QuantLib::Date &fixingDate, const std::string &exceptionType, const std::string &exceptionWhat)
Input Parameters.
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
std::map< std::string, RequiredFixings::FixingDates > FixingMap
std::map< QuantLib::Date, std::set< std::string > > QuoteMap
std::string to_string(const LocationInfo &l)