Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
CompositeLoader Class Reference

#include <ored/marketdata/compositeloader.hpp>

+ Inheritance diagram for CompositeLoader:
+ Collaboration diagram for CompositeLoader:

Public Member Functions

 CompositeLoader (const QuantLib::ext::shared_ptr< Loader > &a, const QuantLib::ext::shared_ptr< Loader > &b)
 
std::vector< QuantLib::ext::shared_ptr< MarketDatum > > loadQuotes (const QuantLib::Date &d) const override
 get all quotes, TODO change the return value to std::set More...
 
QuantLib::ext::shared_ptr< MarketDatumget (const std::string &name, const QuantLib::Date &d) const override
 get quote by its unique name, throws if not existent, override in derived classes for performance More...
 
std::set< QuantLib::ext::shared_ptr< MarketDatum > > get (const std::set< std::string > &names, const QuantLib::Date &asof) const override
 get quotes matching a set of names, this should be overridden in derived classes for performance More...
 
std::set< QuantLib::ext::shared_ptr< MarketDatum > > get (const Wildcard &wildcard, const QuantLib::Date &asof) const override
 get quotes matching a wildcard, this should be overriden in derived classes for performance More...
 
bool has (const std::string &name, const QuantLib::Date &d) const override
 Default implementation, returns false if get throws or returns a null pointer. More...
 
std::set< FixingloadFixings () const override
 
std::set< QuantExt::DividendloadDividends () const override
 Optional load dividends method. More...
 
- Public Member Functions inherited from Loader
virtual ~Loader ()
 
virtual bool hasQuotes (const QuantLib::Date &d) const
 check if there are quotes for a date More...
 
virtual QuantLib::ext::shared_ptr< MarketDatumget (const std::pair< std::string, bool > &name, const QuantLib::Date &d) const
 
virtual bool hasFixing (const string &name, const QuantLib::Date &d) const
 
virtual Fixing getFixing (const string &name, const QuantLib::Date &d) const
 Default implementation for getFixing. More...
 
void setActualDate (const QuantLib::Date &d)
 
const Date & actualDate () const
 
std::pair< bool, string > checkFxDuplicate (const ext::shared_ptr< MarketDatum >, const QuantLib::Date &)
 

Private Attributes

const QuantLib::ext::shared_ptr< Loadera_
 
const QuantLib::ext::shared_ptr< Loaderb_
 

Additional Inherited Members

- Protected Attributes inherited from Loader
Date actualDate_ = Date()
 

Detailed Description

Definition at line 32 of file compositeloader.hpp.

Constructor & Destructor Documentation

◆ CompositeLoader()

CompositeLoader ( const QuantLib::ext::shared_ptr< Loader > &  a,
const QuantLib::ext::shared_ptr< Loader > &  b 
)

Definition at line 34 of file compositeloader.hpp.

34 : a_(a), b_(b) {
35 QL_REQUIRE(a_ || b_, "CompositeLoader(): at least one loader must be not null");
36 }
const QuantLib::ext::shared_ptr< Loader > b_
const QuantLib::ext::shared_ptr< Loader > a_

Member Function Documentation

◆ loadQuotes()

std::vector< QuantLib::ext::shared_ptr< MarketDatum > > loadQuotes ( const QuantLib::Date &  ) const
overridevirtual

get all quotes, TODO change the return value to std::set

Implements Loader.

Definition at line 38 of file compositeloader.hpp.

38 {
39 if (!b_)
40 return a_->loadQuotes(d);
41 if (!a_)
42 return b_->loadQuotes(d);
43 std::vector<QuantLib::ext::shared_ptr<MarketDatum>> data;
44 auto tmp1 = a_->loadQuotes(d);
45 data.insert(data.end(), tmp1.begin(), tmp1.end());
46 auto tmp2 = b_->loadQuotes(d);
47 data.insert(data.end(), tmp2.begin(), tmp2.end());
48 return data;
49 }
@ data
Definition: log.hpp:77

