21#include <ql/money.hpp>
22#include <ql/currencies/exchangeratemanager.hpp>
23#include <ql/math/comparison.hpp>
25#include <boost/format.hpp>
31 void convertTo(Money& m,
const Currency& target) {
32 if (m.currency() != target) {
36 m =
rate.exchange(m).rounded();
40 void convertToBase(Money& m) {
41 const auto & base_currency =
43 QL_REQUIRE(!base_currency.empty(),
"no base currency set");
44 convertTo(m, base_currency);
63 QL_FAIL(
"currency mismatch and no conversion specified");
82 QL_FAIL(
"currency mismatch and no conversion specified");
88 const auto & conversion_type =
103 QL_FAIL(
"currency mismatch and no conversion specified");
108 const auto & conversion_type =
123 QL_FAIL(
"currency mismatch and no conversion specified");
128 const auto & conversion_type =
143 QL_FAIL(
"currency mismatch and no conversion specified");
148 const auto & conversion_type =
163 QL_FAIL(
"currency mismatch and no conversion specified");
168 const auto & conversion_type =
177 return close(tmp1,tmp2,n);
181 return close(m1,tmp,n);
183 QL_FAIL(
"currency mismatch and no conversion specified");
188 const auto & conversion_type =
203 QL_FAIL(
"currency mismatch and no conversion specified");
210 fmt.exceptions(boost::io::all_error_bits ^
211 boost::io::too_many_args_bit);
225 return conversionType_;
230 return baseCurrency_;
235 return baseCurrency_;
243 Money::BaseCurrencyProxy::operator
Currency()
const {
const std::string & code() const
ISO 4217 three-letter code, e.g, "USD".
std::string format() const
output format
const std::string & symbol() const
symbol, e.g, "$"
ExchangeRate lookup(const Currency &source, const Currency &target, Date date=Date(), ExchangeRate::Type type=ExchangeRate::Derived) const
const Money::ConversionType & conversionType() const
Money::ConversionType conversionType_
const Currency & baseCurrency() const
Money & operator+=(const Money &)
const Currency & currency() const
Money & operator-=(const Money &)
static ExchangeRateManager & instance()
access to the unique instance
detail::percent_holder rate(Rate)
output rates and spreads as percentages
Real Decimal
decimal number
std::size_t Size
size of a container
bool operator==(const Currency &c1, const Currency &c2)
bool operator<(const Quantity &m1, const Quantity &m2)
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
bool close(const Quantity &m1, const Quantity &m2, Size n)
bool operator<=(const Quantity &m1, const Quantity &m2)
bool close_enough(const Quantity &m1, const Quantity &m2, Size n)
Real operator/(const Quantity &m1, const Quantity &m2)
BaseCurrencyProxy & operator=(const Currency &)
ConversionTypeProxy & operator=(Money::ConversionType)