Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
currencyparser.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 Quaternion Risk Management Ltd
3
4 This file is part of ORE, a free-software/open-source library
5 for transparent pricing and risk analysis - http://opensourcerisk.org
6
7 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10 The license is also available online at <http://opensourcerisk.org>
11
12 This program is distributed on the basis that it will form a useful
13 contribution to risk analytics and model standardisation, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
16*/
17
18/*! \file ored/utilities/currencyparser.hpp
19 \brief currency parser singleton class
20 \ingroup utilities
21*/
22
23#pragma once
24
25#include <map>
26#include <ql/currency.hpp>
27#include <ql/patterns/singleton.hpp>
28#include <ql/time/calendar.hpp>
29
30#include <boost/thread/lock_types.hpp>
31#include <boost/thread/shared_mutex.hpp>
32
33namespace ore {
34namespace data {
35
36class CurrencyParser : public QuantLib::Singleton<CurrencyParser, std::integral_constant<bool, true>> {
37public:
39
40 QuantLib::Currency parseCurrency(const std::string& name) const;
41 QuantLib::Currency parseMinorCurrency(const std::string& name) const;
42 QuantLib::Currency parseCurrencyWithMinors(const std::string& name) const;
43 std::pair<QuantLib::Currency, QuantLib::Currency> parseCurrencyPair(const std::string& name,
44 const std::string& delimiters) const;
45
46 void addCurrency(const std::string& newName, const QuantLib::Currency& currency);
47 void addMetal(const std::string& newName, const QuantLib::Currency& currency);
48 void addCrypto(const std::string& newName, const QuantLib::Currency& currency);
49
50 bool isValidCurrency(const std::string& name) const;
51 bool isMinorCurrency(const std::string& name) const;
52 bool isPseudoCurrency(const std::string& name) const;
53 bool isPreciousMetal(const std::string& name) const;
54 bool isCryptoCurrency(const std::string& name) const;
55
56 bool hasMinorCurrency(const std::string& name) const;
57 std::string getMinorCurrency(const std::string& name) const;
58
59 std::set<std::string> pseudoCurrencyCodes() const;
60
61 QuantLib::Real convertMinorToMajorCurrency(const std::string& s, QuantLib::Real value);
62
63 void reset();
64
65private:
66 void addMinorCurrencyCodes(const QuantLib::Currency& currency);
67
68 mutable boost::shared_mutex mutex_;
69 std::map<std::string, QuantLib::Currency> currencies_;
70 std::map<std::string, QuantLib::Currency> minorCurrencies_;
71 std::map<std::string, QuantLib::Currency> preciousMetals_;
72 std::map<std::string, QuantLib::Currency> cryptoCurrencies_;
73};
74
75} // namespace data
76} // namespace ore
std::set< std::string > pseudoCurrencyCodes() const
void addCrypto(const std::string &newName, const QuantLib::Currency &currency)
void addMinorCurrencyCodes(const QuantLib::Currency &currency)
std::map< std::string, QuantLib::Currency > minorCurrencies_
bool isCryptoCurrency(const std::string &name) const
std::string getMinorCurrency(const std::string &name) const
bool isPreciousMetal(const std::string &name) const
QuantLib::Real convertMinorToMajorCurrency(const std::string &s, QuantLib::Real value)
std::map< std::string, QuantLib::Currency > cryptoCurrencies_
std::map< std::string, QuantLib::Currency > currencies_
bool isPseudoCurrency(const std::string &name) const
bool isMinorCurrency(const std::string &name) const
std::pair< QuantLib::Currency, QuantLib::Currency > parseCurrencyPair(const std::string &name, const std::string &delimiters) const
QuantLib::Currency parseCurrency(const std::string &name) const
QuantLib::Currency parseCurrencyWithMinors(const std::string &name) const
bool isValidCurrency(const std::string &name) const
QuantLib::Currency parseMinorCurrency(const std::string &name) const
boost::shared_mutex mutex_
std::map< std::string, QuantLib::Currency > preciousMetals_
void addCurrency(const std::string &newName, const QuantLib::Currency &currency)
void addMetal(const std::string &newName, const QuantLib::Currency &currency)
bool hasMinorCurrency(const std::string &name) const
SafeStack< ValueType > value
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string name