Compounding

From Open Ideas
Jump to: navigation, search

Definition

See Wikipedia:Compound interest for a definition.

Codebook

The class IRConverter (IR = interest rate) is the workhorse for converting spot rates, forward rates and discount factors. In this section it is explained how one can switch from one compounding method to another one. The conversion between the financial quantities is shown in the spot rate and forward rate article, respectively. Suppose you have a reference to a continuously compounded spot rate and you intend to convert it to a periodically compounded spot rate. This can be performed as follows:

IInterestRate spot_rate = InterestRate.create(0.05, 0.25, Compounding.CONTINUOUS);
IRConverter.convertCompounding(spot_rate, Compounding.PERIODIC);
double level = spot_rate.getLevel();   // level = 0.05127109637602412

The class IRConverter is extensively used by classes representing term structures. A term structure has an internal compounding and an external compounding. The internal compounding describes the true method used to generate the term structure. By default, the internal and external compounding methods are equal. If the external compounding is set to a different method, then the converted interest rates are returned. The following example demonstrates the idea

ILevelTS term_structure = FlatTS.create(0.05);   // creates a flat term structure at a 5 % level; default: continuously compounding
term_structure.setExternalCompounding(Compounding.PERIODIC);
double spot_level = ts.spotRate(0.25)   // spot_level = 0.05127109637602412

Of course, we obtain the same result as above.

See also