QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
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
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 Currency triangulationCurrency,
40 std::set<std::string> minorUnitCodes)
41 : name(std::move(name)), code(std::move(code)), numeric(numericCode), symbol(std::move(symbol)),
42 fractionSymbol(std::move(fractionSymbol)), fractionsPerUnit(fractionsPerUnit),
43 rounding(rounding), triangulated(std::move(triangulationCurrency)),
44 minorUnitCodes(std::move(minorUnitCodes)) {}
45
46 Currency::Currency(const std::string& name,
47 const std::string& code,
49 const std::string& symbol,
50 const std::string& fractionSymbol,
52 const Rounding& rounding,
54 const std::set<std::string>& minorUnitCodes)
55 : data_(ext::make_shared<Currency::Data>(name,
56 code,
58 symbol,
64
65}
Currency specification
Definition: currency.hpp:36
const Rounding & rounding() const
rounding convention
Definition: currency.hpp:160
const std::string & code() const
ISO 4217 three-letter code, e.g, "USD".
Definition: currency.hpp:135
const std::string & name() const
currency name, e.g, "U.S. Dollar"
Definition: currency.hpp:130
bool empty() const
is this a usable instance?
Definition: currency.hpp:165
Integer numericCode() const
ISO 4217 numeric code, e.g, "840".
Definition: currency.hpp:140
const std::set< std::string > & minorUnitCodes() const
minor unit codes, e.g. GBp, GBX for GBP
Definition: currency.hpp:174
Integer fractionsPerUnit() const
number of fractionary parts in a unit, e.g, 100
Definition: currency.hpp:155
const Currency & triangulationCurrency() const
currency used for triangulated exchange when required
Definition: currency.hpp:169
ext::shared_ptr< Data > data_
Definition: currency.hpp:85
const std::string & fractionSymbol() const
fraction symbol, e.g, "ยข"
Definition: currency.hpp:150
const std::string & symbol() const
symbol, e.g, "$"
Definition: currency.hpp:145
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:37
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, Currency triangulationCurrency=Currency(), std::set< std::string > minorUnitCodes={})
Definition: currency.cpp:32