Skip to content

Commit 75b0e89

Browse files
author
jenkins
committed
git subrepo pull (merge) ore
subrepo: subdir: "ore" merged: "49a38159a6" upstream: origin: "git@gitlab.acadiasoft.net:qs/ore.git" branch: "master" commit: "c78cfbc2b0" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb"
2 parents 6918535 + c78cfbc commit 75b0e89

50 files changed

Lines changed: 437 additions & 199 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Docs/UserGuide/parameterisation/curveconfig.tex

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ \subsubsection{Equity Curve Structures}
309309
<!-- See Table \ref{tab:allow_interp_methods} for allowed interpolation methods -->
310310
<InterpolationMethod>Linear</InterpolationMethod>
311311
</DividendInterpolation>
312-
<!-- Optional node, defaults to true -->
313-
<Extrapolation>True</Extrapolation>
312+
<DividendExtrapolation>False</DividendExtrapolation>
313+
<!-- Optional node, defaults to false -->
314+
<Extrapolation>False</Extrapolation>
314315
<DayCounter>A365</DayCounter>
315316
</EquityCurve>
316317
<EquityCurve>
@@ -336,7 +337,8 @@ \subsubsection{Equity Curve Structures}
336337
\item Quotes [Optional]: Market datum IDs/names to be used in building the curve structure.
337338
\item DayCounter [Optional]: The term structure's day counter used in date to time conversions. Defaults to {\tt A365F}.
338339
\item DividendInterpolation [Optional]: This node contains an \lstinline!InterpolationVariable! and \lstinline!InterpolationMethod! sub-node, which define the variable on which the interpolation is performed and the interpolation method for the dividend curve, respectively. The allowable values are found in Table \ref{tab:allow_interp_variables} and Table \ref{tab:allow_interp_methods}, respectively. This should not be provided if \lstinline!Type! is {\tt NoDividends}.
339-
\item Extrapolation [Optional]: Boolean flag indicating whether extrapolation is allowed. Defaults to {\tt True}.
340+
\item DividendExtrapolation [Optional]: Boolean flag indicating whether extrapolation in the dividend curve is allowed. If True the dividend curve is extrapolated forward at the risk free rate beyond the last date of the curve - this is only considered when \lstinline!Extrapolation! is False. Defaults to {\tt False}.
341+
\item Extrapolation [Optional]: Boolean flag indicating whether extrapolation in the forward price is allowed. Defaults to {\tt False}.
340342
\end{itemize}
341343

