QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
Public Types | List of all members
ExchangeRate Class Reference

exchange rate between two currencies More...

#include <exchangerate.hpp>

+ Collaboration diagram for ExchangeRate:

Public Types

enum  Type { Direct , Derived }
 

Public Member Functions

Constructors
 ExchangeRate ()
 
 ExchangeRate (Currency source, Currency target, Decimal rate)
 
Inspectors
const Currency & source () const
 the source currency. More...
 
const Currency & target () const
 the target currency. More...
 
Type type () const
 the type More...
 
Decimal rate () const
 the exchange rate (when available) More...
 

Utility methods

Currency source_
 
Currency target_
 
Decimal rate_
 
Type type_
 
std::pair< ext::shared_ptr< ExchangeRate >, ext::shared_ptr< ExchangeRate > > rateChain_
 
Money exchange (const Money &amount) const
 apply the exchange rate to a cash amount More...
 
static ExchangeRate chain (const ExchangeRate &r1, const ExchangeRate &r2)
 chain two exchange rates More...
 

Detailed Description

exchange rate between two currencies

Tests:
application of direct and derived exchange rate is tested against calculations.

Definition at line 38 of file exchangerate.hpp.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
Direct 

given directly by the user

Derived 

derived from exchange rates between other currencies

Definition at line 40 of file exchangerate.hpp.

Constructor & Destructor Documentation

◆ ExchangeRate() [1/2]

Definition at line 84 of file exchangerate.hpp.

◆ ExchangeRate() [2/2]

ExchangeRate ( Currency  source,
Currency  target,
Decimal  rate 
)

the rate \( r \) is given with the convention that a unit of the source is worth \( r \) units of the target.

Definition at line 86 of file exchangerate.hpp.

Member Function Documentation

◆ source()

const Currency & source ( ) const

the source currency.

Definition at line 89 of file exchangerate.hpp.

+ Here is the caller graph for this function:

◆ target()

const Currency & target ( ) const

the target currency.

Definition at line 93 of file exchangerate.hpp.

+ Here is the caller graph for this function:

◆ type()

ExchangeRate::Type type ( ) const

the type

Definition at line 97 of file exchangerate.hpp.

◆ rate()

Decimal rate ( ) const

the exchange rate (when available)

Definition at line 101 of file exchangerate.hpp.

+ Here is the caller graph for this function:

◆ exchange()

Money exchange ( const Money &  amount) const

apply the exchange rate to a cash amount

Definition at line 25 of file exchangerate.cpp.

+ Here is the call graph for this function:

◆ chain()

ExchangeRate chain ( const ExchangeRate &  r1,
const ExchangeRate &  r2 
)
static

chain two exchange rates

Definition at line 50 of file exchangerate.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ source_

Currency source_
private

Definition at line 74 of file exchangerate.hpp.

◆ target_

Currency target_
private

Definition at line 74 of file exchangerate.hpp.

◆ rate_

Decimal rate_
private

Definition at line 75 of file exchangerate.hpp.

◆ type_

Type type_
private

Definition at line 76 of file exchangerate.hpp.

◆ rateChain_

std::pair<ext::shared_ptr<ExchangeRate>, ext::shared_ptr<ExchangeRate> > rateChain_
private

Definition at line 78 of file exchangerate.hpp.