Skip to content

Commit 9414e24

Browse files
author
Sjogren
committed
Merge remote-tracking branch 'origin/master' into feature/martin_docs1
2 parents 687da4d + be2a919 commit 9414e24

43 files changed

Lines changed: 724 additions & 273 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/conventions.tex

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ \subsubsection{Future Conventions}\label{ss:conventions_future}
140140
\item Index: The underlying index of the futures, this is either a MM (i.e. Ibor) index like e.g. EUR-EURIBOR-3M or an
141141
overnight index like e.g. USD-SOFR.
142142
\item DateGenerationRule [Optional]: This should be set to `IMM' when the start and end dates of the future are
143-
following the IMM date logic or `FirstDayOfMonth' when the start and end date are the first day of a month. If not
144-
given this field defaults to `IMM'.
143+
following the IMM date logic, `FirstDayOfMonth' when the start and end date are the first day of a month, or
144+
`SecondThursday' when the expiry date is the second Thursday of the month. If not given this field defaults to `IMM'.
145145
\begin{itemize}
146-
\item For MM futures only `IMM' is allowed and the expiry date is determined as the next 3rd Wednesday of the expiry
147-
month of a future.
146+
\item For MM futures `IMM' or `SecondThursday' are allowed. The expiry date for `IMM' is determined as the next 3rd
147+
Wednesday of the expiry month of a future. The expiry date for `SecondThursday' is determined as the 2nd Thursday
148+
of the expiry month (e.g. used for AUD-BBSW-3M futures).
148149
\item For an overnight index future `IMM' means that the end date of the future is set to the 3rd Wednesday of the
149150
expiry month and the start date is set to the 3rd Wednesday of the expiry month minus the future tenor. The setting
150151
`IMM' applies to SOFR-3M futures for example. `FirstDayOfMonth' on the other hand means that the end date of the
@@ -163,8 +164,9 @@ \subsubsection{Future Conventions}\label{ss:conventions_future}
163164
are averaging the daily overnight fixings over the calculation period of the future.
164165
\end{itemize}
165166

166-
Listings \ref{lst:future_conventions_euribor_3m}, \ref{lst:future_conventions_sofr_3m},
167-
\ref{lst:future_conventions_sofr_1m} show examples for Euribor-3M, SOFR-3M and SOFR-1M future conventions.
167+
Listings \ref{lst:future_conventions_euribor_3m}, \ref{lst:future_conventions_aud_bbsw_3m},
168+
\ref{lst:future_conventions_sofr_3m}, \ref{lst:future_conventions_sofr_1m} show examples for Euribor-3M, AUD-BBSW-3M,
169+
SOFR-3M and SOFR-1M future conventions.
168170

169171
\begin{listing}[H]
170172
%\hrule\medskip
@@ -192,6 +194,19 @@ \subsubsection{Future Conventions}\label{ss:conventions_future}
192194
\label{lst:future_conventions_euribor_3m}
193195
\end{listing}
194196

197+
\begin{listing}[H]
198+
%\hrule\medskip
199+
\begin{minted}[fontsize=\footnotesize]{xml}
200+
<Future>
201+
<Id>AUD-BBSW-3M-FUTURES-CONVENTIONS</Id>
202+
<Index>AUD-BBSW-3M</Index>
203+
<DateGenerationRule>SecondThursday</DateGenerationRule>
204+
</Future>
205+
\end{minted}
206+
\caption{AUD BBSW 3M MM Future conventions (Second Thursday expiry)}
207+
\label{lst:future_conventions_aud_bbsw_3m}
208+
\end{listing}
209+
195210
\begin{listing}[H]
196211
%\hrule\medskip
197212
\begin{minted}[fontsize=\footnotesize]{xml}

Examples/CurveBuilding/ExpectedOutput/fixedfloatccs/todaysmarketcalibration_cashflows.csv

Lines changed: 189 additions & 173 deletions
Large diffs are not rendered by default.

Examples/ORE-Python/ExampleScripts/ExpectedOutput/dates.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ advance start date by 1M
1818
startDate 2020-05-01
1919
endDate 2020-06-01
2020
---------------------------
21+
May 1st, 2020
22+
May 6th, 2020
23+
May 11th, 2020
24+
2020-05-06

