QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
currency.cpp
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
32 Currency::Data::Data(std::string name,
33 std::string code,
34 Integer numericCode,
35 std::string symbol,
36 std::string fractionSymbol,
37 Integer fractionsPerUnit,
38 const Rounding& rounding,
39 std::string formatString,
40 Currency triangulationCurrency,
41 std::set<std::string> minorUnitCodes)
42 : name(std::move(name)), code(std::move(code)), numeric(numericCode), symbol(std::move(symbol)),
43 fractionSymbol(std::move(fractionSymbol)), fractionsPerUnit(fractionsPerUnit),
44 rounding(rounding), triangulated(std::move(triangulationCurrency)),
45 formatString(std::move(formatString)), minorUnitCodes(std::move(minorUnitCodes)) {}
46
47 Currency::Currency(const std::string& name,
48 const std::string& code,
50 const std::string& symbol,
51 const std::string& fractionSymbol,
53 const Rounding& rounding,
54 const std::string& formatString,
56 const std::set<std::string>& minorUnitCodes)
57 : data_(ext::make_shared<Currency::Data>(name,
58 code,
60 symbol,
64 formatString,
67}
68
Currency specification
Definition: currency.hpp:36
const Rounding & rounding() const
rounding convention
Definition: currency.hpp:167
const std::string & code() const
ISO 4217 three-letter code, e.g, "USD".
Definition: currency.hpp:142
const std::string & name() const
currency name, e.g, "U.S. Dollar"
Definition: currency.hpp:137
bool empty() const
is this a usable instance?
Definition: currency.hpp:177
Integer numericCode() const
ISO 4217 numeric code, e.g, "840".
Definition: currency.hpp:147
const std::set< std::string > & minorUnitCodes() const
minor unit codes, e.g. GBp, GBX for GBP
Definition: currency.hpp:186
Integer fractionsPerUnit() const
number of fractionary parts in a unit, e.g, 100
Definition: currency.hpp:162
const Currency & triangulationCurrency() const
currency used for triangulated exchange when required
Definition: currency.hpp:181
ext::shared_ptr< Data > data_
Definition: currency.hpp:91
const std::string & fractionSymbol() const
fraction symbol, e.g, "ยข"
Definition: currency.hpp:157
const std::string & symbol() const
symbol, e.g, "$"
Definition: currency.hpp:152
Currency()=default
default constructor
basic rounding class
Definition: rounding.hpp:35
QL_INTEGER Integer
integer number
Definition: types.hpp:35
Definition: any.hpp:35
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
STL namespace.
Data(std::string name, std::string code, Integer numericCode, std::string symbol, std::string fractionSymbol, Integer fractionsPerUnit, const Rounding &rounding, std::string formatString, Currency triangulationCurrency=Currency(), std::set< std::string > minorUnitCodes={})
Definition: currency.cpp:32