Skip to content

Commit 72f4eee

Browse files
Merge remote-tracking branch 'origin/master' into github_modules
2 parents 46d6a92 + e782d18 commit 72f4eee

17 files changed

Lines changed: 372 additions & 226 deletions

Docs/UserGuide/tradedata/bondForward_refdata.tex

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ \subsubsection{Bond Forward / T-Lock / J-Lock (using ref. data)}
4545
true). Exactly one of the fields Amount, LockRate must be given. In case the LockRate is given, the Settlement
4646
must be set to Cash. If Settlement is not given, it defaults to Cash in this case. \\
4747
Allowable values: Any non-negative real number. The LockRate is expressed in decimal form, eg 0.05 is a rate of 5\%
48+
\item dv01 [Optional]: When the LockRate is given, it is possible to implement a contractual DV01 instead of deriving it from the bond price. \\
49+
Allowable values: Any positive real number. E.G If the dPdY is given then dv01=10000*dPdY/N.
4850
\item LockRateDayCounter [Optional]: The day counter w.r.t. which the lock rate is expressed. Optional, defaults to A360. \\
4951
Allowable values: see table \ref{tab:daycount}
5052
\item SettlementDirty [Optional]: A flag that determines whether the settlement amount {({\tt Amount})} reflects
@@ -110,3 +112,23 @@ \subsubsection{Bond Forward / T-Lock / J-Lock (using ref. data)}
110112
\caption{Forward Bond Date (T-Lock)}
111113
\label{lst:forward_bond_refdata_tlock}
112114
\end{listing}
115+
116+
\begin{listing}[H]
117+
\begin{minted}[fontsize=\small]{xml}
118+
<ForwardBondData>
119+
<BondData>
120+
<SecurityId>ISIN:XS1234567890</SecurityId>
121+
<BondNotional>100000</BondNotional>
122+
</BondData>
123+
<SettlementData>
124+
<ForwardMaturityDate>20160808</ForwardMaturityDate>
125+
<ForwardSettlementDate>20160810</ForwardSettlementDate>
126+
<LockRate>0.02365</LockRate>
127+
<dv01>0.8</dv01>
128+
</SettlementData>
129+
<LongInForward>true</LongInForward>
130+
</ForwardBondData>
131+
\end{minted}
132+
\caption{Forward Bond Date (T-Lock) with DV01}
133+
\label{lst:forward_bond_refdata_tlock_dv01}
134+
\end{listing}

OREAnalytics/CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ if(MSVC)
1616
add_compile_definitions(BOOST_IOSTREAMS_NO_LIB)
1717
endif()
1818

19-
if(ORE_USE_ZLIB)
20-
find_package(ZLIB REQUIRED)
21-
endif()
22-
19+
SET(COMPONENT_LIST date_time filesystem iostreams regex serialization system timer thread)
2320
if (ORE_BUILD_TESTS)
24-
SET(COMPONENTS_CONDITIONAL "unit_test_framework")
25-
else()
26-
SET(COMPONENTS_CONDITIONAL "")
21+
LIST(APPEND COMPONENT_LIST unit_test_framework)
22+
endif()
23+
if(MSVC AND ORE_USE_ZLIB)
24+
LIST(APPEND COMPONENT_LIST zlib)
2725
endif()
28-
find_package (Boost REQUIRED COMPONENTS ${COMPONENTS_CONDITIONAL} regex date_time thread serialization system filesystem timer iostreams OPTIONAL_COMPONENTS chrono)
26+
find_package (Boost REQUIRED COMPONENTS ${COMPONENT_LIST} OPTIONAL_COMPONENTS chrono)
2927
if (ORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER AND UNIX AND NOT APPLE)
3028
find_library(RT_LIBRARY rt REQUIRED)
3129
endif()

OREAnalytics/orea/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ target_link_libraries(${OREA_LIB_NAME} ${QLE_LIB_NAME})
176176
target_link_libraries(${OREA_LIB_NAME} ${ORED_LIB_NAME})
177177
target_link_libraries(${OREA_LIB_NAME} ${Boost_LIBRARIES})
178178
if(ZLIB_FOUND)
179-
target_link_libraries(${OREA_LIB_NAME} ZLIB::ZLIB)
180179
add_definitions(-DORE_USE_ZLIB)
181180
endif()
182181

