Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
todaysmarket.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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#include <boost/test/unit_test.hpp>
31#include <oret/toplevelfixture.hpp>
32#include <ql/time/calendars/all.hpp>
33#include <ql/time/daycounters/actual360.hpp>
34#include <ql/utilities/dataformatters.hpp>
35
36#include <boost/algorithm/string.hpp>
37#include <boost/assign/list_of.hpp>
38#include <map>
39
40using namespace QuantLib;
41using namespace QuantExt;
42using namespace boost::unit_test_framework;
43using namespace std;
44using namespace ore;
45using namespace ore::data;
46
47using ore::test::TopLevelFixture;
48
49namespace {
50
51class MarketDataLoader : public Loader {
52public:
53 MarketDataLoader();
54 std::vector<QuantLib::ext::shared_ptr<MarketDatum>> loadQuotes(const QuantLib::Date&) const override;
55 std::set<Fixing> loadFixings() const override { return fixings_; }
56 std::set<QuantExt::Dividend> loadDividends() const override { return dividends_; }
57 void add(QuantLib::Date date, const string& name, QuantLib::Real value) {}
58 void addFixing(QuantLib::Date date, const string& name, QuantLib::Real value) {}
59 void addDividend(const QuantExt::Dividend& div) {}
60
61private:
62 std::map<QuantLib::Date, std::vector<QuantLib::ext::shared_ptr<MarketDatum>>> data_;
63 std::set<Fixing> fixings_;
64 std::set<QuantExt::Dividend> dividends_;
65};
66
67vector<QuantLib::ext::shared_ptr<MarketDatum>> MarketDataLoader::loadQuotes(const Date& d) const {
68 auto it = data_.find(d);
69 QL_REQUIRE(it != data_.end(), "Loader has no data for date " << d);
70 return it->second;
71}
72
73MarketDataLoader::MarketDataLoader() {
74 // clang-format off
75 vector<string> data = boost::assign::list_of
76 // borrow spread curve
77 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/2Y -0.0010")
78 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/5Y -0.0010")
79 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/10Y -0.0010")
80 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/20Y -0.0010")
81 // lending spread curve
82 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/2Y 0.0050")
83 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/5Y 0.0050")
84 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/10Y 0.0050")
85 ("20160226 ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/20Y 0.0050")
86 // Eonia curve
87 ("20160226 MM/RATE/EUR/0D/1D -0.0025")
88 ("20160226 IR_SWAP/RATE/EUR/0D/1D/1D -0.0025")
89 ("20160226 IR_SWAP/RATE/EUR/0D/1D/2D -0.0027")
90 ("20160226 IR_SWAP/RATE/EUR/2D/1D/3D -0.003")
91 ("20160226 IR_SWAP/RATE/EUR/2D/1D/1W -0.00245")
92 ("20160226 IR_SWAP/RATE/EUR/2D/1D/2W -0.00245")
93 ("20160226 IR_SWAP/RATE/EUR/2D/1D/3W -0.00245")
94 ("20160226 IR_SWAP/RATE/EUR/2D/1D/1M -0.0030275")
95 ("20160226 IR_SWAP/RATE/EUR/2D/1D/2M -0.003335")
96 ("20160226 IR_SWAP/RATE/EUR/2D/1D/3M -0.003535")
97 ("20160226 IR_SWAP/RATE/EUR/2D/1D/4M -0.00365")
98 ("20160226 IR_SWAP/RATE/EUR/2D/1D/5M -0.0037925")
99 ("20160226 IR_SWAP/RATE/EUR/2D/1D/6M -0.0037975")
100 ("20160226 IR_SWAP/RATE/EUR/2D/1D/7M -0.00402")
101 ("20160226 IR_SWAP/RATE/EUR/2D/1D/8M -0.0040475")
102 ("20160226 IR_SWAP/RATE/EUR/2D/1D/9M -0.0041875")
103 ("20160226 IR_SWAP/RATE/EUR/2D/1D/10M -0.004245")
104 ("20160226 IR_SWAP/RATE/EUR/2D/1D/11M -0.00431")
105 ("20160226 IR_SWAP/RATE/EUR/2D/1D/1Y -0.00436")
106 ("20160226 IR_SWAP/RATE/EUR/2D/1D/2Y -0.004645")
107 ("20160226 IR_SWAP/RATE/EUR/2D/1D/3Y -0.0043525")
108 ("20160226 IR_SWAP/RATE/EUR/2D/1D/4Y -0.00375")
109 ("20160226 IR_SWAP/RATE/EUR/2D/1D/5Y -0.0029")
110 ("20160226 IR_SWAP/RATE/EUR/2D/1D/6Y -0.00185")
111 ("20160226 IR_SWAP/RATE/EUR/2D/1D/7Y -0.00067")
112 ("20160226 IR_SWAP/RATE/EUR/2D/1D/8Y 0.0005")
113 ("20160226 IR_SWAP/RATE/EUR/2D/1D/9Y 0.00162")
114 ("20160226 IR_SWAP/RATE/EUR/2D/1D/10Y 0.0026375")
115 // USD Fed Funds curve
116 ("20160226 MM/RATE/USD/0D/1D 0.00448")
117 ("20160226 IR_SWAP/RATE/USD/2D/1D/1M 0.004458")
118 ("20160226 IR_SWAP/RATE/USD/2D/1D/3M 0.004851")
119 ("20160226 IR_SWAP/RATE/USD/2D/1D/6M 0.005237")
120 ("20160226 IR_SWAP/RATE/USD/2D/1D/9M 0.005471")
121 ("20160226 IR_SWAP/RATE/USD/2D/1D/1Y 0.005614")
122 ("20160226 IR_SWAP/RATE/USD/2D/1D/2Y 0.006433")
123 ("20160226 IR_SWAP/RATE/USD/2D/1D/3Y 0.007101")
124 ("20160226 IR_SWAP/RATE/USD/2D/1D/4Y 0.008264")
125 ("20160226 IR_SWAP/RATE/USD/2D/1D/5Y 0.009269")
126 ("20160226 IR_SWAP/RATE/USD/2D/1D/7Y 0.011035")
127 ("20160226 IR_SWAP/RATE/USD/2D/1D/10Y 0.013318")
128 ("20160226 IR_SWAP/RATE/USD/2D/1D/12Y 0.01459")
129 ("20160226 IR_SWAP/RATE/USD/2D/1D/15Y 0.016029")
130 ("20160226 IR_SWAP/RATE/USD/2D/1D/20Y 0.01734")
131 ("20160226 IR_SWAP/RATE/USD/2D/1D/25Y 0.01804")
132 ("20160226 IR_SWAP/RATE/USD/2D/1D/30Y 0.018326")
133 ("20160226 IR_SWAP/RATE/USD/2D/1D/50Y 0.0182")
134 // USD 3M curve
135 ("20160226 MM/RATE/USD/2D/3M 0.007961")
136 ("20160226 FRA/RATE/USD/3M/3M 0.008132")
137 ("20160226 FRA/RATE/USD/6M/3M 0.00858")
138 ("20160226 FRA/RATE/USD/9M/3M 0.009141")
139 ("20160226 FRA/RATE/USD/1Y/3M 0.009594")
140 ("20160226 IR_SWAP/RATE/USD/2D/3M/2Y 0.009268")
141 ("20160226 IR_SWAP/RATE/USD/2D/3M/3Y 0.010244")
142 ("20160226 IR_SWAP/RATE/USD/2D/3M/4Y 0.011307")
143 ("20160226 IR_SWAP/RATE/USD/2D/3M/5Y 0.012404")
144 ("20160226 IR_SWAP/RATE/USD/2D/3M/6Y 0.013502")
145 ("20160226 IR_SWAP/RATE/USD/2D/3M/7Y 0.014357")
146 ("20160226 IR_SWAP/RATE/USD/2D/3M/8Y 0.015181")
147 ("20160226 IR_SWAP/RATE/USD/2D/3M/9Y 0.016063")
148 ("20160226 IR_SWAP/RATE/USD/2D/3M/10Y 0.016805")
149 ("20160226 IR_SWAP/RATE/USD/2D/3M/12Y 0.018038")
150 ("20160226 IR_SWAP/RATE/USD/2D/3M/15Y 0.019323")
151 ("20160226 IR_SWAP/RATE/USD/2D/3M/20Y 0.020666")
152 ("20160226 IR_SWAP/RATE/USD/2D/3M/25Y 0.021296")
153 ("20160226 IR_SWAP/RATE/USD/2D/3M/30Y 0.021745")
154 ("20160226 IR_SWAP/RATE/USD/2D/3M/40Y 0.021951")
155 ("20160226 IR_SWAP/RATE/USD/2D/3M/50Y 0.021741")
156 // USD lognormal swaption quotes
157 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/10Y/ATM 0.548236")
158 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/10Y/ATM 0.279322")
159 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/10Y/ATM 0.343264")
160 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/10Y/ATM 0.306509")
161 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/10Y/ATM 0.378516")
162 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/10Y/ATM 0.541913")
163 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/10Y/ATM 0.451828")
164 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/10Y/ATM 0.522381")
165 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/10Y/ATM 0.485922")
166 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/10Y/ATM 0.413209")
167 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/10Y/ATM 0.279684")
168 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/10Y/ATM 0.280131")
169 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/10Y/ATM 0.542948")
170 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/10Y/ATM 0.428622")
171 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/15Y/ATM 0.478372")
172 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/15Y/ATM 0.471117")
173 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/15Y/ATM 0.456872")
174 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/15Y/ATM 0.273396")
175 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/15Y/ATM 0.475296")
176 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/15Y/ATM 0.265159")
177 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/15Y/ATM 0.318263")
178 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/15Y/ATM 0.383914")
179 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/15Y/ATM 0.28198")
180 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/15Y/ATM 0.433144")
181 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/15Y/ATM 0.262587")
182 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/15Y/ATM 0.405347")
183 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/15Y/ATM 0.370537")
184 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/15Y/ATM 0.345499")
185 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/1Y/ATM 0.606815")
186 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/1Y/ATM 0.731808")
187 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/1Y/ATM 0.780075")
188 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/1Y/ATM 0.562741")
189 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/1Y/ATM 0.38573")
190 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/1Y/ATM 0.475593")
191 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/1Y/ATM 0.528012")
192 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/1Y/ATM 0.277531")
193 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/1Y/ATM 0.32467")
194 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/1Y/ATM 0.666817")
195 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/1Y/ATM 0.296386")
196 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/1Y/ATM 0.635173")
197 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/1Y/ATM 0.289454")
198 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/1Y/ATM 0.742497")
199 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/20Y/ATM 0.383058")
200 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/20Y/ATM 0.404186")
201 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/20Y/ATM 0.259696")
202 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/20Y/ATM 0.303547")
203 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/20Y/ATM 0.270757")
204 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/20Y/ATM 0.438879")
205 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/20Y/ATM 0.330822")
206 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/20Y/ATM 0.256717")
207 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/20Y/ATM 0.444512")
208 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/20Y/ATM 0.427477")
209 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/20Y/ATM 0.274453")
210 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/20Y/ATM 0.442455")
211 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/20Y/ATM 0.363194")
212 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/20Y/ATM 0.350917")
213 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/25Y/ATM 0.271733")
214 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/25Y/ATM 0.259564")
215 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/25Y/ATM 0.355165")
216 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/25Y/ATM 0.343885")
217 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/25Y/ATM 0.271644")
218 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/25Y/ATM 0.431135")
219 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/25Y/ATM 0.427615")
220 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/25Y/ATM 0.433391")
221 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/25Y/ATM 0.262762")
222 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/25Y/ATM 0.304406")
223 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/25Y/ATM 0.372194")
224 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/25Y/ATM 0.395398")
225 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/25Y/ATM 0.326927")
226 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/25Y/ATM 0.41513")
227 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/2Y/ATM 0.312514")
228 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/2Y/ATM 0.643934")
229 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/2Y/ATM 0.751427")
230 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/2Y/ATM 0.282604")
231 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/2Y/ATM 0.725701")
232 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/2Y/ATM 0.45533")
233 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/2Y/ATM 0.750588")
234 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/2Y/ATM 0.528093")
235 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/2Y/ATM 0.578914")
236 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/2Y/ATM 0.276083")
237 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/2Y/ATM 0.752889")
238 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/2Y/ATM 0.380044")
239 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/2Y/ATM 0.722185")
240 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/2Y/ATM 0.296735")
241 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/30Y/ATM 0.418857")
242 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/30Y/ATM 0.367358")
243 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/30Y/ATM 0.2718")
244 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/30Y/ATM 0.407524")
245 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/30Y/ATM 0.263453")
246 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/30Y/ATM 0.387553")
247 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/30Y/ATM 0.35077")
248 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/30Y/ATM 0.260409")
249 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/30Y/ATM 0.339702")
250 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/30Y/ATM 0.422241")
251 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/30Y/ATM 0.42532")
252 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/30Y/ATM 0.272841")
253 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/30Y/ATM 0.322472")
254 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/30Y/ATM 0.300322")
255 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/3Y/ATM 0.376155")
256 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/3Y/ATM 0.504808")
257 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/3Y/ATM 0.443113")
258 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/3Y/ATM 0.545964")
259 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/3Y/ATM 0.770113")
260 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/3Y/ATM 0.283092")
261 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/3Y/ATM 0.275506")
262 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/3Y/ATM 0.293776")
263 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/3Y/ATM 0.598626")
264 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/3Y/ATM 0.659808")
265 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/3Y/ATM 0.760853")
266 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/3Y/ATM 0.312797")
267 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/3Y/ATM 0.764493")
268 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/3Y/ATM 0.741367")
269 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/4Y/ATM 0.483701")
270 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/4Y/ATM 0.626629")
271 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/4Y/ATM 0.430606")
272 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/4Y/ATM 0.37399")
273 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/4Y/ATM 0.755829")
274 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/4Y/ATM 0.690926")
275 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/4Y/ATM 0.766932")
276 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/4Y/ATM 0.522394")
277 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/4Y/ATM 0.740591")
278 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/4Y/ATM 0.313507")
279 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/4Y/ATM 0.282171")
280 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/4Y/ATM 0.562962")
281 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/4Y/ATM 0.273649")
282 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/4Y/ATM 0.291507")
283 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/5Y/ATM 0.419719")
284 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/5Y/ATM 0.272182")
285 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/5Y/ATM 0.314468")
286 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/5Y/ATM 0.368886")
287 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/5Y/ATM 0.665892")
288 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/5Y/ATM 0.738673")
289 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/5Y/ATM 0.282147")
290 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/5Y/ATM 0.466931")
291 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/5Y/ATM 0.289319")
292 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/5Y/ATM 0.49694")
293 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/5Y/ATM 0.719629")
294 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/5Y/ATM 0.709472")
295 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/5Y/ATM 0.535164")
296 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/5Y/ATM 0.594412")
297 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/6Y/ATM 0.478518")
298 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/6Y/ATM 0.512654")
299 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/6Y/ATM 0.627983")
300 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/6Y/ATM 0.286969")
301 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/6Y/ATM 0.675274")
302 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/6Y/ATM 0.561415")
303 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/6Y/ATM 0.36362")
304 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/6Y/ATM 0.452013")
305 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/6Y/ATM 0.67379")
306 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/6Y/ATM 0.409059")
307 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/6Y/ATM 0.2763")
308 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/6Y/ATM 0.657404")
309 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/6Y/ATM 0.283231")
310 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/6Y/ATM 0.311968")
311 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/7Y/ATM 0.437809")
312 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/7Y/ATM 0.628908")
313 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/7Y/ATM 0.278409")
314 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/7Y/ATM 0.629572")
315 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/7Y/ATM 0.311755")
316 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/7Y/ATM 0.40233")
317 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/7Y/ATM 0.588402")
318 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/7Y/ATM 0.53681")
319 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/7Y/ATM 0.357638")
320 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/7Y/ATM 0.460946")
321 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/7Y/ATM 0.285254")
322 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/7Y/ATM 0.280821")
323 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/7Y/ATM 0.619567")
324 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/7Y/ATM 0.496016")
325 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/8Y/ATM 0.278576")
326 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/8Y/ATM 0.283873")
327 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/8Y/ATM 0.560732")
328 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/8Y/ATM 0.591543")
329 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/8Y/ATM 0.479076")
330 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/8Y/ATM 0.392865")
331 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/8Y/ATM 0.280426")
332 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/8Y/ATM 0.426418")
333 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/8Y/ATM 0.448315")
334 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/8Y/ATM 0.594923")
335 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/8Y/ATM 0.311033")
336 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/8Y/ATM 0.591289")
337 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/8Y/ATM 0.352116")
338 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/8Y/ATM 0.518648")
339 ("20160226 SWAPTION/RATE_LNVOL/USD/4Y/9Y/ATM 0.438637")
340 ("20160226 SWAPTION/RATE_LNVOL/USD/6M/9Y/ATM 0.566963")
341 ("20160226 SWAPTION/RATE_LNVOL/USD/1M/9Y/ATM 0.56222")
342 ("20160226 SWAPTION/RATE_LNVOL/USD/10Y/9Y/ATM 0.347195")
343 ("20160226 SWAPTION/RATE_LNVOL/USD/1Y/9Y/ATM 0.539202")
344 ("20160226 SWAPTION/RATE_LNVOL/USD/20Y/9Y/ATM 0.281429")
345 ("20160226 SWAPTION/RATE_LNVOL/USD/2Y/9Y/ATM 0.50153")
346 ("20160226 SWAPTION/RATE_LNVOL/USD/5Y/9Y/ATM 0.419976")
347 ("20160226 SWAPTION/RATE_LNVOL/USD/15Y/9Y/ATM 0.308262")
348 ("20160226 SWAPTION/RATE_LNVOL/USD/30Y/9Y/ATM 0.280027")
349 ("20160226 SWAPTION/RATE_LNVOL/USD/3Y/9Y/ATM 0.462502")
350 ("20160226 SWAPTION/RATE_LNVOL/USD/7Y/9Y/ATM 0.384089")
351 ("20160226 SWAPTION/RATE_LNVOL/USD/3M/9Y/ATM 0.569119")
352 ("20160226 SWAPTION/RATE_LNVOL/USD/25Y/9Y/ATM 0.278568")
353 // USD lognormal capfloor quotes
354 ("20160226 CAPFLOOR/RATE_LNVOL/USD/1Y/3M/0/0/0.015 0.44451")
355 ("20160226 CAPFLOOR/RATE_LNVOL/USD/1Y/3M/0/0/0.010 0.447381")
356 ("20160226 CAPFLOOR/RATE_LNVOL/USD/1Y/3M/0/0/0.025 0.452925")
357 ("20160226 CAPFLOOR/RATE_LNVOL/USD/1Y/3M/0/0/0.020 0.450945")
358 ("20160226 CAPFLOOR/RATE_LNVOL/USD/1Y/3M/0/0/0.030 0.447381")
359 ("20160226 CAPFLOOR/RATE_LNVOL/USD/1Y/3M/0/0/0.005 0.570834")
360 ("20160226 CAPFLOOR/RATE_LNVOL/USD/2Y/3M/0/0/0.015 0.484806")
361 ("20160226 CAPFLOOR/RATE_LNVOL/USD/2Y/3M/0/0/0.010 0.51695")
362 ("20160226 CAPFLOOR/RATE_LNVOL/USD/2Y/3M/0/0/0.025 0.459228")
363 ("20160226 CAPFLOOR/RATE_LNVOL/USD/2Y/3M/0/0/0.020 0.468832")
364 ("20160226 CAPFLOOR/RATE_LNVOL/USD/2Y/3M/0/0/0.030 0.440804")
365 ("20160226 CAPFLOOR/RATE_LNVOL/USD/2Y/3M/0/0/0.005 0.661108")
366 ("20160226 CAPFLOOR/RATE_LNVOL/USD/5Y/3M/0/0/0.015 0.5928")
367 ("20160226 CAPFLOOR/RATE_LNVOL/USD/5Y/3M/0/0/0.010 0.670605")
368 ("20160226 CAPFLOOR/RATE_LNVOL/USD/5Y/3M/0/0/0.025 0.50559")
369 ("20160226 CAPFLOOR/RATE_LNVOL/USD/5Y/3M/0/0/0.020 0.54302")
370 ("20160226 CAPFLOOR/RATE_LNVOL/USD/5Y/3M/0/0/0.030 0.472055")
371 ("20160226 CAPFLOOR/RATE_LNVOL/USD/5Y/3M/0/0/0.005 0.87571")
372 ("20160226 CAPFLOOR/RATE_LNVOL/USD/7Y/3M/0/0/0.015 0.584226")
373 ("20160226 CAPFLOOR/RATE_LNVOL/USD/7Y/3M/0/0/0.010 0.686805")
374 ("20160226 CAPFLOOR/RATE_LNVOL/USD/7Y/3M/0/0/0.025 0.470394")
375 ("20160226 CAPFLOOR/RATE_LNVOL/USD/7Y/3M/0/0/0.020 0.518661")
376 ("20160226 CAPFLOOR/RATE_LNVOL/USD/7Y/3M/0/0/0.030 0.431055")
377 ("20160226 CAPFLOOR/RATE_LNVOL/USD/7Y/3M/0/0/0.005 0.931953")
378 ("20160226 CAPFLOOR/RATE_LNVOL/USD/10Y/3M/0/0/0.015 0.54423")
379 ("20160226 CAPFLOOR/RATE_LNVOL/USD/10Y/3M/0/0/0.010 0.65691")
380 ("20160226 CAPFLOOR/RATE_LNVOL/USD/10Y/3M/0/0/0.025 0.423")
381 ("20160226 CAPFLOOR/RATE_LNVOL/USD/10Y/3M/0/0/0.020 0.47358")
382 ("20160226 CAPFLOOR/RATE_LNVOL/USD/10Y/3M/0/0/0.030 0.38394")
383 ("20160226 CAPFLOOR/RATE_LNVOL/USD/10Y/3M/0/0/0.005 0.91791")
384 // equity
385 ("20160226 EQUITY/PRICE/SP5/USD 1500.00")
386 ("20160226 EQUITY_FWD/PRICE/SP5/USD/1Y 1500.00")
387 ("20160226 EQUITY_FWD/PRICE/SP5/USD/20180226 1500.00")
388 ("20160226 EQUITY_DIVIDEND/RATE/SP5/USD/20170226 0.00")
389 ("20160226 EQUITY_DIVIDEND/RATE/SP5/USD/2Y 0.00")
390 ("20160226 EQUITY_OPTION/RATE_LNVOL/SP5/USD/1Y/ATMF 0.25")
391 ("20160226 EQUITY_OPTION/RATE_LNVOL/SP5/USD/2018-02-26/ATMF 0.35")
392 // commodity quotes
393 ("20160226 COMMODITY/PRICE/GOLD/USD 1155.593")
394 ("20160226 COMMODITY_FWD/PRICE/GOLD/USD/2016-08-31 1158.8")
395 ("20160226 COMMODITY_FWD/PRICE/GOLD/USD/2017-02-28 1160.9")
396 ("20160226 COMMODITY_FWD/PRICE/GOLD/USD/2017-08-31 1163.4")
397 ("20160226 COMMODITY_FWD/PRICE/GOLD/USD/2017-12-29 1165.3")
398 ("20160226 COMMODITY_FWD/PRICE/GOLD/USD/2018-12-31 1172.9")
399 ("20160226 COMMODITY_FWD/PRICE/GOLD/USD/2021-12-31 1223")
400 // correlation quotes
401 ("20160226 CORRELATION/RATE/EUR-CMS-10Y/EUR-CMS-2Y/1Y/ATM 0.1")
402 ("20160226 CORRELATION/RATE/EUR-CMS-10Y/EUR-CMS-2Y/2Y/ATM 0.2")
403 ("20160226 CORRELATION/PRICE/USD-CMS-10Y/USD-CMS-2Y/1Y/ATM 0.0038614")
404 ("20160226 CORRELATION/PRICE/USD-CMS-10Y/USD-CMS-2Y/2Y/ATM 0.0105279");
405 // clang-format on
406
407 for (auto s : data) {
408 vector<string> tokens;
409 boost::trim(s);
410 boost::split(tokens, s, boost::is_any_of(" "), boost::token_compress_on);
411
412 QL_REQUIRE(tokens.size() == 3, "Invalid market data line, 3 tokens expected " << s);
413 Date date = parseDate(tokens[0]);
414 const string& key = tokens[1];
415 Real value = parseReal(tokens[2]);
416 data_[date].push_back(parseMarketDatum(date, key, value));
417 }
418}
419
420QuantLib::ext::shared_ptr<TodaysMarketParameters> marketParameters() {
421
422 QuantLib::ext::shared_ptr<TodaysMarketParameters> parameters = QuantLib::ext::make_shared<TodaysMarketParameters>();
423
424 // define three curves
425 map<string, string> mDiscounting = {{"EUR", "Yield/EUR/EUR1D"}, {"USD", "Yield/USD/USD1D"}};
426 parameters->addMarketObject(MarketObject::DiscountCurve, "ois", mDiscounting);
427
428 // define three curves
429 map<string, string> mYield = {{"EUR_LEND", "Yield/EUR/BANK_EUR_LEND"}, {"EUR_BORROW", "Yield/EUR/BANK_EUR_BORROW"}};
430 parameters->addMarketObject(MarketObject::YieldCurve, "ois", mYield);
431
432 map<string, string> mIndex = {
433 {"EUR-EONIA", "Yield/EUR/EUR1D"}, {"USD-FedFunds", "Yield/USD/USD1D"}, {"USD-LIBOR-3M", "Yield/USD/USD3M"}};
434 parameters->addMarketObject(MarketObject::IndexCurve, "ois", mIndex);
435
436 parameters->addMarketObject(MarketObject::SwaptionVol, "ois", {{"USD", "SwaptionVolatility/USD/USD_SW_LN"}});
437 parameters->addMarketObject(MarketObject::CapFloorVol, "ois", {{"USD", "CapFloorVolatility/USD/USD_CF_LN"}});
438
439 map<string, string> swapIndexMap = {{"USD-CMS-1Y", "USD-FedFunds"},
440 {"USD-CMS-30Y", "USD-LIBOR-3M"},
441 {"USD-CMS-2Y", "USD-LIBOR-3M"},
442 {"USD-CMS-10Y", "USD-LIBOR-3M"}};
443 parameters->addMarketObject(MarketObject::SwapIndexCurve, "ois", swapIndexMap);
444
445 map<string, string> equityMap = {{"SP5", "Equity/USD/SP5"}};
446 parameters->addMarketObject(MarketObject::EquityCurve, "ois", equityMap);
447
448 map<string, string> equityVolMap = {{"SP5", "EquityVolatility/USD/SP5"}};
449 parameters->addMarketObject(MarketObject::EquityVol, "ois", equityVolMap);
450
451 parameters->addMarketObject(MarketObject::CommodityCurve, "ois", {{"COMDTY_GOLD_USD", "Commodity/USD/GOLD_USD"}});
452
453 map<string, string> correlationMap = {{"EUR-CMS-10Y/EUR-CMS-2Y", "Correlation/EUR-CORR"},
454 {"USD-CMS-10Y/USD-CMS-2Y", "Correlation/USD-CORR"}};
455 parameters->addMarketObject(MarketObject::Correlation, "ois", correlationMap);
456
457 // all others empty so far
458 map<string, string> emptyMap;
459 parameters->addMarketObject(MarketObject::FXSpot, "ois", emptyMap);
460 parameters->addMarketObject(MarketObject::FXVol, "ois", emptyMap);
461 parameters->addMarketObject(MarketObject::DefaultCurve, "ois", emptyMap);
462
463 // store this set of curves as "default" configuration
464 MarketConfiguration config;
465 config.setId(MarketObject::DiscountCurve, "ois");
466 config.setId(MarketObject::YieldCurve, "ois");
467 config.setId(MarketObject::IndexCurve, "ois");
468 config.setId(MarketObject::SwapIndexCurve, "ois");
469 config.setId(MarketObject::DefaultCurve, "ois");
470 config.setId(MarketObject::SwaptionVol, "ois");
471 config.setId(MarketObject::CapFloorVol, "ois");
472 config.setId(MarketObject::FXSpot, "ois");
473 config.setId(MarketObject::FXVol, "ois");
474 config.setId(MarketObject::EquityCurve, "ois");
475 config.setId(MarketObject::EquityVol, "ois");
476 config.setId(MarketObject::CommodityCurve, "ois");
477 config.setId(MarketObject::Correlation, "ois");
478
479 parameters->addConfiguration("default", config);
480
481 return parameters;
482}
483
484QuantLib::ext::shared_ptr<Conventions> conventions() {
485 QuantLib::ext::shared_ptr<Conventions> conventions(new Conventions());
486
487 QuantLib::ext::shared_ptr<Convention> zeroConv(new ZeroRateConvention("EUR-ZERO-CONVENTIONS-TENOR-BASED", "A365", "TARGET",
488 "Continuous", "Daily", "2", "TARGET", "Following",
489 "false"));
490 conventions->add(zeroConv);
491
492 QuantLib::ext::shared_ptr<Convention> depositConv(new DepositConvention("EUR-EONIA-CONVENTIONS", "EUR-EONIA"));
493 conventions->add(depositConv);
494
495 QuantLib::ext::shared_ptr<Convention> oisConv(new OisConvention("EUR-OIS-CONVENTIONS", "2", "EUR-EONIA", "A360", "TARGET",
496 "1", "false", "Annual", "Following", "Following",
497 "Backward"));
498 conventions->add(oisConv);
499
500 // USD Fed Funds curve conventions
501 conventions->add(QuantLib::ext::make_shared<DepositConvention>("USD-FED-FUNDS-CONVENTIONS", "USD-FedFunds"));
502 conventions->add(QuantLib::ext::make_shared<OisConvention>("USD-OIS-CONVENTIONS", "2", "USD-FedFunds", "A360", "US", "2",
503 "false", "Annual", "Following", "Following", "Backward"));
504
505 // USD 3M curve conventions
506 conventions->add(QuantLib::ext::make_shared<DepositConvention>("USD-LIBOR-CONVENTIONS", "USD-LIBOR"));
507 conventions->add(QuantLib::ext::make_shared<FraConvention>("USD-3M-FRA-CONVENTIONS", "USD-LIBOR-3M"));
508 conventions->add(QuantLib::ext::make_shared<IRSwapConvention>("USD-3M-SWAP-CONVENTIONS", "US", "Semiannual", "MF", "30/360",
509 "USD-LIBOR-3M"));
510
511 // USD swap index conventions
512 conventions->add(QuantLib::ext::make_shared<SwapIndexConvention>("USD-CMS-1Y", "USD-3M-SWAP-CONVENTIONS", "US"));
513 conventions->add(QuantLib::ext::make_shared<SwapIndexConvention>("USD-CMS-30Y", "USD-3M-SWAP-CONVENTIONS", "US"));
514 conventions->add(QuantLib::ext::make_shared<SwapIndexConvention>("USD-CMS-2Y", "USD-3M-SWAP-CONVENTIONS", "US"));
515 conventions->add(QuantLib::ext::make_shared<SwapIndexConvention>("USD-CMS-10Y", "USD-3M-SWAP-CONVENTIONS", "US"));
516
517 // USD CMS spread option conventions
518
519 conventions->add(QuantLib::ext::make_shared<CmsSpreadOptionConvention>("USD-CMS-10Y-2Y-CONVENTION", "0M", "2D", "3M", "2",
520 "TARGET", "A360", "MF"));
521
522 return conventions;
523}
524
525QuantLib::ext::shared_ptr<CurveConfigurations> curveConfigurations() {
526 QuantLib::ext::shared_ptr<CurveConfigurations> configs(new CurveConfigurations());
527
528 // Vectors to hold quote strings and segments
529 vector<string> quotes;
530 vector<QuantLib::ext::shared_ptr<YieldCurveSegment>> segments;
531
532 // Eonia curve
533 quotes = {"MM/RATE/EUR/0D/1D"};
534 segments.push_back(QuantLib::ext::make_shared<SimpleYieldCurveSegment>("Deposit", "EUR-EONIA-CONVENTIONS", quotes));
535
536 // clang-format off
537 quotes = {"IR_SWAP/RATE/EUR/2D/1D/1W",
538 "IR_SWAP/RATE/EUR/2D/1D/2W",
539 "IR_SWAP/RATE/EUR/2D/1D/1M",
540 "IR_SWAP/RATE/EUR/2D/1D/2M",
541 "IR_SWAP/RATE/EUR/2D/1D/3M",
542 "IR_SWAP/RATE/EUR/2D/1D/4M",
543 "IR_SWAP/RATE/EUR/2D/1D/5M",
544 "IR_SWAP/RATE/EUR/2D/1D/6M",
545 "IR_SWAP/RATE/EUR/2D/1D/7M",
546 "IR_SWAP/RATE/EUR/2D/1D/8M",
547 "IR_SWAP/RATE/EUR/2D/1D/9M",
548 "IR_SWAP/RATE/EUR/2D/1D/10M",
549 "IR_SWAP/RATE/EUR/2D/1D/11M",
550 "IR_SWAP/RATE/EUR/2D/1D/1Y",
551 "IR_SWAP/RATE/EUR/2D/1D/2Y",
552 "IR_SWAP/RATE/EUR/2D/1D/3Y",
553 "IR_SWAP/RATE/EUR/2D/1D/4Y",
554 "IR_SWAP/RATE/EUR/2D/1D/5Y",
555 "IR_SWAP/RATE/EUR/2D/1D/6Y",
556 "IR_SWAP/RATE/EUR/2D/1D/7Y",
557 "IR_SWAP/RATE/EUR/2D/1D/8Y",
558 "IR_SWAP/RATE/EUR/2D/1D/9Y",
559 "IR_SWAP/RATE/EUR/2D/1D/10Y"};
560 // clang-format on
561 segments.push_back(QuantLib::ext::make_shared<SimpleYieldCurveSegment>("OIS", "EUR-OIS-CONVENTIONS", quotes));
562
563 configs->add(CurveSpec::CurveType::Yield, "EUR1D",
564 QuantLib::ext::make_shared<YieldCurveConfig>("EUR1D", "Eonia Curve", "EUR", "", segments));
565
566 // Lending curve
567 segments.clear();
568 // clang-format off
569 quotes = {"ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/2Y",
570 "ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/5Y",
571 "ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/10Y",
572 "ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/20Y"};
573 // clang-format on
574 segments.push_back(QuantLib::ext::make_shared<ZeroSpreadedYieldCurveSegment>(
575 "Zero Spread", "EUR-ZERO-CONVENTIONS-TENOR-BASED", quotes, "EUR1D"));
576
577 configs->add(CurveSpec::CurveType::Yield, "BANK_EUR_LEND",
578 QuantLib::ext::make_shared<YieldCurveConfig>("BANK_EUR_LEND", "Eonia Curve", "EUR", "", segments));
579
580 // Borrowing curve
581 segments.clear();
582 // clang-format off
583 quotes = {"ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/2Y",
584 "ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/5Y",
585 "ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/10Y",
586 "ZERO/YIELD_SPREAD/EUR/BANK_EUR_BORROW/A365/20Y"};
587 // clang-format on
588 segments.push_back(QuantLib::ext::make_shared<ZeroSpreadedYieldCurveSegment>(
589 "Zero Spread", "EUR-ZERO-CONVENTIONS-TENOR-BASED", quotes, "EUR1D"));
590
591 configs->add(CurveSpec::CurveType::Yield, "BANK_EUR_BORROW",
592 QuantLib::ext::make_shared<YieldCurveConfig>("BANK_EUR_LEND", "Eonia Curve", "EUR", "", segments));
593
594 // USD Fed Funds curve
595 segments.clear();
596 quotes = {{"MM/RATE/USD/0D/1D"}};
597 segments.push_back(QuantLib::ext::make_shared<SimpleYieldCurveSegment>("Deposit", "USD-FED-FUNDS-CONVENTIONS", quotes));
598
599 // clang-format off
600 quotes = {"IR_SWAP/RATE/USD/2D/1D/1M",
601 "IR_SWAP/RATE/USD/2D/1D/3M",
602 "IR_SWAP/RATE/USD/2D/1D/6M",
603 "IR_SWAP/RATE/USD/2D/1D/9M",
604 "IR_SWAP/RATE/USD/2D/1D/1Y",
605 "IR_SWAP/RATE/USD/2D/1D/2Y",
606 "IR_SWAP/RATE/USD/2D/1D/3Y",
607 "IR_SWAP/RATE/USD/2D/1D/4Y",
608 "IR_SWAP/RATE/USD/2D/1D/5Y",
609 "IR_SWAP/RATE/USD/2D/1D/7Y",
610 "IR_SWAP/RATE/USD/2D/1D/10Y",
611 "IR_SWAP/RATE/USD/2D/1D/12Y",
612 "IR_SWAP/RATE/USD/2D/1D/15Y",
613 "IR_SWAP/RATE/USD/2D/1D/20Y",
614 "IR_SWAP/RATE/USD/2D/1D/25Y",
615 "IR_SWAP/RATE/USD/2D/1D/30Y",
616 "IR_SWAP/RATE/USD/2D/1D/50Y"};
617 // clang-format on
618 segments.push_back(QuantLib::ext::make_shared<SimpleYieldCurveSegment>("OIS", "USD-OIS-CONVENTIONS", quotes));
619
620 configs->add(CurveSpec::CurveType::Yield, "USD1D",
621 QuantLib::ext::make_shared<YieldCurveConfig>("USD1D", "Fed Funds curve", "USD", "", segments));
622
623 // USD 3M forward curve
624 segments.clear();
625 quotes = {"MM/RATE/USD/2D/3M"};
626 segments.push_back(
627 QuantLib::ext::make_shared<SimpleYieldCurveSegment>("Deposit", "USD-LIBOR-CONVENTIONS", quotes, "USD3M"));
628
629 // clang-format off
630 quotes = {"FRA/RATE/USD/3M/3M",
631 "FRA/RATE/USD/6M/3M",
632 "FRA/RATE/USD/9M/3M",
633 "FRA/RATE/USD/1Y/3M"};
634 // clang-format on
635 segments.push_back(QuantLib::ext::make_shared<SimpleYieldCurveSegment>("FRA", "USD-3M-FRA-CONVENTIONS", quotes, "USD3M"));
636
637 // clang-format off
638 quotes = {"IR_SWAP/RATE/USD/2D/3M/2Y",
639 "IR_SWAP/RATE/USD/2D/3M/3Y",
640 "IR_SWAP/RATE/USD/2D/3M/4Y",
641 "IR_SWAP/RATE/USD/2D/3M/5Y",
642 "IR_SWAP/RATE/USD/2D/3M/6Y",
643 "IR_SWAP/RATE/USD/2D/3M/7Y",
644 "IR_SWAP/RATE/USD/2D/3M/8Y",
645 "IR_SWAP/RATE/USD/2D/3M/9Y",
646 "IR_SWAP/RATE/USD/2D/3M/10Y",
647 "IR_SWAP/RATE/USD/2D/3M/12Y",
648 "IR_SWAP/RATE/USD/2D/3M/15Y",
649 "IR_SWAP/RATE/USD/2D/3M/20Y",
650 "IR_SWAP/RATE/USD/2D/3M/25Y",
651 "IR_SWAP/RATE/USD/2D/3M/30Y",
652 "IR_SWAP/RATE/USD/2D/3M/40Y",
653 "IR_SWAP/RATE/USD/2D/3M/50Y"};
654 // clang-format on
655 segments.push_back(QuantLib::ext::make_shared<SimpleYieldCurveSegment>("Swap", "USD-3M-SWAP-CONVENTIONS", quotes, "USD3M"));
656
657 configs->add(CurveSpec::CurveType::Yield, "USD3M",
658 QuantLib::ext::make_shared<YieldCurveConfig>("USD3M", "USD 3M curve", "USD", "USD1D", segments));
659
660 // Swaption volatilities
661
662 // Common variables for all volatility structures
663 Actual365Fixed dayCounter;
664 BusinessDayConvention bdc = Following;
665
666 // Swaption volatility structure option and swap tenors
667 // clang-format off
668 vector<string> optionTenors{
669 "1M",
670 "3M",
671 "6M",
672 "1Y",
673 "2Y",
674 "3Y",
675 "4Y",
676 "5Y",
677 "7Y",
678 "10Y",
679 "15Y",
680 "20Y",
681 "25Y",
682 "30Y"
683 };
684
685 vector<string> swapTenors{
686 "1Y",
687 "2Y",
688 "3Y",
689 "4Y",
690 "5Y",
691 "7Y",
692 "10Y",
693 "15Y",
694 "20Y",
695 "25Y",
696 "30Y"
697 };
698 // clang-format on
699
700 // USD Lognormal swaption volatility "curve" configuration
701 configs->add(CurveSpec::CurveType::SwaptionVolatility, "USD_SW_LN",
702 QuantLib::ext::make_shared<SwaptionVolatilityCurveConfig>(
703 "USD_SW_LN", "USD Lognormal swaption volatilities", SwaptionVolatilityCurveConfig::Dimension::ATM,
704 SwaptionVolatilityCurveConfig::VolatilityType::Lognormal,
705 SwaptionVolatilityCurveConfig::VolatilityType::Lognormal,
706 GenericYieldVolatilityCurveConfig::Interpolation::Linear,
707 GenericYieldVolatilityCurveConfig::Extrapolation::Flat, optionTenors, swapTenors, dayCounter,
708 UnitedStates(UnitedStates::Settlement), bdc, "USD-CMS-1Y", "USD-CMS-30Y"));
709
710 // Capfloor volatility structure tenors and strikes
711 vector<string> capTenors{"1Y", "2Y", "5Y", "7Y", "10Y"};
712 vector<string> strikes{"0.005", "0.010", "0.015", "0.020", "0.025", "0.030"};
713
714 // USD Lognormal capfloor volatility "curve" configuration
715 configs->add(CurveSpec::CurveType::CapFloorVolatility, "USD_CF_LN", QuantLib::ext::make_shared<CapFloorVolatilityCurveConfig>(
716 "USD_CF_LN", "USD Lognormal capfloor volatilities", CapFloorVolatilityCurveConfig::VolatilityType::Lognormal,
717 true, false, false, capTenors, strikes, dayCounter, 0, UnitedStates(UnitedStates::Settlement), bdc,
718 "USD-LIBOR-3M", 3 * Months, 0, "Yield/USD/USD1D"));
719
720 vector<string> optionTenors2{"1Y"};
721
722 vector<string> optionTenors3{"1Y", "2Y"};
723 // Correlation curve
724 configs->add(CurveSpec::CurveType::Correlation, "EUR-CORR", QuantLib::ext::make_shared<CorrelationCurveConfig>(
725 "EUR-CORR", "EUR CMS Correlations", CorrelationCurveConfig::Dimension::Constant,
726 CorrelationCurveConfig::CorrelationType::CMSSpread, "EUR-CMS-1Y-10Y-CONVENTION",
727 MarketDatum::QuoteType::RATE, true, optionTenors2, dayCounter, UnitedStates(UnitedStates::Settlement), bdc,
728 "EUR-CMS-10Y", "EUR-CMS-2Y", "EUR"));
729 configs->add(CurveSpec::CurveType::Correlation, "USD-CORR", QuantLib::ext::make_shared<CorrelationCurveConfig>(
730 "USD-CORR", "USD CMS Correlations", CorrelationCurveConfig::Dimension::ATM,
731 CorrelationCurveConfig::CorrelationType::CMSSpread, "USD-CMS-10Y-2Y-CONVENTION",
732 MarketDatum::QuoteType::PRICE, true, optionTenors3, Actual360(), TARGET(), ModifiedFollowing,
733 "USD-CMS-10Y", "USD-CMS-2Y", "USD", "USD_SW_LN", "USD1D"));
734
735 // clang-format off
736 vector<string> eqFwdQuotes{
737 "EQUITY_FWD/PRICE/SP5/USD/1Y",
738 "EQUITY_FWD/PRICE/SP5/USD/20180226"
739 };
740 vector<string> equityVolExpiries{
741 "1Y",
742 "2018-02-26"
743 };
744 // clang-format on
745
746 configs->add(CurveSpec::CurveType::Equity, "SP5", QuantLib::ext::make_shared<EquityCurveConfig>(
747 "SP5", "", "USD1D", "USD", "USD", EquityCurveConfig::Type::ForwardPrice, "EQUITY/PRICE/SP5/USD", eqFwdQuotes));
748
749 vector<string> eqVolQuotes = {"EQUITY_OPTION/RATE_LNVOL/SP5/USD/1Y/ATMF",
750 "EQUITY_OPTION/RATE_LNVOL/SP5/USD/2018-02-26/ATMF"};
751 vector<QuantLib::ext::shared_ptr<VolatilityConfig>> vcc;
752 vcc.push_back(QuantLib::ext::make_shared<VolatilityCurveConfig>(eqVolQuotes, "Flat", "Flat"));
753
754 configs->add(CurveSpec::CurveType::EquityVolatility, "SP5", QuantLib::ext::make_shared<EquityVolatilityCurveConfig>(
755 "SP5", "", "USD", vcc, "SP5", "A365", "USD"));
756
757 // clang-format off
758 vector<string> commodityQuotes{
759 "COMMODITY_FWD/PRICE/GOLD/USD/2016-08-31",
760 "COMMODITY_FWD/PRICE/GOLD/USD/2017-02-28",
761 "COMMODITY_FWD/PRICE/GOLD/USD/2017-08-31",
762 "COMMODITY_FWD/PRICE/GOLD/USD/2017-12-29",
763 "COMMODITY_FWD/PRICE/GOLD/USD/2018-12-31",
764 "COMMODITY_FWD/PRICE/GOLD/USD/2021-12-31"
765 };
766 // clang-format on
767
768 configs->add(CurveSpec::CurveType::Commodity, "GOLD_USD",
769 QuantLib::ext::make_shared<CommodityCurveConfig>("GOLD_USD", "", "USD", commodityQuotes, "COMMODITY/PRICE/GOLD/USD"));
770
771 return configs;
772}
773
774// Fixture to use for this test suite
775class F : public TopLevelFixture {
776public:
777 QuantLib::ext::shared_ptr<TodaysMarket> market;
778
779 F() {
780 Date asof(26, February, 2016);
781 Settings::instance().evaluationDate() = asof;
782
783 auto loader = QuantLib::ext::make_shared<MarketDataLoader>();
784 auto params = marketParameters();
785 auto configs = curveConfigurations();
786 auto convs = conventions();
787
788 ore::data::InstrumentConventions::instance().setConventions(convs);
789
790 BOOST_TEST_MESSAGE("Creating TodaysMarket Instance");
791 market = QuantLib::ext::make_shared<TodaysMarket>(asof, params, loader, configs);
792 }
793
794 ~F() {
795 BOOST_TEST_MESSAGE("Destroying TodaysMarket instance");
796 market.reset();
797 }
798};
799
800} // namespace
801
802BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, TopLevelFixture)
803
804BOOST_FIXTURE_TEST_SUITE(TodaysMarketTests, F)
805
806BOOST_AUTO_TEST_CASE(testZeroSpreadedYieldCurve) {
807
808 BOOST_TEST_MESSAGE("Testing zero spreaded yield curve rates...");
809
810 Handle<YieldTermStructure> dts = market->discountCurve("EUR");
811 Handle<YieldTermStructure> dtsLend = market->yieldCurve("EUR_LEND");
812 Handle<YieldTermStructure> dtsBorrow = market->yieldCurve("EUR_BORROW");
813
814 QL_REQUIRE(!dts.empty(), "EUR discount curve not found");
815 QL_REQUIRE(!dtsLend.empty(), "EUR lending curve not found");
816 QL_REQUIRE(!dtsBorrow.empty(), "EUR borrowing curve not found");
817
818 Date today = Settings::instance().evaluationDate();
819 DayCounter dc = Actual365Fixed();
820 Real tolerance = 1.0e-5; // 0.1 bp
821 Real expected1 = 0.005;
822 Real expected2 = -0.001;
823 for (Size i = 1; i <= 120; i++) {
824 Date d = today + i * Months;
825 Real z0 = dts->zeroRate(d, dc, Continuous);
826 Real z1 = dtsLend->zeroRate(d, dc, Continuous);
827 Real z2 = dtsBorrow->zeroRate(d, dc, Continuous);
828 BOOST_CHECK_MESSAGE(fabs(z1 - z0 - expected1) < tolerance, "error in lending spread curve setup");
829 BOOST_CHECK_MESSAGE(fabs(z2 - z0 - expected2) < tolerance, "error in borrowing spread curve setup");
830 }
831}
832
833BOOST_AUTO_TEST_CASE(testNormalOptionletVolatility) {
834
835 BOOST_TEST_MESSAGE("Testing normal optionlet volatilities...");
836
837 Handle<OptionletVolatilityStructure> ovs = market->capFloorVol("USD");
838
839 BOOST_CHECK_MESSAGE(!ovs.empty(), "USD lognormal optionlet volatility structure was not created");
840 BOOST_CHECK_MESSAGE(ovs->volatilityType() == Normal,
841 "USD lognormal capfloor volatility was not converted to Normal optionlet volatility");
842
843 // Test against some expected values
844 Real tolerance = 1.0e-6;
845 vector<Period> tenors{1 * Years, 2 * Years, 5 * Years, 7 * Years, 10 * Years};
846 vector<Rate> strikes{0.005, 0.010, 0.015, 0.020, 0.025, 0.030};
847 // clang-format off
848 vector<vector<Real>> cachedValues{
849 { 0.004336061, 0.004790686, 0.005541127, 0.006411979, 0.007242633, 0.007889790 },
850 { 0.005904299, 0.006478381, 0.006929551, 0.007486301, 0.008139029, 0.008566001 },
851 { 0.008871166, 0.009370956, 0.009723190, 0.010015776, 0.010243227, 0.010492463 },
852 { 0.008517407, 0.008700672, 0.008661611, 0.008631934, 0.008657444, 0.008690871 },
853 { 0.007641226, 0.007821393, 0.007889650, 0.007980682, 0.008075806, 0.008235808 }
854 };
855 // clang-format on
856
857 for (Size i = 0; i < tenors.size(); ++i) {
858 for (Size j = 0; j < strikes.size(); ++j) {
859 Volatility v = ovs->volatility(tenors[i], strikes[j]);
860 Real error = fabs(v - cachedValues[i][j]);
861 // clang-format off
862 BOOST_CHECK_MESSAGE(error < tolerance,
863 "\ncap tenor: " << tenors[i] <<
864 "\nstrike: " << io::rate(strikes[j]) <<
865 "\ncached volatility: " << io::volatility(cachedValues[i][j]) <<
866 "\nvolatility: " << io::volatility(v) <<
867 "\nerror: " << io::rate(error) <<
868 "\ntolerance: " << io::rate(tolerance));
869 // clang-format on
870 }
871 }
872}
873
874BOOST_AUTO_TEST_CASE(testEquityCurve) {
875
876 BOOST_TEST_MESSAGE("Testing equity curve...");
877
878 Handle<YieldTermStructure> divTs = market->equityDividendCurve("SP5");
879 BOOST_CHECK(divTs.currentLink());
880 Handle<YieldTermStructure> equityIrTs = market->discountCurve("USD");
881 BOOST_CHECK(equityIrTs.currentLink());
882 Handle<Quote> equitySpot = market->equitySpot("SP5");
883 BOOST_CHECK(equitySpot.currentLink());
884 Real spotVal = equitySpot->value();
885 DayCounter divDc = divTs->dayCounter();
886
887 Date today = Settings::instance().evaluationDate();
888 Date d_1y = Date(27, Feb, 2017);
889 Date d_2y = Date(26, Feb, 2018);
890 Rate r_1y = equityIrTs->zeroRate(d_1y, divDc, Continuous);
891 Rate r_2y = equityIrTs->zeroRate(d_2y, divDc, Continuous);
892 Rate q_1y = divTs->zeroRate(d_1y, divDc, Continuous);
893 Rate q_2y = divTs->zeroRate(d_2y, divDc, Continuous);
894 Real f_1y = spotVal * std::exp((r_1y - q_1y) * (divDc.yearFraction(today, d_1y)));
895 Real f_2y = spotVal * std::exp((r_2y - q_2y) * (divDc.yearFraction(today, d_2y)));
896 BOOST_CHECK_CLOSE(1500.00, f_1y, 1.e-10); // hardcoded, to be the same as the input quote
897 BOOST_CHECK_CLOSE(1500.0, f_2y, 1.e-10); // hardcoded, to be the same as the input quote
898
899 // test flat extrapolation of the dividend yield term structure (N.B. NOT FLAT ON FORWARDS!)
900 Rate q_5y = divTs->zeroRate(5.0, Continuous);
901 Rate q_50y = divTs->zeroRate(50.0, Continuous);
902 BOOST_CHECK_CLOSE(q_5y, q_50y, 1.e-10);
903
904 // test that the t=0 forward value is equal to the spot
905 Rate r_0 = equityIrTs->zeroRate(0.0, Continuous);
906 Rate q_0 = divTs->zeroRate(0.0, Continuous);
907 Real fwd_0 = spotVal * std::exp((r_0 - q_0) * 0.0);
908 BOOST_CHECK_EQUAL(spotVal, fwd_0);
909}
910
911BOOST_AUTO_TEST_CASE(testEquityVolCurve) {
912
913 BOOST_TEST_MESSAGE("Testing equity vol curve...");
914
915 Handle<BlackVolTermStructure> eqVol = market->equityVol("SP5");
916 BOOST_CHECK(eqVol.currentLink());
917
918 Date d_1y = Date(27, Feb, 2017);
919 Date d_2y = Date(26, Feb, 2018);
920 Volatility v_1y_atm = eqVol->blackVol(d_1y, 0.0);
921 Volatility v_1y_smile = eqVol->blackVol(d_1y, 2000.0);
922 BOOST_CHECK_EQUAL(v_1y_atm, v_1y_smile); // test ATM flat smile
923 BOOST_CHECK_EQUAL(v_1y_atm, 0.25); // test input = output
924 Volatility v_2y_atm = eqVol->blackVol(d_2y, 0.0);
925 Volatility v_2y_smile = eqVol->blackVol(d_2y, 2000.0);
926 BOOST_CHECK_EQUAL(v_2y_atm, v_2y_smile); // test ATM flat smile
927 BOOST_CHECK_EQUAL(v_2y_atm, 0.35); // test input = output
928
929 // test flat extrapolation
930 Volatility v_5y_atm = eqVol->blackVol(5.0, 0.0);
931 Volatility v_50y_atm = eqVol->blackVol(50.0, 0.0);
932 BOOST_CHECK_CLOSE(v_5y_atm, v_50y_atm, 1.e-10);
933}
934
935BOOST_AUTO_TEST_CASE(testCommodityCurve) {
936
937 BOOST_TEST_MESSAGE("Testing commodity price curve");
938
939 // Just test that the building succeeded - the curve itself has been tested elsewhere
940 Handle<PriceTermStructure> commodityCurve = market->commodityPriceCurve("COMDTY_GOLD_USD");
941 BOOST_CHECK(*commodityCurve);
942}
943
944BOOST_AUTO_TEST_CASE(testCorrelationCurve) {
945
946 BOOST_TEST_MESSAGE("Testing correlation curve");
947
948 // Just test that the building succeeded - the curve itself has been tested elsewhere
949 Handle<QuantExt::CorrelationTermStructure> correlationCurve1 =
950 market->correlationCurve("EUR-CMS-10Y", "EUR-CMS-2Y");
951 Handle<QuantExt::CorrelationTermStructure> correlationCurve2 =
952 market->correlationCurve("USD-CMS-10Y", "USD-CMS-2Y");
953 BOOST_CHECK(*correlationCurve1);
954 BOOST_CHECK(*correlationCurve2);
955
956 Calendar calendar = TARGET();
957 Date qlStartDate = calendar.advance(calendar.advance(market->asofDate(), 2 * Days), 0 * Months);
958 Date qlEndDate1Y = calendar.advance(qlStartDate, 1 * Years, ModifiedFollowing);
959 Date qlEndDate2Y = calendar.advance(qlStartDate, 2 * Years, ModifiedFollowing);
960 string startDate = ore::data::to_string(qlStartDate);
961 string endDate1Y = ore::data::to_string(qlEndDate1Y);
962 string endDate2Y = ore::data::to_string(qlEndDate2Y);
963
964 BOOST_TEST_MESSAGE(startDate);
965 BOOST_TEST_MESSAGE(endDate1Y);
966 BOOST_TEST_MESSAGE(endDate2Y);
967
968 ScheduleData cms1YSchedule(ScheduleRules(startDate, endDate1Y, "3M", "TARGET", "MF", "MF", "Forward", "N"));
969 ScheduleData cms2YSchedule(ScheduleRules(startDate, endDate2Y, "3M", "TARGET", "MF", "MF", "Forward", "N"));
970
971 Real fairSpread1Y = 0.00752401;
972 Real fairSpread2Y = 0.00755509;
973
974 LegData cms1YLeg(QuantLib::ext::make_shared<CMSSpreadLegData>(
975 "USD-CMS-10Y", "USD-CMS-2Y", 2, true, std::vector<Real>(1, 0.0), vector<string>(),
976 std::vector<Real>(1, fairSpread1Y), vector<string>(), vector<double>(), vector<string>(),
977 vector<double>(), vector<string>(), true),
978 false, "USD", cms1YSchedule, "A360", std::vector<Real>(1, 1));
979 vector<LegData> legs1Y;
980 legs1Y.push_back(cms1YLeg);
981
982 LegData cms2YLeg(QuantLib::ext::make_shared<CMSSpreadLegData>(
983 "USD-CMS-10Y", "USD-CMS-2Y", 2, true, std::vector<Real>(1, 0.0), vector<string>(),
984 std::vector<Real>(1, fairSpread2Y), vector<string>(), vector<double>(), vector<string>(),
985 vector<double>(), vector<string>(), true),
986 false, "USD", cms2YSchedule, "A360", std::vector<Real>(1, 1));
987 vector<LegData> legs2Y;
988 legs2Y.push_back(cms2YLeg);
989
990 Envelope env("CP1");
991
992 ore::data::Swap cmsSpread1YCap(env, legs1Y);
993 ore::data::Swap cmsSpread2YCap(env, legs2Y);
994
995 Real expectedNpv1Y = 0.0038614;
996 Real expectedNpv2Y = 0.0105279;
997
998 // Build and price
999 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
1000 engineData->model("CMS") = "LinearTSR";
1001 engineData->engine("CMS") = "LinearTSRPricer";
1002
1003 map<string, string> engineparams1;
1004 engineparams1["MeanReversion"] = "0.0";
1005 engineparams1["Policy"] = "RateBound";
1006 engineparams1["LowerRateBoundLogNormal"] = "0.0001";
1007 engineparams1["UpperRateBoundLogNormal"] = "2";
1008 engineparams1["LowerRateBoundNormal"] = "-2";
1009 engineparams1["UpperRateBoundNormal"] = "2";
1010 engineparams1["VegaRatio"] = "0.01";
1011 engineparams1["PriceThreshold"] = "0.0000001";
1012 engineparams1["BsStdDev"] = "3";
1013 engineData->engineParameters("CMS") = engineparams1;
1014
1015 engineData->model("CMSSpread") = "BrigoMercurio";
1016 engineData->engine("CMSSpread") = "Analytic";
1017 map<string, string> engineparams2;
1018 engineparams2["IntegrationPoints"] = "16";
1019 engineData->engineParameters("CMSSpread") = engineparams2;
1020
1021 engineData->model("Swap") = "DiscountedCashflows";
1022 engineData->engine("Swap") = "DiscountingSwapEngine";
1023
1024 QuantLib::ext::shared_ptr<EngineFactory> engineFactory = QuantLib::ext::make_shared<EngineFactory>(engineData, market);
1025
1026 cmsSpread1YCap.build(engineFactory);
1027 cmsSpread2YCap.build(engineFactory);
1028
1029 Real npvCash = cmsSpread1YCap.instrument()->NPV();
1030
1031 BOOST_TEST_MESSAGE("NPV Cash 1Y = " << npvCash);
1032 BOOST_CHECK_SMALL(npvCash - expectedNpv1Y, 0.000001);
1033
1034 npvCash = cmsSpread2YCap.instrument()->NPV();
1035
1036 BOOST_TEST_MESSAGE("NPV Cash 2Y = " << npvCash);
1037
1038 BOOST_CHECK_SMALL(npvCash - expectedNpv2Y, 0.000001);
1039}
1040
1041BOOST_AUTO_TEST_SUITE_END()
1042
1043BOOST_AUTO_TEST_SUITE_END()
Engine builder for Swaps.
Repository for currency dependent market conventions.
Container class for all Curve Configurations.
Container for storing Deposit conventions.
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Serializable object holding leg data.
Definition: legdata.hpp:844
Market data loader base class.
Definition: loader.hpp:47
virtual std::vector< QuantLib::ext::shared_ptr< MarketDatum > > loadQuotes(const QuantLib::Date &) const =0
get all quotes, TODO change the return value to std::set
virtual std::set< Fixing > loadFixings() const =0
virtual std::set< QuantExt::Dividend > loadDividends() const
Optional load dividends method.
Definition: loader.cpp:118
void setId(const MarketObject o, const string &id)
Container for storing Overnight Index Swap conventions.
Serializable schedule data.
Definition: schedule.hpp:202
Serializable object holding schedule Rules data.
Definition: schedule.hpp:37
Serializable Swap, Single and Cross Currency.
Definition: swap.hpp:36
virtual void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
Definition: swap.cpp:45
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument() const
Definition: trade.hpp:141
Container for storing Zero Rate conventions.
builder that returns an engine to price capped floored ibor legs
builder that returns a cms spread coupon pricer
SafeStack< ValueType > value
QuantLib::ext::shared_ptr< MarketDatum > parseMarketDatum(const Date &asof, const string &datumName, const Real &value)
Function to parse a market datum.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
Leg Builders.
Market Datum Loader Interface.
@ data
Definition: log.hpp:77
Market Datum parser.
Calendar calendar
Definition: utilities.cpp:441
Real error
Definition: utilities.cpp:65
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.
Swap trade data model and serialization.
vector< Real > strikes
BOOST_AUTO_TEST_CASE(testZeroSpreadedYieldCurve)
string conversion utilities
An concrete implementation of the Market class that loads todays market and builds the required curve...
string name