Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
adjustmentfactors.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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#pragma once
20
23
24namespace ore {
25namespace data {
26
27//! Class to hold market data adjustment factors - for example equity stock splits
29public:
30 AdjustmentFactors(QuantLib::Date asof) : asof_(asof){};
31
32 //! Check if we have any adjustment factors for a name
33 bool hasFactor(const std::string& name) const;
34 //! Returns the adjustment factor for a name on a given date
35 QuantLib::Real getFactor(const std::string& name, const QuantLib::Date& d) const;
36 //! Add an adjustment factor
37 void addFactor(std::string name, QuantLib::Date d, QuantLib::Real factor);
38
39 //! \name Serilaisation
40 //@{
41 virtual void fromXML(ore::data::XMLNode* node) override;
42 virtual ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
43 //@}
44
45 //! names with adjustment factors
46 std::set<std::string> names() const;
47 //! dates with contributions to an adjustment factor for a name
48 std::set<QuantLib::Date> dates(const std::string& name) const;
49 //! gets the contribution to an adjustment factor for a name on a given date
50 QuantLib::Real getFactorContribution(const std::string& name, const QuantLib::Date& d) const;
51
52private:
53 //! Asof date - only apply adjustments before this date
54 QuantLib::Date asof_;
55 //! Map of names to adjustment factors
56 std::map<std::string, std::vector<std::pair<QuantLib::Date, QuantLib::Real>>> data_;
57};
58
59} // namespace data
60} // namespace ore
Class to hold market data adjustment factors - for example equity stock splits.
QuantLib::Real getFactor(const std::string &name, const QuantLib::Date &d) const
Returns the adjustment factor for a name on a given date.
AdjustmentFactors(QuantLib::Date asof)
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.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string name
XML utility functions.