Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
cbo.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <ored/portfolio/cbo.hpp>
#include <ored/portfolio/builders/cbo.hpp>
#include <oret/toplevelfixture.hpp>
#include <oret/datapaths.hpp>
#include <ored/configuration/curveconfigurations.hpp>
#include <ored/marketdata/csvloader.hpp>
#include <ored/marketdata/todaysmarket.hpp>
#include <ored/portfolio/portfolio.hpp>
#include <iostream>
#include <iomanip>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testSimpleCBO)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( testSimpleCBO  )

Definition at line 31 of file cbo.cpp.

31 {
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}
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
vector< string > curveConfigs
+ Here is the call graph for this function: