QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ExchangeRateManager Class Reference

exchange-rate repository More...

#include <exchangeratemanager.hpp>

+ Inheritance diagram for ExchangeRateManager:
+ Collaboration diagram for ExchangeRateManager:

Classes

struct  Entry
 

Public Member Functions

void add (const ExchangeRate &, const Date &startDate=Date::minDate(), const Date &endDate=Date::maxDate())
 Add an exchange rate. More...
 
ExchangeRate lookup (const Currency &source, const Currency &target, Date date=Date(), ExchangeRate::Type type=ExchangeRate::Derived) const
 
void clear ()
 remove the added exchange rates More...
 
- Public Member Functions inherited from Singleton< ExchangeRateManager >
 Singleton (const Singleton &)=delete
 
 Singleton (Singleton &&)=delete
 
Singletonoperator= (const Singleton &)=delete
 
Singletonoperator= (Singleton &&)=delete
 
 ~Singleton ()=default
 

Private Types

typedef BigInteger Key
 

Private Member Functions

 ExchangeRateManager ()
 
Key hash (const Currency &, const Currency &) const
 
bool hashes (Key, const Currency &) const
 
void addKnownRates ()
 
ExchangeRate directLookup (const Currency &source, const Currency &target, const Date &date) const
 
ExchangeRate smartLookup (const Currency &source, const Currency &target, const Date &date, std::list< Integer > forbiddenCodes=std::list< Integer >()) const
 
const ExchangeRatefetch (const Currency &source, const Currency &target, const Date &date) const
 

Private Attributes

std::map< Key, std::list< Entry > > data_
 

Friends

class Singleton< ExchangeRateManager >
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< ExchangeRateManager >
static ExchangeRateManagerinstance ()
 access to the unique instance More...
 
- Protected Member Functions inherited from Singleton< ExchangeRateManager >
 Singleton ()=default
 

Detailed Description

exchange-rate repository

Tests:
lookup of direct, triangulated, and derived exchange rates is tested.

Definition at line 41 of file exchangeratemanager.hpp.

Member Typedef Documentation

◆ Key

typedef BigInteger Key
private

Definition at line 81 of file exchangeratemanager.hpp.

Constructor & Destructor Documentation

◆ ExchangeRateManager()

ExchangeRateManager ( )
private

Definition at line 41 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

void add ( const ExchangeRate rate,
const Date startDate = Date::minDate(),
const Date endDate = Date::maxDate() 
)

Add an exchange rate.

The given rate is valid between the given dates.

Note
If two rates are given between the same currencies and with overlapping date ranges, the latest one added takes precedence during lookup.

Definition at line 45 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookup()

ExchangeRate lookup ( const Currency source,
const Currency target,
Date  date = Date(),
ExchangeRate::Type  type = ExchangeRate::Derived 
) const

Lookup the exchange rate between two currencies at a given date. If the given type is Direct, only direct exchange rates will be returned if available; if Derived, direct rates are still preferred but derived rates are allowed.

Warning:
if two or more exchange-rate chains are possible which allow to specify a requested rate, it is unspecified which one is returned.

Definition at line 52 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void clear ( )

remove the added exchange rates

Definition at line 84 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:

◆ hash()

ExchangeRateManager::Key hash ( const Currency c1,
const Currency c2 
) const
private

Definition at line 89 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hashes()

bool hashes ( ExchangeRateManager::Key  k,
const Currency c 
) const
private

Definition at line 95 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addKnownRates()

void addKnownRates ( )
private

Definition at line 100 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ directLookup()

ExchangeRate directLookup ( const Currency source,
const Currency target,
const Date date 
) const
private

Definition at line 137 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smartLookup()

ExchangeRate smartLookup ( const Currency source,
const Currency target,
const Date date,
std::list< Integer forbiddenCodes = std::list<Integer>() 
) const
private

Definition at line 148 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetch()

const ExchangeRate * fetch ( const Currency source,
const Currency target,
const Date date 
) const
private

Definition at line 194 of file exchangeratemanager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Singleton< ExchangeRateManager >

friend class Singleton< ExchangeRateManager >
friend

Definition at line 1 of file exchangeratemanager.hpp.

Member Data Documentation

◆ data_

std::map<Key, std::list<Entry> > data_
mutableprivate

Definition at line 82 of file exchangeratemanager.hpp.