Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
marketdatainmemoryloader.cpp
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
21
22using namespace ore::data;
24
25namespace ore {
26namespace analytics {
27
28void MarketDataInMemoryLoaderImpl::loadCorporateActionData(QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
29 const map<string, string>& equities) {
30 // TODO
31}
32
34 const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
35 const map<Date, set<string>>& quotes,
36 const Date& relabelDate) {
37
38 if (inputs_->entireMarket()) {
39 loadDataFromBuffers(*loader, marketData_, std::vector<std::string>(), inputs_->implyTodaysFixings());
40 } else {
41 QL_FAIL("MarketDataInMemoryLoaderImpl::retrieveMarketData() requires inputs_->entireMarket()");
42 }
43}
44
45void MarketDataInMemoryLoaderImpl::retrieveFixings(const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
46 map<string, RequiredFixings::FixingDates> fixings,
47 map<pair<string, Date>, set<Date>> lastAvailableFixingLookupMap) {
48
49 if (inputs_->allFixings()) {
50 loadDataFromBuffers(*loader, std::vector<std::string>(), fixingData_, inputs_->implyTodaysFixings());
51 } else {
52 QL_FAIL("MarketDataInMemoryLoaderImpl::retrieveFixings() requires inputs_->allFixings()");
53 }
54
55 for (const auto& fp : lastAvailableFixingLookupMap) {
56 if (loader->getFixing(fp.first.first, fp.first.second).empty()) {
57 set<Date>::reverse_iterator rit;
58 for (rit = fp.second.rbegin(); rit != fp.second.rend(); rit++) {
59 auto f = loader->getFixing(fp.first.first, *rit);
60 if (!f.empty()) {
61 loader->addFixing(fp.first.second, fp.first.first, f.fixing);
62 break;
63 }
64 }
65 WLOG("MarketDataInMemoryLoader::retrieveFixings(::load Could not find fixing for id " << fp.first.first << " on date "
66 << fp.first.second << ". ");
67 }
68 }
69}
70
71} // namespace analytics
72} // namespace ore
void retrieveMarketData(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const ore::analytics::QuoteMap &quotes, const QuantLib::Date &marketDate) override
retrieve market data
void retrieveFixings(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, ore::analytics::FixingMap fixings={}, std::map< std::pair< std::string, QuantLib::Date >, std::set< QuantLib::Date > > lastAvailableFixingLookupMap={}) override
retrieve fixings
void loadCorporateActionData(QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::map< std::string, std::string > &equities) override
load corporate action data
QuantLib::ext::shared_ptr< InputParameters > inputs_
#define WLOG(text)
Market Data Loader.
void loadDataFromBuffers(InMemoryLoader &loader, const std::vector< std::string > &marketData, const std::vector< std::string > &fixingData, bool implyTodaysFixings=false)