Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
fxtriangulation.cpp File Reference
#include <boost/make_shared.hpp>
#include <boost/test/unit_test.hpp>
#include <ored/marketdata/fxtriangulation.hpp>
#include <oret/toplevelfixture.hpp>
#include <ql/quotes/simplequote.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testDataLoaded)
 
 BOOST_AUTO_TEST_CASE (testUnity)
 
 BOOST_AUTO_TEST_CASE (testValues)
 
 BOOST_AUTO_TEST_CASE (testMoreThanOneStep)
 
 BOOST_AUTO_TEST_CASE (testBadInputsThrow)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( testDataLoaded  )

Definition at line 81 of file fxtriangulation.cpp.

81 {
82 for (const auto& p : fxtData()) {
83 BOOST_CHECK_EQUAL(fx.getQuote(p.first)->value(), p.second);
84 }
85}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( testUnity  )

Definition at line 87 of file fxtriangulation.cpp.

87 {
88 BOOST_CHECK_EQUAL(fx.getQuote("EUREUR")->value(), 1.0);
89 BOOST_CHECK_EQUAL(fx.getQuote("USDUSD")->value(), 1.0);
90}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( testValues  )

Definition at line 92 of file fxtriangulation.cpp.

92 {
93
94 // Tolerance for comparisons
95 Real tol = 1e-12;
96
97 // Check inverse
98 BOOST_CHECK_CLOSE(fx.getQuote("USDEUR")->value(), 1.0 / 1.0861, tol);
99 BOOST_CHECK_CLOSE(fx.getQuote("JPYEUR")->value(), 1.0 / 128.51, tol);
100
101 // Check Triangulation
102 BOOST_CHECK_CLOSE(fx.getQuote("USDJPY")->value(), 128.51 / 1.0861, tol);
103 BOOST_CHECK_CLOSE(fx.getQuote("JPYUSD")->value(), 1.0861 / 128.51, tol);
104 BOOST_CHECK_CLOSE(fx.getQuote("USDGBP")->value(), 0.74519 / 1.0861, tol);
105 BOOST_CHECK_CLOSE(fx.getQuote("GBPUSD")->value(), 1.0861 / 0.74519, tol);
106 BOOST_CHECK_CLOSE(fx.getQuote("NOKSEK")->value(), 9.2640 / 9.6810, tol);
107
108 // Check Triangulation where the EUR quote is reversed
109 BOOST_CHECK_CLOSE(fx.getQuote("ZZZUSD")->value(), 3.141 * 1.0861, tol);
110 BOOST_CHECK_CLOSE(fx.getQuote("USDZZZ")->value(), 1 / (3.141 * 1.0861), tol);
111}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( testMoreThanOneStep  )

Definition at line 113 of file fxtriangulation.cpp.

113 {
114
115 // Larger tolerance for multiple steps
116 Real tol = 1e-8;
117
118 BOOST_CHECK_CLOSE(fx.getQuote("USDNZD")->value(), 1.6450 / 1.0861, tol);
119}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( testBadInputsThrow  )

Definition at line 121 of file fxtriangulation.cpp.

121 {
122 BOOST_CHECK_THROW(fx.getQuote("BadInput"), QuantLib::Error);
123 BOOST_CHECK_THROW(fx.getQuote(""), QuantLib::Error);
124 BOOST_CHECK_THROW(fx.getQuote("MXNZAR"), QuantLib::Error);
125}
+ Here is the call graph for this function: