QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
Classes | Related Functions | List of all members
Money Class Reference

amount of cash More...

#include <ql/money.hpp>

+ Collaboration diagram for Money:

Classes

struct  BaseCurrencyProxy
 
struct  ConversionTypeProxy
 
class  Settings
 Per-session settings for the Money class. More...
 

Public Member Functions

Constructors
 Money ()=default
 
 Money (Currency currency, Decimal value)
 
 Money (Decimal value, Currency currency)
 
Inspectors
const Currencycurrency () const
 
Decimal value () const
 
Money rounded () const
 
Money arithmetics

See below for non-member functions and for settings which determine the behavior of the operators.

Money operator+ () const
 
Money operator- () const
 
Moneyoperator+= (const Money &)
 
Moneyoperator-= (const Money &)
 
Moneyoperator*= (Decimal)
 
Moneyoperator/= (Decimal)
 

Related Functions

(Note that these are not member functions.)

Money operator+ (const Money &, const Money &)
 
Money operator- (const Money &, const Money &)
 
Money operator* (const Money &, Decimal)
 
Money operator* (Decimal, const Money &)
 
Money operator/ (const Money &, Decimal)
 
Decimal operator/ (const Money &, const Money &)
 
bool operator== (const Money &, const Money &)
 
bool operator!= (const Money &, const Money &)
 
bool operator< (const Money &, const Money &)
 
bool operator<= (const Money &, const Money &)
 
bool operator> (const Money &, const Money &)
 
bool operator>= (const Money &, const Money &)
 
bool close (const Money &, const Money &, Size n=42)
 
bool close_enough (const Money &, const Money &, Size n=42)
 
Money operator* (Decimal, const Currency &)
 
Money operator* (const Currency &, Decimal)
 
std::ostream & operator<< (std::ostream &, const Money &)
 

Conversion settings

These parameters are used for combining money amounts in different currencies

enum  ConversionType { NoConversion , BaseCurrencyConversion , AutomatedConversion }
 
Decimal value_ = 0.0
 
Currency currency_
 

Detailed Description

amount of cash

Tests:
money arithmetic is tested with and without currency conversions.

Definition at line 38 of file money.hpp.

Member Enumeration Documentation

◆ ConversionType

Enumerator
NoConversion 

do not perform conversions

BaseCurrencyConversion 

convert both operands to the base currency before converting

AutomatedConversion 

return the result in the currency of the first operand

Definition at line 71 of file money.hpp.

Constructor & Destructor Documentation

◆ Money() [1/3]

Money ( )
default

◆ Money() [2/3]

Money ( Currency  currency,
Decimal  value 
)

Definition at line 167 of file money.hpp.

◆ Money() [3/3]

Money ( Decimal  value,
Currency  currency 
)

Definition at line 170 of file money.hpp.

Member Function Documentation

◆ currency()

const Currency & currency ( ) const

Definition at line 173 of file money.hpp.

+ Here is the caller graph for this function:

◆ value()

Decimal value ( ) const

Definition at line 177 of file money.hpp.

+ Here is the caller graph for this function:

◆ rounded()

Money rounded ( ) const

Definition at line 181 of file money.hpp.

+ Here is the caller graph for this function:

◆ operator+()

Money operator+ ( ) const

Definition at line 185 of file money.hpp.

◆ operator-()

Money operator- ( ) const

Definition at line 189 of file money.hpp.

◆ operator+=()

Money & operator+= ( const Money m)

Definition at line 49 of file money.cpp.

+ Here is the call graph for this function:

◆ operator-=()

Money & operator-= ( const Money m)

Definition at line 68 of file money.cpp.

+ Here is the call graph for this function:

◆ operator*=()

Money & operator*= ( Decimal  x)

Definition at line 193 of file money.hpp.

◆ operator/=()

Money & operator/= ( Decimal  x)

Definition at line 198 of file money.hpp.

Friends And Related Function Documentation

◆ operator+()

Money operator+ ( const Money ,
const Money  
)
related

Definition at line 204 of file money.hpp.

◆ operator-()

Money operator- ( const Money ,
const Money  
)
related

Definition at line 210 of file money.hpp.

◆ operator*() [1/4]

Money operator* ( const Money ,
Decimal   
)
related

Definition at line 216 of file money.hpp.

◆ operator*() [2/4]

Money operator* ( Decimal  ,
const Money  
)
related

Definition at line 222 of file money.hpp.

◆ operator/() [1/2]

Money operator/ ( const Money ,
Decimal   
)
related

Definition at line 226 of file money.hpp.

◆ operator/() [2/2]

Decimal operator/ ( const Money ,
const Money  
)
related

Definition at line 87 of file money.cpp.

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const Money ,
const Money  
)
related

Definition at line 107 of file money.cpp.

+ Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const Money ,
const Money  
)
related

Definition at line 232 of file money.hpp.

◆ operator<()

bool operator< ( const Money ,
const Money  
)
related

Definition at line 127 of file money.cpp.

+ Here is the call graph for this function:

◆ operator<=()

bool operator<= ( const Money ,
const Money  
)
related

Definition at line 147 of file money.cpp.

+ Here is the call graph for this function:

◆ operator>()

bool operator> ( const Money ,
const Money  
)
related

Definition at line 236 of file money.hpp.

◆ operator>=()

bool operator>= ( const Money ,
const Money  
)
related

Definition at line 240 of file money.hpp.

◆ close()

bool close ( const Money ,
const Money ,
Size  n = 42 
)
related

Definition at line 167 of file money.cpp.

+ Here is the call graph for this function:

◆ close_enough()

bool close_enough ( const Money ,
const Money ,
Size  n = 42 
)
related

Definition at line 187 of file money.cpp.

+ Here is the call graph for this function:

◆ operator*() [3/4]

Money operator* ( Decimal  ,
const Currency  
)
related

Definition at line 244 of file money.hpp.

◆ operator*() [4/4]

Money operator* ( const Currency ,
Decimal   
)
related

Definition at line 248 of file money.hpp.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  ,
const Money  
)
related

Definition at line 208 of file money.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ value_

Decimal value_ = 0.0
private

Definition at line 84 of file money.hpp.

◆ currency_

Currency currency_
private

Definition at line 85 of file money.hpp.