Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
aggregationscenariodata.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>
21#include <oret/toplevelfixture.hpp>
23
24using namespace ore::analytics;
25using namespace boost::unit_test_framework;
26
27BOOST_FIXTURE_TEST_SUITE(OREAnalyticsTestSuite, ore::test::OreaTopLevelFixture)
28
29BOOST_AUTO_TEST_SUITE(AggregationScenarioDataTest)
30
31BOOST_AUTO_TEST_CASE(testInMemoryAggregationScenarioData) {
33
34 // write data
35 BOOST_CHECK_THROW(data.set(3, 0, 0.0, AggregationScenarioDataType::Generic, "blabla"), std::exception);
36 BOOST_CHECK_THROW(data.set(0, 5, 0.0, AggregationScenarioDataType::Generic, "blabla"), std::exception);
37
38 for (Size i = 0; i < 3; ++i) {
39 for (Size j = 0; j < 5; ++j) {
40 data.set(i, j, 0.0001 * i + 0.01 * j, AggregationScenarioDataType::IndexFixing, "OIS_EUR");
41 data.set(i, j, 0.1 + 0.0001 * i + 0.01 * j, AggregationScenarioDataType::IndexFixing, "OIS_USD");
42 data.set(i, j, 0.2 + 0.0001 * i + 0.01 * j, AggregationScenarioDataType::IndexFixing, "OIS_GBP");
43 data.set(i, j, i + 0.1 * j, AggregationScenarioDataType::FXSpot, "EURUSD");
44 data.set(i, j, 2.0 + i + 0.1 * j, AggregationScenarioDataType::FXSpot, "EURGBP");
45 }
46 }
47
48 // read data
49 BOOST_CHECK_THROW(data.get(3, 0, AggregationScenarioDataType::Generic, "blabla"), std::exception);
50 BOOST_CHECK_THROW(data.get(0, 5, AggregationScenarioDataType::Generic, "blabla"), std::exception);
51
52 Real tol = 1.0E-12;
53
54 for (Size i = 0; i < 3; ++i) {
55 for (Size j = 0; j < 5; ++j) {
56 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::IndexFixing, "OIS_EUR"),
57 0.0001 * i + 0.01 * j, tol);
58 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::IndexFixing, "OIS_USD"),
59 0.1 + 0.0001 * i + 0.01 * j, tol);
60 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::IndexFixing, "OIS_GBP"),
61 0.2 + 0.0001 * i + 0.01 * j, tol);
62 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::FXSpot, "EURUSD"), i + 0.1 * j, tol);
63 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::FXSpot, "EURGBP"), 2.0 + i + 0.1 * j, tol);
64 }
65 }
66}
67
68BOOST_AUTO_TEST_SUITE_END()
69
70BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(testInMemoryAggregationScenarioData)
this class holds data associated to scenarios
A concrete in memory implementation of AggregationScenarioData.
OREAnalytics Top level fixture.
data
Fixture that can be used at top level of OREAnalytics test suites.