OREAnalytics/orea/app/oreapp.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -234,47 +234,47 @@ void OREApp::analytics() {
234234

235235
// Read all inputs from params and files referenced in params
236236
CONSOLEW("Loading inputs");
237-
auto inputs = boost::make_shared<InputParameters>();
238-
buildInputParameters(inputs, params_);
237+
inputs_ = boost::make_shared<InputParameters>();
238+
buildInputParameters(inputs_, params_);
239239
auto outputs = boost::make_shared<OutputParameters>(params_);
240240
CONSOLE("OK");
241241

242242
// Set global evaluation date, though already set in the OREAppInputParameters c'tor
243-
Settings::instance().evaluationDate() = inputs->asof();
243+
Settings::instance().evaluationDate() = inputs_->asof();
244244

245245
// FIXME
246-
GlobalPseudoCurrencyMarketParameters::instance().set(inputs->pricingEngine()->globalParameters());
246+
GlobalPseudoCurrencyMarketParameters::instance().set(inputs_->pricingEngine()->globalParameters());
247247

248248
// Initialize the global conventions
249-
InstrumentConventions::instance().setConventions(inputs->conventions());
249+
InstrumentConventions::instance().setConventions(inputs_->conventions());
250250

251251
// Create a market data loader that reads market data, fixings, dividends from csv files
252252
auto csvLoader = buildCsvLoader(params_);
253-
auto loader = boost::make_shared<MarketDataCsvLoader>(inputs, csvLoader);
253+
auto loader = boost::make_shared<MarketDataCsvLoader>(inputs_, csvLoader);
254254

255255
// Create the analytics manager
256-
analyticsManager_ = boost::make_shared<AnalyticsManager>(inputs, loader);
256+
analyticsManager_ = boost::make_shared<AnalyticsManager>(inputs_, loader);
257257
LOG("Available analytics: " << to_string(analyticsManager_->validAnalytics()));
258258
CONSOLEW("Requested analytics");
259-
CONSOLE(to_string(inputs->analytics()));
260-
LOG("Requested analytics: " << to_string(inputs->analytics()));
259+
CONSOLE(to_string(inputs_->analytics()));
260+
LOG("Requested analytics: " << to_string(inputs_->analytics()));
261261

262262
// Run the requested analytics
263-
analyticsManager_->runAnalytics(inputs->analytics());
263+
analyticsManager_->runAnalytics(inputs_->analytics());
264264

265265
// Write reports to files in the results path
266266
Analytic::analytic_reports reports = analyticsManager_->reports();
267267
analyticsManager_->toFile(reports,
268-
inputs->resultsPath().string(), outputs->fileNameMap(),
269-
inputs->csvSeparator(), inputs->csvCommentCharacter(),
270-
inputs->csvQuoteChar(), inputs->reportNaString());
268+
inputs_->resultsPath().string(), outputs->fileNameMap(),
269+
inputs_->csvSeparator(), inputs_->csvCommentCharacter(),
270+
inputs_->csvQuoteChar(), inputs_->reportNaString());
271271