342344
The equity curves here consists of a spot equity price, as well as a set of either forward prices or else dividend
@@ -358,6 +360,7 @@ \subsubsection{Equity Volatility Structures}
358360
\begin{itemize}
359361
\item CurveId: Unique identifier for the curve.
360362
\item CurveDescription [Optional]: A description of the curve. This field may be left blank.
363+
\item EquityId: [Optional] Identifies the underlying equity name, this is used in the construction of the \lstinline!Quote! strings. If omitted the \lstinline!CurveId! is used instead.
361364
\item Currency: Currency of the equity.
362365
\item Calendar [Optional]: allowable value is any valid calendar. Defaults to \lstinline!NullCalendar!.
363366
\item DayCounter [Optional]: allowable value is any valid day counter. Defaults to \lstinline!A365!.
@@ -374,10 +377,11 @@ \subsubsection{Equity Volatility Structures}
374377
<EquityVolatility>
375378
<CurveId>SP5</CurveId>
376379
<CurveDescription>Lognormal option implied vols for SP 500</CurveDescription>
380+
<EquityId>RIC:.SP5</EquityId>
377381
<Currency>USD</Currency>
378382
<DayCounter>Actual/365 (Fixed)</DayCounter>
379383
<Constant>
380-
<Quote>EQUITY_OPTION/RATE_LNVOL/SP5/USD/5Y/ATMF</Quote>
384+
<Quote>EQUITY_OPTION/RATE_LNVOL/RIC:.SP5/USD/5Y/ATMF</Quote>
381385
</Constant>
382386
</EquityVolatility>
383387
<EquityVolatility>
@@ -398,13 +402,14 @@ \subsubsection{Equity Volatility Structures}
398402
<EquityVolatility>
399403
<CurveId>SP5</CurveId>
400404
<CurveDescription>Lognormal option implied vols for SP 500</CurveDescription>
405+
<EquityId>RIC:.SP5</EquityId>
401406
<Currency>USD</Currency>
402407
<DayCounter>Actual/365 (Fixed)</DayCounter>
403408
<Curve>
404409
<QuoteType>ImpliedVolatility</QuoteType>
405410
<VolatilityType>Lognormal</VolatilityType>
406411
<Quotes>
407-
<Quote>EQUITY_OPTION/RATE_LNVOL/SP5/USD/*</Quote>
412+
<Quote>EQUITY_OPTION/RATE_LNVOL/RIC:.SP5/USD/*</Quote>
408413
</Quotes>
409414
<Interpolation>LinearFlat</Interpolation>
410415
<Extrapolation>Flat</Extrapolation>
@@ -463,6 +468,7 @@ \subsubsection{Equity Volatility Structures}
463468
<EquityVolatility>
464469
<CurveId>SP5</CurveId>
465470
<CurveDescription>Lognormal option implied vols for SP 500</CurveDescription>
471+
<EquityId>RIC:.SP5</EquityId>
466472
<Currency>USD</Currency>
467473
<DayCounter>Actual/365 (Fixed)</DayCounter>
468474
<StrikeSurface>
@@ -509,6 +515,7 @@ \subsubsection{Equity Volatility Structures}
509515
<EquityVolatility>
510516
<CurveId>SP5</CurveId>
511517
<CurveDescription>Lognormal option implied vols for SP 500</CurveDescription>
518+
<EquityId>RIC:.SP5</EquityId>
512519
<Currency>USD</Currency>
513520
<DayCounter>Actual/365 (Fixed)</DayCounter>
514521
<MoneynessSurface>
@@ -542,6 +549,7 @@ \subsubsection{Equity Volatility Structures}
542549
<EquityVolatility>
543550
<CurveId>ABC</CurveId>
544551
<CurveDescription>Lognormal option implied vols for APC - proxied from SP5</CurveDescription>
552+
<EquityId>RIC:.SP5</EquityId>
545553
<Currency>USD</Currency>
546554
<DayCounter>Actual/365 (Fixed)</DayCounter>
547555
<ProxySurface>

OREAnalytics/orea/app/inputparameters.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ class InputParameters {
631631
bool outputCurves_ = false;
632632
std::string curvesMarketConfig_ = Market::defaultConfiguration;
633633
std::string curvesGrid_ = "240,1M";
634-
bool outputTodaysMarketCalibration_ = false;
634+
bool outputTodaysMarketCalibration_ = true;
635635

636636
/***********************************
637637
* CASHFLOW and CASHFLOWNPV analytic

OREData/ored/configuration/conventions.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Convention::Convention(const string& id, Type type) : type_(type), id_(id) {}
7171

7272
const boost::shared_ptr<ore::data::Conventions>& InstrumentConventions::conventions(QuantLib::Date d) const {
7373
QL_REQUIRE(!conventions_.empty(), "InstrumentConventions: No conventions provided.");
74-
std::shared_lock<std::shared_mutex> lock(mutex_);
74+
boost::shared_lock<boost::shared_mutex> lock(mutex_);
7575
Date dt = d == Date() ? Settings::instance().evaluationDate() : d;
7676
auto it = conventions_.lower_bound(dt);
7777
if(it != conventions_.end() && it->first == dt)
@@ -91,7 +91,7 @@ const boost::shared_ptr<ore::data::Conventions>& InstrumentConventions::conventi
9191

9292
void InstrumentConventions::setConventions(
9393
const boost::shared_ptr<ore::data::Conventions>& conventions, QuantLib::Date d) {
94-
std::unique_lock<std::shared_mutex> lock(mutex_);
94+
boost::unique_lock<boost::shared_mutex> lock(mutex_);
9595
conventions_[d] = conventions;
9696
}
9797

@@ -2467,7 +2467,7 @@ void Conventions::fromXML(XMLNode* node) {
24672467
}
24682468

24692469
XMLNode* Conventions::toXML(XMLDocument& doc) {
2470-
std::unique_lock<std::shared_mutex> lock(mutex_);
2470+
boost::unique_lock<boost::shared_mutex> lock(mutex_);
24712471

24722472
XMLNode* conventionsNode = doc.allocNode("Conventions");
24732473

@@ -2480,7 +2480,7 @@ XMLNode* Conventions::toXML(XMLDocument& doc) {
24802480
}
24812481

24822482
void Conventions::clear() const {
2483-
std::unique_lock<std::shared_mutex> lock(mutex_);
2483+
boost::unique_lock<boost::shared_mutex> lock(mutex_);
24842484
data_.clear();
24852485
}
24862486

@@ -2509,7 +2509,7 @@ std::string flip(const std::string& id, const std::string& sep = "-") {
25092509
boost::shared_ptr<Convention> Conventions::get(const string& id) const {
25102510

25112511
{
2512-
std::shared_lock<std::shared_mutex> lock(mutex_);
2512+
boost::shared_lock<boost::shared_mutex> lock(mutex_);
25132513
if (auto it = data_.find(id); it != data_.end()) {
25142514
used_.insert(id);
25152515
return it->second;
@@ -2522,7 +2522,7 @@ boost::shared_ptr<Convention> Conventions::get(const string& id) const {
25222522

25232523
std::string type, unparsed;
25242524
{
2525-
std::unique_lock<std::shared_mutex> lock(mutex_);
2525+
boost::unique_lock<boost::shared_mutex> lock(mutex_);
25262526
if (auto it = unparsed_.find(id); it != unparsed_.end()) {
25272527
std::tie(type, unparsed) = it->second;
25282528
unparsed_.erase(id);
@@ -2597,7 +2597,7 @@ boost::shared_ptr<Convention> Conventions::get(const string& id) const {
25972597
}
25982598

25992599
boost::shared_ptr<Convention> Conventions::getFxConvention(const string& ccy1, const string& ccy2) const {
2600-
std::shared_lock<std::shared_mutex> lock(mutex_);
2600+
boost::shared_lock<boost::shared_mutex> lock(mutex_);
26012601
for (auto c : data_) {
26022602
auto fxCon = boost::dynamic_pointer_cast<FXConvention>(c.second);
26032603
if (fxCon) {
@@ -2629,7 +2629,7 @@ std::set<boost::shared_ptr<Convention>> Conventions::get(const Convention::Type&
26292629
std::set<std::string> unparsedIds;
26302630
std::string typeStr = ore::data::to_string(type);
26312631
{
2632-
std::shared_lock<std::shared_mutex> lock(mutex_);
2632+
boost::shared_lock<boost::shared_mutex> lock(mutex_);
26332633
for (auto const& d : data_) {
26342634
if (d.second->type() == type) {
26352635
used_.insert(d.first);
@@ -2653,7 +2653,7 @@ bool Conventions::has(const string& id) const {
26532653
} catch (const std::exception& e) {
26542654
return false;
26552655
}
2656-
std::shared_lock<std::shared_mutex> lock(mutex_);
2656+
boost::shared_lock<boost::shared_mutex> lock(mutex_);
26572657
return data_.find(id) != data_.end() || unparsed_.find(id) != unparsed_.end() ||
26582658
data_.find(flip(id)) != data_.end() || unparsed_.find(flip(id)) != unparsed_.end();
26592659
}
@@ -2663,7 +2663,7 @@ bool Conventions::has(const std::string& id, const Convention::Type& type) const
26632663
}
26642664

26652665
void Conventions::add(const boost::shared_ptr<Convention>& convention) const {
2666-
std::unique_lock<std::shared_mutex> lock(mutex_);
2666+
boost::unique_lock<boost::shared_mutex> lock(mutex_);
26672667
const string& id = convention->id();
26682668
QL_REQUIRE(data_.find(id) == data_.end(), "Convention already exists for id " << id);
26692669
data_[id] = convention;

OREData/ored/configuration/conventions.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#include <qle/indexes/bmaindexwrapper.hpp>
3737
#include <qle/indexes/commodityindex.hpp>
3838

39-
#include <shared_mutex>
40-
39+
#include <boost/thread/shared_mutex.hpp>
40+
#include <boost/thread/lock_types.hpp>
4141

4242
namespace ore {
4343
namespace data {
@@ -154,7 +154,7 @@ class Conventions : public XMLSerializable {
154154
mutable map<string, boost::shared_ptr<Convention>> data_;
155155
mutable map<string, std::pair<string, string>> unparsed_;
156156
mutable std::set<string> used_;
157-
mutable std::shared_mutex mutex_;
157+
mutable boost::shared_mutex mutex_;
158158
};
159159

160160
//! Singleton to hold conventions
@@ -166,7 +166,7 @@ class InstrumentConventions : public QuantLib::Singleton<InstrumentConventions,
166166
InstrumentConventions() { conventions_[Date()] = boost::make_shared<ore::data::Conventions>(); }
167167

168168
mutable std::map<QuantLib::Date, boost::shared_ptr<ore::data::Conventions>> conventions_;
169-
mutable std::shared_mutex mutex_;
169+
mutable boost::shared_mutex mutex_;
170170
mutable std::size_t numberOfEmittedWarnings_ = 0;
171171

172172
public:

OREData/ored/configuration/curveconfigurations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void CurveConfigurations::parseNode(const CurveSpec::CurveType& type, const stri
135135
configs_[type][curveId] = config;
136136
unparsed_.at(type).erase(curveId);
137137
} catch (std::exception& ex) {
138-
string err = "Curve config under node '" + to_string(type) + "was requested, but could not be parsed.";
138+
string err = "Curve config under node '" + to_string(type) + " was requested, but could not be parsed.";
139139
ALOG(StructuredCurveErrorMessage(curveId, err, ex.what()));
140140
QL_FAIL(err);
141141
}

OREData/ored/configuration/equitycurveconfig.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ EquityCurveConfig::EquityCurveConfig(const string& curveID, const string& curveD
3131
const EquityCurveConfig::Type& type, const string& equitySpotQuote,
3232
const vector<string>& fwdQuotes, const string& dayCountID,
3333
const string& dividendInterpVariable, const string& dividendInterpMethod,
34-
bool extrapolation, const QuantLib::Exercise::Type& exerciseStyle)
34+
const bool dividendExtrapolation, const bool extrapolation,
35+
const QuantLib::Exercise::Type& exerciseStyle)
3536
: CurveConfig(curveID, curveDescription), fwdQuotes_(fwdQuotes), forecastingCurve_(forecastingCurve),
36-
currency_(currency), calendar_(calendar), type_(type), equitySpotQuoteID_(equitySpotQuote), dayCountID_(dayCountID),
37-
divInterpVariable_(dividendInterpVariable), divInterpMethod_(dividendInterpMethod), extrapolation_(extrapolation),
38-
exerciseStyle_(exerciseStyle) {
37+
currency_(currency), calendar_(calendar), type_(type), equitySpotQuoteID_(equitySpotQuote), dayCountID_(dayCountID),
38+
divInterpVariable_(dividendInterpVariable), divInterpMethod_(dividendInterpMethod), dividendExtrapolation_(dividendExtrapolation),
39+
extrapolation_(extrapolation), exerciseStyle_(exerciseStyle) {
3940
quotes_ = fwdQuotes;
4041
quotes_.insert(quotes_.begin(), equitySpotQuote);
4142
populateRequiredCurveIds();
@@ -72,8 +73,8 @@ void EquityCurveConfig::fromXML(XMLNode* node) {
7273
divInterpVariable_ = "Zero";
7374
divInterpMethod_ = divInterpVariable_ == "Zero" ? "Linear" : "LogLinear";
7475
}
75-
76-
extrapolation_ = XMLUtils::getChildValueAsBool(node, "Extrapolation"); // defaults to true
76+
dividendExtrapolation_ = XMLUtils::getChildValueAsBool(node, "DividendExtrapolation", false, false);
77+
extrapolation_ = XMLUtils::getChildValueAsBool(node, "Extrapolation", false, false);
7778

7879
if (type_ == Type::NoDividends) {
7980
QL_REQUIRE(fwdQuotes_.size() == 0,
@@ -105,6 +106,7 @@ XMLNode* EquityCurveConfig::toXML(XMLDocument& doc) {
105106
XMLUtils::addChild(doc, divInterpNode, "InterpolationVariable", divInterpVariable_);
106107
XMLUtils::addChild(doc, divInterpNode, "InterpolationMethod", divInterpMethod_);
107108
}
109+
XMLUtils::addChild(doc, node, "DividendExtrapolation", dividendExtrapolation_);
108110
XMLUtils::addChild(doc, node, "Extrapolation", extrapolation_);
109111

110112
return node;

OREData/ored/configuration/equitycurveconfig.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class EquityCurveConfig : public CurveConfig {
5656
const string& currency, const string& calendar, const Type& type, const string& equitySpotQuote,
5757
const vector<string>& quotes, const string& dayCountID = "",
5858
const string& dividendInterpVariable = "Zero", const string& dividendInterpMethod = "Linear",
59-
bool extrapolation = true,
59+
const bool dividendExtrapolation = false, const bool extrapolation = false,
6060
const QuantLib::Exercise::Type& exerciseStyle = QuantLib::Exercise::Type::European);
6161
//! Default constructor
6262
EquityCurveConfig() {}
@@ -78,6 +78,7 @@ class EquityCurveConfig : public CurveConfig {
7878
const string& dayCountID() const { return dayCountID_; }
7979
const string& dividendInterpolationVariable() const { return divInterpVariable_; }
8080
const string& dividendInterpolationMethod() const { return divInterpMethod_; }
81+
bool dividendExtrapolation() const { return dividendExtrapolation_; }
8182
bool extrapolation() const { return extrapolation_; }
8283
const QuantLib::Exercise::Type exerciseStyle() const { return exerciseStyle_; }
8384
const vector<string>& fwdQuotes() { return fwdQuotes_; }
@@ -91,6 +92,7 @@ class EquityCurveConfig : public CurveConfig {
9192
string& dayCountID() { return dayCountID_; }
9293
string& dividendInterpolationVariable() { return divInterpVariable_; }
9394
string& dividendInterpolationMethod() { return divInterpMethod_; }
95+
bool& dividendExtrapolation() { return dividendExtrapolation_; }
9496
bool& extrapolation() { return extrapolation_; }
9597
QuantLib::Exercise::Type& exerciseStyle() { return exerciseStyle_; }
9698

@@ -110,6 +112,7 @@ class EquityCurveConfig : public CurveConfig {
110112
string dayCountID_;
111113
string divInterpVariable_;
112114
string divInterpMethod_;
115+
bool dividendExtrapolation_;
113116
bool extrapolation_;
114117
QuantLib::Exercise::Type exerciseStyle_;
115118
};

OREData/ored/configuration/equityvolcurveconfig.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ namespace data {
2929

3030
EquityVolatilityCurveConfig::EquityVolatilityCurveConfig(
3131
const string& curveID, const string& curveDescription, const string& currency,
32-
const vector<boost::shared_ptr<VolatilityConfig>>& volatilityConfig, const string& dayCounter,
33-
const string& calendar, const OneDimSolverConfig& solverConfig, const boost::optional<bool>& preferOutOfTheMoney)
32+
const vector<boost::shared_ptr<VolatilityConfig>>& volatilityConfig, const string& equityId,
33+
const string& dayCounter, const string& calendar, const OneDimSolverConfig& solverConfig,
34+
const boost::optional<bool>& preferOutOfTheMoney)
3435
: CurveConfig(curveID, curveDescription), ccy_(currency), volatilityConfig_(volatilityConfig),
35-
dayCounter_(dayCounter), calendar_(calendar), solverConfig_(solverConfig),
36+
equityId_(equityId), dayCounter_(dayCounter), calendar_(calendar), solverConfig_(solverConfig),
3637
preferOutOfTheMoney_(preferOutOfTheMoney) {
3738
populateQuotes();
3839
populateRequiredCurveIds();
3940
}
4041

41-
EquityVolatilityCurveConfig::EquityVolatilityCurveConfig(const string& curveID, const string& curveDescription,
42-
const string& currency,
43-
const boost::shared_ptr<VolatilityConfig>& volatilityConfig,
44-
const string& dayCounter, const string& calendar,
45-
const OneDimSolverConfig& solverConfig,
46-
const boost::optional<bool>& preferOutOfTheMoney)
42+
EquityVolatilityCurveConfig::EquityVolatilityCurveConfig(
43+
const string& curveID, const string& curveDescription, const string& currency,
44+
const boost::shared_ptr<VolatilityConfig>& volatilityConfig, const string& equityId,
45+
const string& dayCounter, const string& calendar, const OneDimSolverConfig& solverConfig,
46+
const boost::optional<bool>& preferOutOfTheMoney)
4747
: EquityVolatilityCurveConfig(curveID, curveDescription, currency,
48-
std::vector<boost::shared_ptr<VolatilityConfig>>{volatilityConfig}, dayCounter,
49-
calendar, solverConfig, preferOutOfTheMoney) {}
48+
std::vector<boost::shared_ptr<VolatilityConfig>>{volatilityConfig}, equityId, dayCounter,
49+
calendar, solverConfig, preferOutOfTheMoney) {}
5050

5151
const string EquityVolatilityCurveConfig::quoteStem(const string& volType) const {
52-
return "EQUITY_OPTION/" + volType + "/" + curveID_ + "/" + ccy_ + "/";
52+
return "EQUITY_OPTION/" + volType + "/" + equityId() + "/" + ccy_ + "/";
5353
}
5454

5555
void EquityVolatilityCurveConfig::populateQuotes() {
@@ -97,6 +97,7 @@ void EquityVolatilityCurveConfig::fromXML(XMLNode* node) {
9797

9898
curveID_ = XMLUtils::getChildValue(node, "CurveId", true);
9999
curveDescription_ = XMLUtils::getChildValue(node, "CurveDescription", true);
100+
equityId_ = XMLUtils::getChildValue(node, "EquityId", false);
100101
ccy_ = XMLUtils::getChildValue(node, "Currency", true);
101102

102103
calendar_ = XMLUtils::getChildValue(node, "Calendar", false);
@@ -138,13 +139,13 @@ void EquityVolatilityCurveConfig::fromXML(XMLNode* node) {
138139
"Dimension ATM, but multiple strikes provided for EquityVolatility " << curveID_);
139140
// if ATM create VolatilityCurveConfig which requires quotes to be provided
140141
vector<string> quotes(expiries.size());
141-
string quoteStem = "EQUITY_OPTION/RATE_LNVOL/" + curveID_ + "/" + ccy_ + "/";
142+
string stem = quoteStem("RATE_LNVOL");
142143
if (expiries.size() == 1 && expiries.front() == "*") {
143-
quotes[0] = (quoteStem + "*");
144+
quotes[0] = (stem + "*");
144145
} else {
145146
Size i = 0;
146147
for (auto ex : expiries) {
147-
quotes[i] = (quoteStem + ex + "/ATMF");
148+
quotes[i] = (stem + ex + "/ATMF");
148149
i++;
149150
}
150151
}
@@ -178,6 +179,7 @@ XMLNode* EquityVolatilityCurveConfig::toXML(XMLDocument& doc) {
178179

179180
XMLUtils::addChild(doc, node, "CurveId", curveID_);
180181
XMLUtils::addChild(doc, node, "CurveDescription", curveDescription_);
182+
XMLUtils::addChild(doc, node, "EquityId", equityId_);
181183
XMLUtils::addChild(doc, node, "Currency", ccy_);
182184
XMLUtils::addChild(doc, node, "DayCounter", dayCounter_);
183185

0 commit comments

Comments
 (0)