26#include <ql/shared_ptr.hpp>
34 CompositeLoader(
const QuantLib::ext::shared_ptr<Loader>& a,
const QuantLib::ext::shared_ptr<Loader>& b) :
a_(a),
b_(b) {
35 QL_REQUIRE(
a_ ||
b_,
"CompositeLoader(): at least one loader must be not null");
38 std::vector<QuantLib::ext::shared_ptr<MarketDatum>>
loadQuotes(
const QuantLib::Date& d)
const override {
40 return a_->loadQuotes(d);
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());
51 QuantLib::ext::shared_ptr<MarketDatum>
get(
const std::string&
name,
const QuantLib::Date& d)
const override {
56 QL_FAIL(
"No MarketDatum for name " <<
name <<
" and date " << d);
59 std::set<QuantLib::ext::shared_ptr<MarketDatum>>
get(
const std::set<std::string>& names,
60 const QuantLib::Date& asof)
const override {
61 std::set<QuantLib::ext::shared_ptr<MarketDatum>> result;
63 auto tmp =
a_->get(names, asof);
64 result.insert(tmp.begin(), tmp.end());
67 auto tmp =
b_->get(names, asof);
68 result.insert(tmp.begin(), tmp.end());
73 std::set<QuantLib::ext::shared_ptr<MarketDatum>>
get(
const Wildcard& wildcard,
const QuantLib::Date& asof)
const override {
74 std::set<QuantLib::ext::shared_ptr<MarketDatum>> result;
76 auto tmp =
a_->get(wildcard, asof);
77 result.insert(tmp.begin(), tmp.end());
80 auto tmp =
b_->get(wildcard, asof);
81 result.insert(tmp.begin(), tmp.end());
86 bool has(
const std::string&
name,
const QuantLib::Date& d)
const override {
92 return a_->loadFixings();
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());
105 return a_->loadDividends();
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());
117 const QuantLib::ext::shared_ptr<Loader>
a_,
b_;
std::set< QuantExt::Dividend > loadDividends() const override
Optional load dividends method.
bool has(const std::string &name, const QuantLib::Date &d) const override
Default implementation, returns false if get throws or returns a null pointer.
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
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
std::set< Fixing > loadFixings() const override
const QuantLib::ext::shared_ptr< Loader > b_
CompositeLoader(const QuantLib::ext::shared_ptr< Loader > &a, const QuantLib::ext::shared_ptr< Loader > &b)
QuantLib::ext::shared_ptr< MarketDatum > get(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
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
const QuantLib::ext::shared_ptr< Loader > a_
Market data loader base class.
Market Datum Loader Interface.
Serializable Credit Default Swap.