Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
currency.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 "toplevelfixture.hpp"
20#include <boost/test/unit_test.hpp>
21#include <ql/currencies/all.hpp>
22#include <ql/currency.hpp>
28
29using namespace QuantLib;
30using namespace QuantExt;
31using namespace boost::unit_test_framework;
32using namespace std;
33
34namespace {
35
36struct CcyTestData {
37 Currency ccy;
38 string name;
39 string code;
40 int numCode;
41};
42
43static CcyTestData currencyData[] = {
44 // African currencies
45 { TNDCurrency(), "Tunisian dinar", "TND", 788 },
46 { EGPCurrency(), "Egyptian pound", "EGP", 818 },
47 { MADCurrency(), "Moroccan dirham", "MAD", 504 },
48 // American currencies
49 { MXVCurrency(), "Mexican Unidad de Inversion", "MXV", 979 },
50 { CLFCurrency(), "Unidad de Fomento (funds code)", "CLF", 990 },
51 { UYUCurrency(), "Uruguayan peso", "UYU", 858 },
52 // Asian currencies
53 { KZTCurrency(), "Kazakstanti Tenge", "KZT", 398 }, // note the typo in the QuantLib KZT
54 { QARCurrency(), "Qatari riyal", "QAR", 634 },
55 { BHDCurrency(), "Bahraini dinar", "BHD", 48 },
56 { OMRCurrency(), "Omani rial", "OMR", 512 },
57 { AEDCurrency(), "United Arab Emirates dirham", "AED", 784 },
58 { PHPCurrency(), "Philippine peso", "PHP", 608 },
59 { XAUCurrency(), "Troy Ounce of Gold", "XAU", 959 },
60 { XAGCurrency(), "Troy Ounce of Silver", "XAG", 961 },
61 { XPDCurrency(), "Troy Ounce of Palladium", "XPD", 964 },
62 { XPTCurrency(), "Troy Ounce of Platinum", "XPT", 962 },
63 { AOACurrency(), "Angolan kwanza", "AOA", 973 },
64 { ETBCurrency(), "Ethiopian birr", "ETB", 230 },
65 { XOFCurrency(), "West African CFA franc", "XOF", 952 },
66 // European currencies
67 { GELCurrency(), "Georgian lari", "GEL", 981 }
68};
69} // namespace
70
71BOOST_FIXTURE_TEST_SUITE(QuantExtTestSuite, qle::test::TopLevelFixture)
72
73BOOST_AUTO_TEST_SUITE(CurrencyTest)
74
75BOOST_AUTO_TEST_CASE(testCurrency) {
76
77 BOOST_TEST_MESSAGE("Testing QuantExt currencies");
78
79 Size size = sizeof(currencyData) / sizeof(currencyData[0]);
80
81 for (Size i = 0; i < size; i++) {
82 BOOST_CHECK_EQUAL(currencyData[i].ccy.name(), currencyData[i].name);
83 BOOST_CHECK_EQUAL(currencyData[i].ccy.code(), currencyData[i].code);
84 BOOST_CHECK_EQUAL(currencyData[i].ccy.numericCode(), currencyData[i].numCode);
85 }
86}
87
88BOOST_AUTO_TEST_SUITE_END()
89
90BOOST_AUTO_TEST_SUITE_END()
Extend QuantLib African currencies.
Extend QuantLib American currencies.
Extend QuantLib Asian currencies.
Troy ounce of Silver.
Definition: metals.hpp:48
Troy ounce of Gold.
Definition: metals.hpp:39
Troy ounce of Palladium.
Definition: metals.hpp:66
Troy ounce of Platinum.
Definition: metals.hpp:57
BOOST_AUTO_TEST_CASE(testCurrency)
Definition: currency.cpp:75
Extend QuantLib European currencies.
Extend QuantLib currencies for precious metal codes.
Fixture that can be used at top level.