Examples/ORE-Python/ExampleScripts/dates.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,13 @@
4646
print("startDate", startDate.to_date())
4747
print("endDate ", endDate.to_date())
4848
print('---------------------------')
49+
50+
mporDays = 3
51+
52+
print(startDate)
53+
#print(ore.calculateMporDate(mporDays))
54+
print(ore.calculateMporDate(mporDays, startDate))
55+
print(ore.calculateMporDate(mporDays, startDate, calendarString))
56+
57+
print(ore.calculateMporDate(mporDays, startDate).to_date())
58+

ORE-SWIG/OREAnalytics-SWIG/SWIG/orea_app.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public:
112112
const ext::shared_ptr<ore::data::CurrencyConfig>& currencyConfigs();
113113
const ext::shared_ptr<ore::data::CalendarAdjustmentConfig>& calendarAdjustmentConfigs();
114114
const ext::shared_ptr<CurveConfigurations>& curveConfig(const std::string& s = std::string()) const;
115+
QuantLib::Date mporDate();
115116

116117
const QuantLib::ext::shared_ptr<ScenarioSimMarketParameters>& stressSimMarketParams() const;
117118
const QuantLib::ext::shared_ptr<StressTestScenarioData>& stressScenarioData() const;
@@ -127,6 +128,7 @@ public:
127128
void setBuildFailedTrades(bool b);
128129
void setObservationModel(const std::string& s);
129130
void setImplyTodaysFixings(bool b);
131+
void setFixingCutOffDate(Date d);
130132
void setUseAtParCouponsCurves(bool b);
131133
void setUseAtParCouponsTrades(bool b);
132134
void setMarketConfig(const std::string& config, const std::string& context);
@@ -141,6 +143,9 @@ public:
141143
void setConventions(const std::string& xml);
142144
void setConventionsFromFile(const std::string& fileName);
143145
void setConventions(const ext::shared_ptr<Conventions>& convs);
146+
void setMporConventions(const std::string& xml);
147+
void setMporConventionsFromFile(const std::string& fileName);
148+
void setIborFallbackConfig(const std::string& xml);
144149
void setIborFallbackConfig(const std::string& xml);
145150
void setIborFallbackConfigFromFile(const std::string& fileName);
146151
void setCurveConfigs(const std::string& xml, std::string id = std::string());