◆ get() [1/3]

QuantLib::ext::shared_ptr< MarketDatum > get ( const std::string &  name,
const QuantLib::Date &  d 
) const
overridevirtual

get quote by its unique name, throws if not existent, override in derived classes for performance

Reimplemented from Loader.

Definition at line 51 of file compositeloader.hpp.

51 {
52 if (a_ && a_->has(name, d))
53 return a_->get(name, d);
54 if (b_ && b_->has(name, d))
55 return b_->get(name, d);
56 QL_FAIL("No MarketDatum for name " << name << " and date " << d);
57 }
string name

◆ get() [2/3]

std::set< QuantLib::ext::shared_ptr< MarketDatum > > get ( const std::set< std::string > &  names,
const QuantLib::Date &  asof 
) const
overridevirtual

get quotes matching a set of names, this should be overridden in derived classes for performance

Reimplemented from Loader.

Definition at line 59 of file compositeloader.hpp.

60 {
61 std::set<QuantLib::ext::shared_ptr<MarketDatum>> result;
62 if (a_) {
63 auto tmp = a_->get(names, asof);
64 result.insert(tmp.begin(), tmp.end());
65 }
66 if (b_) {
67 auto tmp = b_->get(names, asof);
68 result.insert(tmp.begin(), tmp.end());
69 }
70 return result;
71 }

◆ get() [3/3]

std::set< QuantLib::ext::shared_ptr< MarketDatum > > get ( const Wildcard wildcard,
const QuantLib::Date &  asof 
) const
overridevirtual

get quotes matching a wildcard, this should be overriden in derived classes for performance

Reimplemented from Loader.

Definition at line 73 of file compositeloader.hpp.

73 {
74 std::set<QuantLib::ext::shared_ptr<MarketDatum>> result;
75 if (a_) {
76 auto tmp = a_->get(wildcard, asof);
77 result.insert(tmp.begin(), tmp.end());
78 }
79 if (b_) {
80 auto tmp = b_->get(wildcard, asof);
81 result.insert(tmp.begin(), tmp.end());
82 }
83 return result;
84 }

◆ has()

bool has ( const std::string &  name,
const QuantLib::Date &  d 
) const
overridevirtual

Default implementation, returns false if get throws or returns a null pointer.

Reimplemented from Loader.

Definition at line 86 of file compositeloader.hpp.

86 {
87 return (a_ && a_->has(name, d)) || (b_ && b_->has(name, d));
88 }

◆ loadFixings()

std::set< Fixing > loadFixings ( ) const
overridevirtual

Implements Loader.

Definition at line 90 of file compositeloader.hpp.

90 {
91 if (!b_)
92 return a_->loadFixings();
93 if (!a_)
94 return b_->loadFixings();
95 std::set<Fixing> fixings;
96 auto tmp1 = a_->loadFixings();
97 auto tmp2 = b_->loadFixings();
98 fixings.insert(tmp1.begin(), tmp1.end());
99 fixings.insert(tmp2.begin(), tmp2.end());
100 return fixings;
101 }

◆ loadDividends()

std::set< QuantExt::Dividend > loadDividends ( ) const
overridevirtual

Optional load dividends method.

Reimplemented from Loader.

Definition at line 103 of file compositeloader.hpp.

103 {
104 if (!b_)
105 return a_->loadDividends();
106 if (!a_)
107 return b_->loadDividends();
108 std::set<QuantExt::Dividend> dividends;
109 auto tmp1 = a_->loadDividends();
110 auto tmp2 = b_->loadDividends();
111 dividends.insert(tmp1.begin(), tmp1.end());
112 dividends.insert(tmp2.begin(), tmp2.end());
113 return dividends;
114 }

Member Data Documentation

◆ a_

const QuantLib::ext::shared_ptr<Loader> a_
private

Definition at line 117 of file compositeloader.hpp.

◆ b_

const QuantLib::ext::shared_ptr<Loader> b_
private

Definition at line 117 of file compositeloader.hpp.