Business components : Business components : Branch application components : Foreign Exchange : Concepts
  
Concepts
See also
Home currency
Conversion currency
Foreign Exchange layer
Rates Provider layer
Rates Repository layer
Foreign Exchange
Home currency
The home currency is the currency that a financial institution uses to conduct business. When determining the buy and sell rates, Foreign exchange treats the home currency as the source (the from currency), and the currency that is being bought or sold as the destination (the to currency).
See also
Concepts
Conversion currency
The conversion currency is the currency that a financial institution uses to calculate a foreign exchange when a direct conversion rate between two currencies does not exist. For example, a customer of a Peruvian bank wants to convert Peruvian sols to Canadian dollars, the bank does not have a direct conversion rate between the two, so the bank first converts the sols to US dollars (the bank's conversion currency) and then converts the US dollars to the Canadian dollars.
To complete the coverage for the Foreign Exchange component, the datastorage containing the foreign exchange rates should contain the foreign exchange rates between the conversion currency and every other currency in the world.
See also
Concepts
Foreign Exchange layer
The ForeignExchange is the interface to the Foreign Exchange component. Client application of the component has to keep a reference to the interface to call the conversion methods, which decouples the implementation of the component with the client application.
The ForeignExchangeImpl is the implementation of currency conversion logic which is mainly related with the amount of currencies. It obtains the settings used to customize the component, such as the conversion currency, the rate cache refresh interval from the XML file. It is also responsible for passing each Foreign Exchange rate query request to its sub-layers, the Rates Provider layer.
The Foreign Exchange Layer is also responsible for caching rates, in order to reduce the number of rate retrieval requests that the ForeignExchangeImpl sends to the Rates Provider Layer. Before calling the RatesProvider to query the rates, the ForeignExchangeImpl checks the cache to see if the rates it needs are contained there.
To prevent rates in the cache from becoming stale, the cache clears the rates from time to time. It compares the time when the rates were last cached with the time of the current attempt to retrieve them from the cache. If the result of the comparison exceeds a specified time limit, which is referred as rates refresh interval, the cache is emptied. If this is the case, the ForeignExchangeImpl retrieves fresh rates from the server (through its sub-layers). If it does obtain fresh rates, it adds them to the cache.
See also
Concepts
Rates Provider layer
The responsibility of the Rates Provider layer is to provide rate conversion service to the Foreign Exchange Layer. Given an arbitrary pair of currencies and their monetary item type, the Rates Provider Layer returns the sell rate or the buy rate to the caller according to the request. The RatesProviderImpl is a default implementation of this function. When querying an exchange rate between two currencies, the RatesProviderImpl firstly checks whether the direct conversion rate is available between the two. If a direct rate does not exist, it uses the conversion currency to perform the calculation.
For example, a financial institution has to convert Mexican pesos (in Traveler's check) to Canadian dollars (in cash). If a direct conversion rate exists between the two, that rate is returned. If not, the RatesProviderImpl tries to convert the pesos Traveler's check into the conversion currency in Traveler's check. If no conversion rate exists between the two, the provider converts the pesos Traveler's check into the conversion currency in cash (the basic monetary item), then converts the conversion currency to the Canadian dollars.
The rate conversion process is an example of the functionality of the Rates Provider layer. You must implement your own process according to your business requirements. The raw conversion rates (rates in the storage with no conversion) needed by the Rates Provider layer are provided by the Rates Repository layer.
See also
Concepts
Rates Repository layer
The raw foreign exchange rates are typically stored in datastorage, such as DB2 database. The Rates Repository layer's responsibility is to decouple the rate conversion algorithm from the concrete datastorage of the raw rates.
The RatesRepositoryFileImpl is an implementation of retrieving raw rates from XML file by leveraging the UDTT ElementFactory, while the RatesRepositoryDB2Impl retrieves rates from a FxRates table in a DB2 database.
Rates table
The rates table stores the foreign exchange rates information. Following is a typical design of the rates table schema:
 
Column
Description
SQL Type
Size
Java Type
FROMCURRENCY (PK)
Identifies the source currency.
CHAR
3
String
TOCURRENCY (PK)
Identifies the destination currency.
CHAR
3
String
FROMMONETARYITEM (PK)
Identifies how the financial institution received the source currency.
CHAR
2
String
TOMONETARYITEM (PK)
Identifies how the financial institution received the destination currency.
CHAR
2
String
BUYRATE
Contains the rate at which the financial institution buys the destination currency. Its format is fixed to six significant digits.
CHAR
8
String
SELLRATE
Contains the rate at which the financial institution sells the destination currency. Its format is fixed to six significant digits.
CHAR
9
String
See also
Concepts