ORE-SWIG/OREData-SWIG/SWIG/ored_parsers.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ using ore::data::parseBusinessDayConvention;
7474
using ore::data::parseDate;
7575
using ore::data::fxDominance;
7676
using ore::data::isGenericIborIndex;
77+
using ore::data::calculateMporDate;
7778
%}
7879
bool isGenericIborIndex(const std::string& indexName);
7980
ext::shared_ptr<IborIndex> parseIborIndex(const std::string& s,
@@ -103,6 +104,7 @@ QuantLib::Settlement::Type parseSettlementType(const std::string& s);
103104
QuantLib::Exercise::Type parseExerciseType(const std::string& s);
104105
QuantLib::Option::Type parseOptionType(const std::string& s);
105106
QuantLib::Date parseDate(const std::string& s);
107+
QuantLib::Date calculateMporDate(const QuantLib::Size& mporDays, QuantLib::Date asOf = QuantLib::Date(), std::string mporCalendar = "US");
106108

107109
%template(StringCalMap) std::map<std::string, Calendar>;
108110

OREAnalytics/orea/app/analytics/pnlexplainanalytic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void PnlExplainAnalyticImpl::runAnalytic(const QuantLib::ext::shared_ptr<ore::da
135135
t0SimMarket->scenarioGenerator() = sgen;
136136

137137
// use difference scenarios for par sensi pnl explain
138-
zeroScenarios->setGenerateDifferenceScenarios(t0SimMarket->useSpreadedTermStructures());
138+
zeroScenarios->setGenerateDifferenceScenarios(true);
139139

140140
QL_REQUIRE(parSensiAnalysis, "Par Sensi Analysis required");
141141
auto parScenarios = QuantLib::ext::make_shared<ZeroToParScenarioGenerator>(zeroScenarios, t0SimMarket,

OREAnalytics/orea/app/analyticsmanager.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,22 @@ void AnalyticsManager::toFile(const ore::analytics::Analytic::analytic_reports&
280280

281281
// attach a suffix only if it does not have one already
282282
string suffix = "";
283-
if (!endsWith(fileName,".csv") && !endsWith(fileName, ".txt"))
284-
suffix = ".csv";
285283
std::string fullFileName = outputPath + "/" + fileName + suffix;
286-
287-
report->toFile(fullFileName, sep, commentCharacter, quoteChar, nullString,
288-
lowerHeaderReportNames.find(reportName) != lowerHeaderReportNames.end());
284+
if (!endsWith(fileName,".csv") && !endsWith(fileName, ".txt") && !endsWith(fileName, ".gz")){
285+
suffix = ".csv";
286+
fullFileName = outputPath + "/" + fileName + suffix;
287+
report->toFile(fullFileName, sep, commentCharacter, quoteChar, nullString,
288+
lowerHeaderReportNames.find(reportName) != lowerHeaderReportNames.end());
289+
}else if(endsWith(fileName,".gz")){
290+
fullFileName = outputPath + "/" + fileName;
291+
report->toZip(fullFileName, sep, commentCharacter, quoteChar, nullString,
292+
lowerHeaderReportNames.find(reportName) != lowerHeaderReportNames.end());
293+
}else{
294+
fullFileName = outputPath + "/" + fileName + suffix;
295+
report->toFile(fullFileName, sep, commentCharacter, quoteChar, nullString,
296+
lowerHeaderReportNames.find(reportName) != lowerHeaderReportNames.end());
297+
}
298+
289299
LOG("report " << reportName << " written to " << fullFileName);
290300
}
291301
}

OREAnalytics/orea/app/inputparameters.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,26 @@ vector<string> getFileNames(const string& fileString, const std::filesystem::pat
6767
InputParameters::InputParameters() {
6868
iborFallbackConfig_ = QuantLib::ext::make_shared<IborFallbackConfig>(IborFallbackConfig::defaultConfig());
6969
simmBucketMapper_ = QuantLib::ext::make_shared<SimmBucketMapperBase>();
70-
loadParameters();
70+
}
71+
72+
void InputParameters::loadParameters() {
73+
74+
// load Override parameters
75+
QuantLib::ext::shared_ptr<CurveConfigurations> ccOverride;
76+
loadParameterXML<CurveConfigurations>(ccOverride, "setup", "curveConfigOverride");
77+
if (ccOverride)
78+
curveConfigs_.setOverride(ccOverride);
79+
80+
QuantLib::ext::shared_ptr<Conventions> conventionsOverride;
81+
loadParameterXML<Conventions>(conventionsOverride, "setup", "conventionsOverride");
82+
if (conventions_ && conventionsOverride)
83+
conventions_->setConventionsOverride(conventionsOverride);
84+
85+
QuantLib::ext::shared_ptr<BasicReferenceDataManager> rdmOverride;
86+
loadParameterXML<BasicReferenceDataManager>(rdmOverride, "setup", "referenceDataOverride");
87+
if (refDataManager_ && rdmOverride)
88+
refDataManager_->setRDMOverride(rdmOverride);
89+
7190
}
7291

7392
bool checkString(const std::string& obj) { return true; }
@@ -150,6 +169,18 @@ void InputParameters::setConventionsFromFile(const std::string& fileName) {
150169
InstrumentConventions::instance().setConventions(conventions_);
151170
}
152171

172+
void InputParameters::setMporConventions(const std::string& xml) {
173+
mporConventions_ = QuantLib::ext::make_shared<Conventions>();
174+
mporConventions_->fromXMLString(xml);
175+
InstrumentConventions::instance().setConventions(mporConventions_, mporDate());
176+
}
177+
178+
void InputParameters::setMporConventionsFromFile(const std::string& fileName) {
179+
mporConventions_ = QuantLib::ext::make_shared<Conventions>();
180+
mporConventions_->fromFile(fileName);
181+
InstrumentConventions::instance().setConventions(mporConventions_, mporDate());
182+
}
183+
153184
void InputParameters::setCurveConfigs(const std::string& xml, std::string id) {
154185
auto curveConfig = QuantLib::ext::make_shared<CurveConfigurations>();
155186
curveConfig->fromXMLString(xml);

OREAnalytics/orea/app/inputparameters.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class InputParameters {
8989
QuantLib::ext::shared_ptr<T>& obj, const std::string& analytic,
9090
const std::string& param, const bool mandatory = false) {
9191
string str = loadParameterXMLString(analytic, param, mandatory);
92+
if (str.empty() && !mandatory)
93+
return false;
9294
obj = QuantLib::ext::make_shared<T>();
9395
obj->fromXMLString(str);
9496
return true;
@@ -132,6 +134,7 @@ class InputParameters {
132134
void setBuildFailedTrades(bool b) { buildFailedTrades_ = b; }
133135
void setObservationModel(const std::string& s) { observationModel_ = s; }
134136
void setImplyTodaysFixings(bool b) { implyTodaysFixings_ = b; }
137+
void setFixingCutOffDate(Date d) { fixingCutOffDate_ = d; }
135138
void setUseAtParCouponsCurves(bool b) { useAtParCouponsCurves_ = b; }
136139
void setUseAtParCouponsTrades(bool b) { useAtParCouponsTrades_ = b; }
137140
void setEnrichIndexFixings(bool b) { enrichIndexFixings_ = b; }
@@ -151,6 +154,8 @@ class InputParameters {
151154
void setConventions(const std::string& xml);
152155
void setConventions(const QuantLib::ext::shared_ptr<Conventions>& convs);
153156
void setConventionsFromFile(const std::string& fileName);
157+
void setMporConventions(const std::string& xml);
158+
void setMporConventionsFromFile(const std::string& fileName);
154159
void setIborFallbackConfig(const std::string& xml);
155160
void setIborFallbackConfigFromFile(const std::string& fileName);
156161
void setBaselTrafficLightConfig(const std::string& xml);
@@ -611,6 +616,7 @@ class InputParameters {
611616
bool buildFailedTrades() const { return buildFailedTrades_; }
612617
const std::string& observationModel() const { return observationModel_; }
613618
bool implyTodaysFixings() const { return implyTodaysFixings_; }
619+
Date fixingCutOffDate() const { return fixingCutOffDate_; }
614620
bool useAtParCouponsCurves() const { return useAtParCouponsCurves_; }
615621
bool useAtParCouponsTrades() const { return useAtParCouponsTrades_; }
616622
bool enrichIndexFixings() const { return enrichIndexFixings_; }
@@ -620,6 +626,7 @@ class InputParameters {
620626
const std::string& marketConfig(const std::string& context);
621627
const QuantLib::ext::shared_ptr<ore::data::BasicReferenceDataManager>& refDataManager() const { return refDataManager_; }
622628
const QuantLib::ext::shared_ptr<ore::data::Conventions>& conventions() const { return conventions_; }
629+
const QuantLib::ext::shared_ptr<ore::data::Conventions>& mporConventions() const { return mporConventions_; }
623630
const QuantLib::ext::shared_ptr<ore::data::IborFallbackConfig>& iborFallbackConfig() const { return iborFallbackConfig_; }
624631
const QuantLib::ext::shared_ptr<ore::data::BaselTrafficLightData>& baselTrafficLightConfig() const { return baselTrafficLightConfig_; }
625632

@@ -1072,7 +1079,7 @@ class InputParameters {
10721079
*************************************/
10731080
const std::set<std::string>& analytics() const { return analytics_; }
10741081

1075-
virtual void loadParameters(){}
1082+
virtual void loadParameters();
10761083
virtual void writeOutParameters(){}
10771084

10781085
protected:
@@ -1104,6 +1111,7 @@ class InputParameters {
11041111
bool buildFailedTrades_ = true;
11051112
std::string observationModel_ = "None";
11061113
bool implyTodaysFixings_ = false;
1114+
Date fixingCutOffDate_;
11071115
bool useAtParCouponsCurves_ = true;
11081116
bool useAtParCouponsTrades_ = true;
11091117
bool enrichIndexFixings_ = false;
@@ -1117,7 +1125,7 @@ class InputParameters {
11171125
std::map<std::string, std::string> marketConfigs_;
11181126
QuantLib::ext::shared_ptr<ore::data::BasicReferenceDataManager> refDataManager_;
11191127
QuantLib::ext::shared_ptr<ore::data::BaselTrafficLightData> baselTrafficLightConfig_;
1120-
QuantLib::ext::shared_ptr<ore::data::Conventions> conventions_;
1128+
QuantLib::ext::shared_ptr<ore::data::Conventions> conventions_, mporConventions_;
11211129
QuantLib::ext::shared_ptr<ore::data::IborFallbackConfig> iborFallbackConfig_;
11221130
CurveConfigurationsManager curveConfigs_;
11231131
QuantLib::ext::shared_ptr<ore::data::CalendarAdjustmentConfig> calendarAdjustment_;

0 commit comments

Comments
 (0)