QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
currency.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004, 2007 StatPro Italia srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#include <ql/currency.hpp>
21#include <utility>
22
23namespace QuantLib {
24
25 std::ostream& operator<<(std::ostream& out, const Currency& c) {
26 if (!c.empty())
27 return out << c.code();
28 else
29 return out << "null currency";
30 }
31
33
34 Currency::Data::Data(std::string name,
35 std::string code,
36 Integer numericCode,
37 std::string symbol,
38 std::string fractionSymbol,
39 Integer fractionsPerUnit,
40 const Rounding& rounding,
41 Currency triangulationCurrency,
42 std::set<std::string> minorUnitCodes)
43 : name(std::move(name)), code(std::move(code)), numeric(numericCode), symbol(std::move(symbol)),
44 fractionSymbol(std::move(fractionSymbol)), fractionsPerUnit(fractionsPerUnit),
45 rounding(rounding), triangulated(std::move(triangulationCurrency)),
46 minorUnitCodes(std::move(minorUnitCodes)) {}
47
49 std::string code,
51 std::string symbol,
52 std::string fractionSymbol,
54 const Rounding& rounding,
55 std::string formatString,
57 std::set<std::string> minorUnitCodes)
58 : name(std::move(name)), code(std::move(code)), numeric(numericCode), symbol(std::move(symbol)),
60 rounding(rounding), triangulated(std::move(triangulationCurrency)),
61 formatString(std::move(formatString)), minorUnitCodes(std::move(minorUnitCodes)) {}
62
63 Currency::Currency(const std::string& name,
64 const std::string& code,
66 const std::string& symbol,
67 const std::string& fractionSymbol,
69 const Rounding& rounding,
71 const std::set<std::string>& minorUnitCodes)
72 : data_(ext::make_shared<Currency::Data>(name,
73 code,
75 symbol,
81
82 Currency::Currency(const std::string& name,
83 const std::string& code,
84 Integer numericCode,
85 const std::string& symbol,
86 const std::string& fractionSymbol,
87 Integer fractionsPerUnit,
88 const Rounding& rounding,
89 const std::string& formatString,
90 const Currency& triangulationCurrency,
91 const std::set<std::string>& minorUnitCodes)
92 : data_(ext::make_shared<Currency::Data>(name,
93 code,
94 numericCode,
95 symbol,
96 fractionSymbol,
97 fractionsPerUnit,
98 rounding,
99 formatString,
100 triangulationCurrency,
101 minorUnitCodes)) {}
102
104
105}
Currency specification
Definition: currency.hpp:36
const Rounding & rounding() const
rounding convention
Definition: currency.hpp:203
const std::string & code() const
ISO 4217 three-letter code, e.g, "USD".
Definition: currency.hpp:178
const std::string & name() const
currency name, e.g, "U.S. Dollar"
Definition: currency.hpp:173
bool empty() const
is this a usable instance?
Definition: currency.hpp:217
Integer numericCode() const
ISO 4217 numeric code, e.g, "840".
Definition: currency.hpp:183
const std::set< std::string > & minorUnitCodes() const
minor unit codes, e.g. GBp, GBX for GBP
Definition: currency.hpp:226
Integer fractionsPerUnit() const
number of fractionary parts in a unit, e.g, 100
Definition: currency.hpp:198
const Currency & triangulationCurrency() const
currency used for triangulated exchange when required
Definition: currency.hpp:221
ext::shared_ptr< Data > data_
Definition: currency.hpp:108
const std::string & fractionSymbol() const
fraction symbol, e.g, "ยข"
Definition: currency.hpp:193
const std::string & symbol() const
symbol, e.g, "$"
Definition: currency.hpp:188
Currency()=default
default constructor
basic rounding class
Definition: rounding.hpp:35
Currency specification.
QL_INTEGER Integer
integer number
Definition: types.hpp:35
Definition: any.hpp:35
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
STL namespace.
#define QL_DEPRECATED_DISABLE_WARNING
Definition: qldefines.hpp:216
#define QL_DEPRECATED_ENABLE_WARNING
Definition: qldefines.hpp:217
QL_DEPRECATED Data(std::string name, std::string code, Integer numericCode, std::string symbol, std::string fractionSymbol, Integer fractionsPerUnit, const Rounding &rounding, Currency triangulationCurrency=Currency(), std::set< std::string > minorUnitCodes={})
Definition: currency.cpp:34