Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cbo.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4*/
5
6// clang-format off
7#include <boost/test/unit_test.hpp>
8#include <boost/test/data/test_case.hpp>
9// clang-format on
10
13#include <oret/toplevelfixture.hpp>
14
15#include <oret/datapaths.hpp>
19
21
22#include <iostream>
23#include <iomanip>
24
25using namespace ore::data;
26
27BOOST_FIXTURE_TEST_SUITE(OREPlusCreditTestSuite, ore::test::TopLevelFixture)
28
29BOOST_AUTO_TEST_SUITE(CBOTest)
30
31BOOST_AUTO_TEST_CASE(testSimpleCBO) {
32 BOOST_TEST_MESSAGE("Testing simple CBO...");
33
34 Settings::instance().evaluationDate() = Date(31, Dec, 2018);
35 Date asof = Settings::instance().evaluationDate();
36
37 // Market
38 auto conventions = QuantLib::ext::make_shared<Conventions>();
39 conventions->fromFile(TEST_INPUT_FILE("conventions.xml"));
40 InstrumentConventions::instance().setConventions(conventions);
41
42 auto todaysMarketParams = QuantLib::ext::make_shared<TodaysMarketParameters>();
43 todaysMarketParams->fromFile(TEST_INPUT_FILE("todaysmarket.xml"));
44 auto curveConfigs = QuantLib::ext::make_shared<CurveConfigurations>();
45 curveConfigs->fromFile(TEST_INPUT_FILE("curveconfig.xml"));
46 auto loader = QuantLib::ext::make_shared<CSVLoader>(TEST_INPUT_FILE("market.txt"), TEST_INPUT_FILE("fixings.txt"), false);
47 auto market = QuantLib::ext::make_shared<TodaysMarket>(asof, todaysMarketParams, loader, curveConfigs, false);
48
49 // Portfolio to test market
50 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
51 engineData->fromFile(TEST_INPUT_FILE("pricingengine.xml"));
52 QuantLib::ext::shared_ptr<EngineFactory> factory = QuantLib::ext::make_shared<EngineFactory>(engineData, market);
53
54 Portfolio p;
55 BOOST_CHECK_NO_THROW(p.fromFile(TEST_INPUT_FILE("cbo.xml")));
56 BOOST_CHECK_NO_THROW(p.build(factory));
57
58 // Pricing comparison
59 double expectedNpv = 3013120.939;
60 const Real tol = 0.01;
61
62 BOOST_CHECK_NO_THROW(p.get("CBO-Constellation")->instrument()->NPV());
63 BOOST_TEST_MESSAGE(p.get("CBO-Constellation")->instrument()->NPV());
64 BOOST_CHECK_CLOSE(p.get("CBO-Constellation")->instrument()->NPV(), expectedNpv, tol);
65}
66
67BOOST_AUTO_TEST_SUITE_END()
68
69BOOST_AUTO_TEST_SUITE_END()
collateralized bond obligation data model
Serializable portfolio.
Definition: portfolio.hpp:43
void build(const QuantLib::ext::shared_ptr< EngineFactory > &, const std::string &context="unspecified", const bool emitStructuredError=true)
Call build on all trades in the portfolio, the context is included in error messages.
Definition: portfolio.cpp:122
QuantLib::ext::shared_ptr< Trade > get(const std::string &id) const
Definition: portfolio.cpp:194
void fromFile(const std::string &filename)
Definition: xmlutils.cpp:150
Market Datum Loader Implementation.
Curve configuration repository.
Portfolio class.
BOOST_AUTO_TEST_CASE(testSimpleCBO)
Definition: cbo.cpp:31
vector< string > curveConfigs
An concrete implementation of the Market class that loads todays market and builds the required curve...