19#include <boost/make_shared.hpp>
20#include <boost/test/unit_test.hpp>
22#include <oret/toplevelfixture.hpp>
23#include <ql/quotes/simplequote.hpp>
29using ore::test::TopLevelFixture;
34vector<pair<string, Real>> fxtData() {
37 vector<pair<string, Real>> testData{
42 {
"EURGBP", 0.74519 },
50 {
"AUDNZD", 1.0616327848 }
58class FxTriFixture :
public TopLevelFixture {
64 std::map<std::string, Handle<Quote>> quotes;
65 for (
const auto& p : fxtData()) {
66 Handle<Quote> q(QuantLib::ext::make_shared<SimpleQuote>(p.second));
77BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, TopLevelFixture)
79BOOST_FIXTURE_TEST_SUITE(FXTriangulationTests, FxTriFixture)
82 for (
const auto& p : fxtData()) {
83 BOOST_CHECK_EQUAL(fx.
getQuote(p.first)->value(), p.second);
88 BOOST_CHECK_EQUAL(fx.
getQuote(
"EUREUR")->value(), 1.0);
89 BOOST_CHECK_EQUAL(fx.
getQuote(
"USDUSD")->value(), 1.0);
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);
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);
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);
118 BOOST_CHECK_CLOSE(fx.
getQuote(
"USDNZD")->value(), 1.6450 / 1.0861, tol);
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);
127BOOST_AUTO_TEST_SUITE_END()
129BOOST_AUTO_TEST_SUITE_END()
QuantLib::Handle< QuantLib::Quote > getQuote(const std::string &pair) const
Intelligent FX price repository.
BOOST_AUTO_TEST_CASE(testDataLoaded)