19#include <boost/test/unit_test.hpp>
20#include <oret/datapaths.hpp>
21#include <oret/fileutilities.hpp>
22#include <oret/toplevelfixture.hpp>
33using namespace boost::unit_test_framework;
38using ore::test::TopLevelFixture;
42QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<IrModelData>>> irConfigsData() {
49 vector<std::string> expiries = {
"1Y",
"2Y",
"36M"};
50 vector<std::string> terms = {
"5Y",
"2Y",
"6M"};
51 vector<std::string>
strikes = {
"ATM",
"ATM",
"ATM"};
54 lgmData1->qualifier() =
"EUR";
59 std::vector<Time> hTimes = {1.0, 2.0, 3.0, 4.0};
60 std::vector<Real> hValues = {1.0, 2.0, 3.0, 4.0};
61 std::vector<Time> aTimes = {1.0, 2.0, 3.0, 4.0};
62 std::vector<Real> aValues = {1.0, 2.0, 3.0, 4.0};
64 lgmData1->calibrateH() =
false;
67 lgmData1->hTimes() = hTimes;
69 lgmData1->hValues() = hValues;
71 lgmData1->calibrateA() =
false;
73 lgmData1->aTimes() = aTimes;
74 lgmData1->aValues() = aValues;
75 lgmData1->shiftHorizon() = 1.0;
77 lgmData1->optionExpiries() = expiries;
78 lgmData1->optionTerms() = terms;
79 lgmData1->optionStrikes() =
strikes;
81 lgmData1->scaling() = 1.0;
84 lgmData2->qualifier() =
"USD";
90 lgmData2->calibrateH() =
false;
92 lgmData2->hTimes() = hTimes;
93 lgmData2->hValues() = hValues;
95 lgmData2->calibrateA() =
false;
98 lgmData2->aTimes() = aTimes;
99 lgmData2->aValues() = aValues;
100 lgmData2->shiftHorizon() = 1.0;
102 lgmData2->optionExpiries() = expiries;
103 lgmData2->optionTerms() = terms;
104 lgmData2->optionStrikes() =
strikes;
106 lgmData2->scaling() = 1.0;
109 lgmData3->qualifier() =
"JPY";
115 lgmData3->calibrateH() =
false;
117 lgmData3->hTimes() = hTimes;
118 lgmData3->hValues() = hValues;
120 lgmData3->calibrateA() =
false;
123 lgmData3->aTimes() = aTimes;
124 lgmData3->aValues() = aValues;
125 lgmData3->shiftHorizon() = 1.0;
127 lgmData3->optionExpiries() = expiries;
128 lgmData3->optionTerms() = terms;
129 lgmData3->optionStrikes() =
strikes;
131 lgmData3->scaling() = 1.0;
133 QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<IrModelData>>> lgmDataVector(
new vector<QuantLib::ext::shared_ptr<IrModelData>>);
134 *lgmDataVector = {lgmData1, lgmData2, lgmData3};
135 return lgmDataVector;
138vector<QuantLib::ext::shared_ptr<InflationModelData>> infConfigsData() {
142 vector<QuantLib::ext::shared_ptr<CalibrationInstrument>> instruments;
143 vector<Period> expiries = { 1 * Years, 2 * Years, 36 * Months };
144 auto strike = QuantLib::ext::make_shared<AbsoluteStrike>(0.03);
145 for (
const Period& expiry : expiries) {
146 instruments.push_back(QuantLib::ext::make_shared<CpiCapFloor>(CapFloor::Floor, expiry, strike));
149 vector<CalibrationBasket> calibrationBaskets = { cb };
151 ReversionParameter reversion(LgmData::ReversionType::HullWhite,
false, ParamType::Piecewise,
152 { 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0, 4.0 });
154 VolatilityParameter volatility(LgmData::VolatilityType::Hagan,
false, ParamType::Piecewise,
155 { 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0, 4.0 });
159 QuantLib::ext::shared_ptr<InfDkData>
data = QuantLib::ext::make_shared<InfDkData>(CalibrationType::Bootstrap, calibrationBaskets,
160 "EUR",
"EUHICPXT", reversion, volatility, rt);
165QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<FxBsData>>> fxConfigsData() {
168 QuantLib::ext::shared_ptr<FxBsData> fxBsData1(
new data::FxBsData());
169 QuantLib::ext::shared_ptr<FxBsData> fxBsData2(
new data::FxBsData());
171 vector<std::string> expiries = {
"1Y",
"2Y",
"36M"};
172 vector<std::string>
strikes = {
"ATMF",
"ATMF",
"ATMF"};
173 std::vector<Time> times = {1.0, 2.0, 3.0, 4.0};
176 fxBsData1->foreignCcy() =
"USD";
177 fxBsData1->domesticCcy() =
"EUR";
179 fxBsData1->calibrateSigma() =
true;
181 fxBsData1->sigmaTimes() = times;
182 fxBsData1->optionExpiries() = expiries;
183 fxBsData1->optionStrikes() =
strikes;
186 fxBsData2->foreignCcy() =
"JPY";
187 fxBsData2->domesticCcy() =
"EUR";
189 fxBsData2->calibrateSigma() =
true;
191 fxBsData2->sigmaTimes() = times;
192 fxBsData2->optionExpiries() = expiries;
193 fxBsData2->optionStrikes() =
strikes;
195 QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<FxBsData>>> fxBsDataVector(
new vector<QuantLib::ext::shared_ptr<FxBsData>>);
196 *fxBsDataVector = {fxBsData1, fxBsData2};
197 return fxBsDataVector;
200QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<EqBsData>>> eqConfigsData() {
203 QuantLib::ext::shared_ptr<EqBsData> eqBsData1(
new data::EqBsData());
205 vector<std::string> expiries = {
"1Y",
"2Y",
"36M"};
206 vector<std::string>
strikes = {
"ATMF",
"ATMF",
"ATMF"};
207 std::vector<Time> times = {1.0, 2.0, 3.0, 4.0};
210 eqBsData1->eqName() =
"SP5";
211 eqBsData1->currency() =
"EUR";
213 eqBsData1->calibrateSigma() =
true;
215 eqBsData1->sigmaTimes() = times;
216 eqBsData1->optionExpiries() = expiries;
217 eqBsData1->optionStrikes() =
strikes;
219 QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<EqBsData>>> eqBsDataVector(
new vector<QuantLib::ext::shared_ptr<EqBsData>>);
220 *eqBsDataVector = {eqBsData1};
221 return eqBsDataVector;
224QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<CrLgmData>>> crLgmConfigsData() {
229 lgmData->name() =
"ItraxxEuropeS9V1";
234 std::vector<Time> hTimes = {1.0, 2.0, 3.0, 4.0};
235 std::vector<Real> hValues = {1.0, 2.0, 3.0, 4.0};
236 std::vector<Time> aTimes = {1.0, 2.0, 3.0, 4.0};
237 std::vector<Real> aValues = {1.0, 2.0, 3.0, 4.0};
239 lgmData->calibrateH() =
false;
242 lgmData->hTimes() = hTimes;
244 lgmData->hValues() = hValues;
246 lgmData->calibrateA() =
false;
248 lgmData->aTimes() = aTimes;
249 lgmData->aValues() = aValues;
250 lgmData->shiftHorizon() = 1.0;
252 lgmData->scaling() = 1.0;
254 QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<CrLgmData>>> lgmDataVector(
new vector<QuantLib::ext::shared_ptr<CrLgmData>>);
255 *lgmDataVector = {lgmData};
256 return lgmDataVector;
259QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<CrCirData>>> crCirConfigsData() {
264 cirData->name() =
"CDX.NA.S33v1";
266 cirData->currency() =
"USD";
269 cirData->startValue() = 0.1;
270 cirData->reversionValue() = 0.1;
271 cirData->longTermValue() = 0.1;
272 cirData->volatility() = 0.1;
273 cirData->relaxedFeller() =
true;
274 cirData->fellerFactor() = 1.1;
275 cirData->tolerance() = 1e-8;
277 QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<CrCirData>>> cirDataVector(
new vector<QuantLib::ext::shared_ptr<CrCirData>>);
278 *cirDataVector = {cirData};
279 return cirDataVector;
282QuantLib::ext::shared_ptr<data::CrossAssetModelData> crossAssetData() {
286 crossAssetData->domesticCurrency() =
"EUR";
287 crossAssetData->currencies() = {
"EUR",
"USD",
"JPY"};
288 crossAssetData->equities() = {
"SP5"};
289 crossAssetData->infIndices() = {
"EUHICPXT"};
290 crossAssetData->creditNames() = {
"ItraxxEuropeS9V1",
"CDX.NA.S33v1"};
291 crossAssetData->irConfigs() = *irConfigsData();
292 crossAssetData->fxConfigs() = *fxConfigsData();
293 crossAssetData->eqConfigs() = *eqConfigsData();
294 crossAssetData->infConfigs() = infConfigsData();
295 crossAssetData->crLgmConfigs() = *crLgmConfigsData();
296 crossAssetData->crCirConfigs() = *crCirConfigsData();
305 cmb.
addCorrelation(
"CR:ItraxxEuropeS9V1",
"CR:CDX.NA.S33v1", 1.0);
309 crossAssetData->bootstrapTolerance() = 0.001;
311 return crossAssetData;
315class F :
public TopLevelFixture {
318 ~F() { clearOutput(TEST_OUTPUT_PATH); }
322BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, TopLevelFixture)
324BOOST_FIXTURE_TEST_SUITE(CrossAssetModelDataTests, F)
328 BOOST_TEST_MESSAGE(
"Testing toXML/fromXML...");
339 std::string filename = TEST_OUTPUT_FILE(
"simulationtest.xml");
345 BOOST_CHECK(
data == newData);
348 BOOST_CHECK(
data != newData);
351BOOST_AUTO_TEST_SUITE_END()
353BOOST_AUTO_TEST_SUITE_END()
void addCorrelation(const std::string &factor1, const std::string &factor2, QuantLib::Real correlation)
const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > & correlations()
Get the raw correlation data.
Cross Asset Model Parameters.
const vector< QuantLib::ext::shared_ptr< IrModelData > > & irConfigs() const
Small XML Document wrapper class.
void appendNode(XMLNode *)
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
void toFile(const string &filename) const
save the XML Document to the given file.
void fromFile(const std::string &filename)
static void appendNode(XMLNode *parent, XMLNode *child)
configuration class for building correlation matrices
Dodgson Kainth inflation model component data for the cross asset model.
IR component data for the cross asset model.
class for holding details of a zero coupon CPI cap floor calibration instrument.
CalibrationType parseCalibrationType(const string &s)
Convert calibration type string into enumerated class value.
ParamType parseParamType(const string &s)
Convert parameter type string into enumerated class value.
CrCirData::CalibrationStrategy parseCirCalibrationStrategy(const string &s)
LgmData::ReversionType parseReversionType(const string &s)
Enum parsers.
LgmData::VolatilityType parseVolatilityType(const string &s)
Serializable Credit Default Swap.
BOOST_AUTO_TEST_CASE(testToXMLFromXML)