272272
// Write npv cube(s)
273273
for (auto a : analyticsManager_->npvCubes()) {
274274
for (auto b : a.second) {
275275
LOG("write npv cube " << b.first);
276276
string reportName = b.first;
277-
std::string fileName = inputs->resultsPath().string() + "/" + outputs->outputFileName(reportName, "dat");
277+
std::string fileName = inputs_->resultsPath().string() + "/" + outputs->outputFileName(reportName, "dat");
278278
LOG("write npv cube " << reportName << " to file " << fileName);
279279
saveCube(fileName, *b.second);
280280
}
@@ -284,7 +284,7 @@ void OREApp::analytics() {
284284
for (auto a : analyticsManager_->mktCubes()) {
285285
for (auto b : a.second) {
286286
string reportName = b.first;
287-
std::string fileName = inputs->resultsPath().string() + "/" + outputs->outputFileName(reportName, "dat");
287+
std::string fileName = inputs_->resultsPath().string() + "/" + outputs->outputFileName(reportName, "dat");
288288
LOG("write market cube " << reportName << " to file " << fileName);
289289
saveAggregationScenarioData(fileName, *b.second);
290290
}

OREAnalytics/orea/app/oreapp.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class OREApp {
8888
buildEngineFactoryFromXMLString(const boost::shared_ptr<ore::data::Market>& market,
8989
const std::string& pricingEngineXML, const bool generateAdditionalResults = false);
9090

91+
const boost::shared_ptr<InputParameters>& getInputs() const { return inputs_; }
92+
9193
std::set<std::string> getAnalyticTypes();
9294
std::set<std::string> getSupportedAnalyticTypes();
9395
const boost::shared_ptr<Analytic>& getAnalytic(std::string type);

OREData/ored/portfolio/forwardbond.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void ForwardBond::build(const boost::shared_ptr<EngineFactory>& engineFactory) {
7575
}
7676
Real amount = amount_.empty() ? Null<Real>() : parseReal(amount_);
7777
Real lockRate = lockRate_.empty() ? Null<Real>() : parseReal(lockRate_);
78+
Real dv01 = dv01_.empty() ? Null<Real>() : parseReal(dv01_);
7879
DayCounter lockRateDayCounter = lockRateDayCounter_.empty() ? Actual360() : parseDayCounter(lockRateDayCounter_);
7980
bool settlementDirty = settlementDirty_.empty() ? true : parseBool(settlementDirty_);
8081
Real compensationPayment = parseReal(compensationPayment_);
@@ -84,6 +85,7 @@ void ForwardBond::build(const boost::shared_ptr<EngineFactory>& engineFactory) {
8485
QL_REQUIRE((amount == Null<Real>() && lockRate != Null<Real>()) ||
8586
(amount != Null<Real>() && lockRate == Null<Real>()),
8687
"ForwardBond: exactly one of Amount of LockRate must be given");
88+
QL_REQUIRE(dv01 >= 0.0, "negative DV01 given");
8789
QL_REQUIRE(compensationPaymentDate <= fwdMaturityDate, "Premium cannot be paid after forward contract maturity");
8890

8991
if (lockRate != Null<Real>())
@@ -138,7 +140,7 @@ void ForwardBond::build(const boost::shared_ptr<EngineFactory>& engineFactory) {
138140
: boost::make_shared<QuantExt::ForwardBond>(bond, lockRate, lockRateDayCounter, longInForward,
139141
fwdMaturityDate, fwdSettlementDate, isPhysicallySettled,
140142
settlementDirty, compensationPayment,
141-
compensationPaymentDate, bondData_.bondNotional());
143+
compensationPaymentDate, bondData_.bondNotional(), dv01);
142144

143145
boost::shared_ptr<fwdBondEngineBuilder> fwdBondBuilder =
144146
boost::dynamic_pointer_cast<fwdBondEngineBuilder>(builder_fwd);
@@ -177,6 +179,7 @@ void ForwardBond::fromXML(XMLNode* node) {
177179
lockRate_ = XMLUtils::getChildValue(fwdSettlementNode, "LockRate", false);
178180
lockRateDayCounter_ = XMLUtils::getChildValue(fwdSettlementNode, "LockRateDayCounter", false);
179181
settlementDirty_ = XMLUtils::getChildValue(fwdSettlementNode, "SettlementDirty", false);
182+
dv01_ = XMLUtils::getChildValue(fwdSettlementNode, "dv01", false);
180183

181184
XMLNode* fwdPremiumNode = XMLUtils::getChildNode(fwdBondNode, "PremiumData");
182185
if (fwdPremiumNode) {
@@ -207,6 +210,8 @@ XMLNode* ForwardBond::toXML(XMLDocument& doc) {
207210
XMLUtils::addChild(doc, fwdSettlementNode, "Amount", amount_);
208211
if (!lockRate_.empty())
209212
XMLUtils::addChild(doc, fwdSettlementNode, "LockRate", lockRate_);
213+
if (!dv01_.empty())
214+
XMLUtils::addChild(doc, fwdSettlementNode, "dv01", dv01_);
210215
if (!lockRateDayCounter_.empty())
211216
XMLUtils::addChild(doc, fwdSettlementNode, "LockRateDayCounter", lockRateDayCounter_);
212217
if (!settlementDirty_.empty())

OREData/ored/portfolio/forwardbond.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class ForwardBond : public Trade {
3636
//! Constructor taking an envelope and bond data
3737
ForwardBond(Envelope env, const BondData& bondData, string fwdMaturityDate, string fwdSettlementDate,
3838
string settlement, string amount, string lockRate, string lockRateDayCounter, string settlementDirty,
39-
string compensationPayment, string compensationPaymentDate, string longInForward)
39+
string compensationPayment, string compensationPaymentDate, string longInForward, string dv01 = string())
4040
: Trade("ForwardBond", env), originalBondData_(bondData), bondData_(bondData),
4141
fwdMaturityDate_(fwdMaturityDate), fwdSettlementDate_(fwdSettlementDate), settlement_(settlement),
4242
amount_(amount), lockRate_(lockRate), lockRateDayCounter_(lockRateDayCounter),
4343
settlementDirty_(settlementDirty), compensationPayment_(compensationPayment),
44-
compensationPaymentDate_(compensationPaymentDate), longInForward_(longInForward) {}
44+
compensationPaymentDate_(compensationPaymentDate), longInForward_(longInForward), dv01_(dv01) {}
4545

4646
virtual void build(const boost::shared_ptr<EngineFactory>&) override;
4747

@@ -65,6 +65,7 @@ class ForwardBond : public Trade {
6565
const string& compensationPayment() const { return compensationPayment_; }
6666
const string& compensationPaymentDate() const { return compensationPaymentDate_; }
6767
const string& longInForward() const { return longInForward_; }
68+
const string& dv01() const { return dv01_; }
6869

6970
protected:
7071
BondData originalBondData_, bondData_;
@@ -80,6 +81,7 @@ class ForwardBond : public Trade {
8081
string compensationPayment_;
8182
string compensationPaymentDate_;
8283
string longInForward_;
84+
string dv01_;
8385
};
8486
} // namespace data
8587
} // namespace ore

0 commit comments

Comments
 (0)