29 Real baseFactor = 1.0;
42 if (d < f.first && asof_ > f.first) {
43 baseFactor = baseFactor * f.second;
45 if (
asof_ < f.first && f.first <= d) {
46 baseFactor = baseFactor / f.second;
53 data_[
name].push_back(std::pair<Date, Real>(d, factor));
72 for (
auto d :
data_) {
73 for (
auto f : d.second) {
84 std::set<std::string> result;
85 for (
auto const& m :
data_)
86 result.insert(m.first);
91 std::set<QuantLib::Date> result;
93 if (d !=
data_.end()) {
94 for (
auto const& m : d->second)
95 result.insert(m.first);
102 if (adj !=
data_.end()) {
103 auto it = std::find_if(adj->second.begin(), adj->second.end(),
104 [&d](
const std::pair<QuantLib::Date, QuantLib::Real>& m) { return m.first == d; });
105 if (it != adj->second.end())
QuantLib::Real getFactor(const std::string &name, const QuantLib::Date &d) const
Returns the adjustment factor for a name on a given date.
std::map< std::string, std::vector< std::pair< QuantLib::Date, QuantLib::Real > > > data_
Map of names to adjustment factors.
virtual void fromXML(ore::data::XMLNode *node) override
std::set< QuantLib::Date > dates(const std::string &name) const
dates with contributions to an adjustment factor for a name
QuantLib::Date asof_
Asof date - only apply adjustments before this date.
std::set< std::string > names() const
names with adjustment factors
virtual ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
void addFactor(std::string name, QuantLib::Date d, QuantLib::Real factor)
Add an adjustment factor.
QuantLib::Real getFactorContribution(const std::string &name, const QuantLib::Date &d) const
gets the contribution to an adjustment factor for a name on a given date
bool hasFactor(const std::string &name) const
Check if we have any adjustment factors for a name.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void checkNode(XMLNode *n, const string &expectedName)
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
static XMLNode * locateNode(XMLNode *n, const string &name="")
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities