org.jquantlib.currencies
Class ExchangeRateManager
- java.lang.Object
-
- org.jquantlib.currencies.ExchangeRateManager
-
public class ExchangeRateManager extends java.lang.ObjectExchange rate Repository.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classExchangeRateManager.EntryEntity to be stored in the repository.static classExchangeRateManager.Valid_atHelper class to decide whether or a date is in the range of a specific entry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(ExchangeRate rate)Adds an exchange rate to the repository.voidadd(ExchangeRate rate, Date startDate, Date endDate)Adds an exchange rate.voidclear()Removes all manually added exchange rates from this ExchangeRateManager.ExchangeRatefetch(Currency source, Currency target, Date date)Fetches an ExchangeRate from the HashMap.static ExchangeRateManagergetInstance()Returns a singleton of the ExchangeRateManager.inthash(Currency c1, Currency c2)Creates a hash for two currencies.booleanhashes(int k, Currency c)???????????????????????????????????????????????ExchangeRatelookup(Currency source, Currency target)Looks up an ExchangeRate in the repository.ExchangeRatelookup(Currency source, Currency target, Date date)ExchangeRatelookup(Currency source, Currency target, Date date, ExchangeRate.Type type)Lookup the exchange rate between two currencies at a given date.
-
-
-
Method Detail
-
getInstance
public static ExchangeRateManager getInstance()
Returns a singleton of the ExchangeRateManager.- Returns:
- The ExchangeRateManager shared by everything loaded with this classloader.
-
add
public void add(ExchangeRate rate, Date startDate, Date endDate)
Adds 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.- Parameters:
rate- The ExchangeRate to be addedstartDate- The start date of the period for which the above Exchange rate should be valid.endDate- The end date of the period for which the above Exchange rate should be valid.
-
add
public void add(ExchangeRate rate)
Adds an exchange rate to the repository. The given rate is valid between min and max Date (implementation dependend).- Parameters:
rate-
-
lookup
public ExchangeRate lookup(Currency source, Currency target)
Looks up an ExchangeRate in the repository.- Parameters:
source- The source currency the Exchange rates must have.target- The source currency the Exchange rates must have.- Returns:
-
lookup
public ExchangeRate lookup(Currency source, Currency target, Date date)
-
lookup
public ExchangeRate lookup(Currency source, Currency target, Date date, ExchangeRate.Type type)
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.- Parameters:
source- The source currency of the exchange rate to be found. Currencytarget- The target currency of the exchange rate to be found. Currencydate- The date when this exchange rate should be valid. Datetype- The type of the exchange rate. ExchangeRate.Type- Returns:
- The exchange rate fulfilling all these properties. ExchangeRate
-
clear
public void clear()
Removes all manually added exchange rates from this ExchangeRateManager.
-
hash
public int hash(Currency c1, Currency c2)
Creates a hash for two currencies.- Parameters:
c1- Currency one. Currencyc2- Currency two. Currency- Returns:
- A hash of these to currencies. int
-
hashes
public boolean hashes(int k, Currency c)???????????????????????????????????????????????- Parameters:
k-c-- Returns:
-
fetch
public ExchangeRate fetch(Currency source, Currency target, Date date)
Fetches an ExchangeRate from the HashMap.- Parameters:
source- The source currency of the exchange rate.target- The target currency of the exchange rate.date- The date when the exchange rate should be valid.- Returns:
- The found ExchangeRate.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG