Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxdom.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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>
22
23using namespace boost::unit_test_framework;
24using namespace std;
25
26BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
27
28BOOST_AUTO_TEST_SUITE(FXDominanceTest)
29
30BOOST_AUTO_TEST_CASE(testFXDominance) {
31 BOOST_TEST_MESSAGE("Testing FXDominance...");
32
33 // List of pairs - we split them up and try both ways
34 const char* expectedPairs[] = {
35 "EURUSD", "GBPUSD", "AUDUSD", "CADJPY", "AUDJPY", "EURNOK", "EURJPY", "EURSEK", "EURCHF", "EURNOK", "NOKJPY",
36 "NOKSEK", "DKKSEK", "CNYJPY", "JPYIDR",
37
38 // another longer list - might have duplicates
39 "AUDCAD", "AUDCHF", "AUDJPY", "AUDNZD", "AUDUSD", "CADJPY", "CADMXN", "CADNOK", "CHFJPY", "EURAUD", "EURCAD",
40 "EURCHF", "EURCZK", "EURDKK", "EURGBP", "EURHUF", "EURJPY", "EURKRW", "EURMXN", "EURNOK", "EURNZD", "EURPLN",
41 "EURRUB", "EURSEK", "EURTRY", "EURUSD", "EURZAR", "GBPAUD", "GBPCAD", "GBPCHF", "GBPJPY", "GBPNOK", "GBPUSD",
42 "JPYKRW", "MXNJPY", "NOKSEK", "NZDCAD", "NZDCHF", "NZDJPY", "NZDUSD", "TRYJPY", "USDCAD", "USDCHF", "USDCNH",
43 "USDCZK", "USDDKK", "USDHKD", "USDHUF", "USDILS", "USDJPY", "USDMXN", "USDNOK", "USDOMR", "USDPLN", "USDRON",
44 "USDRUB", "USDSEK", "USDSGD", "USDTHB", "USDTRY", "USDZAR",
45
46 // XXX for unknown ccys
47 "XXXJPY", "EURXXX", "USDXXX",
48
49 // Some metals
50 "XAUUSD", "XAGUSD", "XPTUSD", "XPDUSD", "XAUEUR", "XAGEUR", "XPTAUD"};
51
52 for (unsigned i = 0; i < sizeof(expectedPairs) / sizeof(expectedPairs[0]); i++) {
53 string expectedPair = expectedPairs[i];
54 string s1 = expectedPair.substr(0, 3);
55 string s2 = expectedPair.substr(3);
56
57 BOOST_TEST_MESSAGE("Combining " << s1 << " and " << s2 << " expecting " << expectedPair);
58 string pair = ore::data::fxDominance(s1, s2);
59 BOOST_CHECK_EQUAL(pair, expectedPair);
60
61 BOOST_TEST_MESSAGE("Combining " << s2 << " and " << s1 << " expecting " << expectedPair);
62 pair = ore::data::fxDominance(s2, s1);
63 BOOST_CHECK_EQUAL(pair, expectedPair);
64 }
65}
66
67BOOST_AUTO_TEST_SUITE_END()
68
69BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(testFXDominance)
Definition: fxdom.cpp:30
string fxDominance(const string &s1, const string &s2)
Convert FX pair to market standard dominance.
Definition: parsers.cpp:1296
Map text representations to QuantLib/QuantExt types.