57 {
58 BOOST_TEST_MESSAGE("Testing Fx Accumulator...");
59
63
64 Settings::instance().evaluationDate() = Date(31, Dec, 2018);
65 Date asof = Settings::instance().evaluationDate();
66
68 conventions->fromFile(TEST_INPUT_FILE("conventions.xml"));
70
72 todaysMarketParams->fromFile(TEST_INPUT_FILE("todaysmarket.xml"));
74 curveConfigs->fromFile(TEST_INPUT_FILE("curveconfig.xml"));
76 QuantLib::ext::make_shared<
CSVLoader>(TEST_INPUT_FILE("market.txt"), TEST_INPUT_FILE("fixings.txt"), false);
79
80
82 engineData->fromFile(TEST_INPUT_FILE("pricingengine.xml"));
84
85
86 struct cleanup {
87 ~cleanup() { ore::data::ScriptLibraryStorage::instance().
clear(); }
88 } cleanup;
90 library.
fromFile(TEST_INPUT_FILE(
"scriptlibrary.xml"));
91 ore::data::ScriptLibraryStorage::instance().set(std::move(library));
92
93
95 string trade = "FX_Accumulator";
96 string portfolioFile = trade + ".xml";
97 p.
fromFile(TEST_INPUT_FILE(portfolioFile));
98 BOOST_CHECK_NO_THROW(p.
build(factory));
99
100
101
102 BOOST_CHECK_NO_THROW(p.
get(
"FX_ACCUMULATOR_1")->instrument()->NPV());
103 BOOST_TEST_MESSAGE(p.
get(
"FX_ACCUMULATOR_1")->instrument()->NPV() * 1.1469);
104 BOOST_TEST_MESSAGE(p.
get(
"FX_FORWARD_1")->instrument()->NPV());
105
106 BOOST_CHECK_CLOSE(p.
get(
"FX_ACCUMULATOR_1")->instrument()->NPV() * 1.1469,
107 p.
get(
"FX_FORWARD_1")->instrument()->NPV(), 0.01);
108
109
110
111 BOOST_CHECK_CLOSE(p.
get(
"FX_ACCUMULATOR_2")->instrument()->NPV() * 1.1469,
112 p.
get(
"FX_FORWARD_2A")->instrument()->NPV() + p.
get(
"FX_FORWARD_2B")->instrument()->NPV() +
113 p.
get(
"FX_FORWARD_2C")->instrument()->NPV(),
114 0.01);
115
116
117
118 BOOST_CHECK_CLOSE(p.
get(
"FX_ACCUMULATOR_3")->instrument()->NPV() * 1.1469,
119 (p.
get(
"FX_ACCUMULATOR_3A")->instrument()->NPV() +
120 p.
get(
"FX_ACCUMULATOR_3B")->instrument()->NPV() +
121 p.
get(
"FX_ACCUMULATOR_3C")->instrument()->NPV()) *
122 1.1469,
123 0.01);
124}
Utility class for loading market quotes and fixings from a file.
Repository for currency dependent market conventions.
Container class for all Curve Configurations.
Pricing engine description.
Pricing Engine Factory class.
void clear()
Clear all builders.
Singleton to hold conventions.
Market data loader base class.
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.
QuantLib::ext::shared_ptr< Trade > get(const std::string &id) const
Today's Market Parameters.
void fromFile(const std::string &filename)
#define ORE_REGISTER_TRADE_BUILDER(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_ENGINE_BUILDER(CLASS, OVERWRITE)
Serializable Credit Default Swap.
vector< string > curveConfigs