Cash Flow

From Open Ideas
Jump to navigation Jump to search

Codebook

Construction

CashFlow objects can be created directly

double[] timeToMaturities = {0.5, 1.0, 1.5, 2.0};
double[] payments = {0.04, 0.04, 0.04, 1.04};
ICashFlow cf1 = CashFlow.create(timeToMaturities, payments);

or derived from other objects like bonds

IDay due = Day.create(2006, 05, 22);
IDay maturity = Day.create(2011, 05, 15);
IMarketBond bond = PeriodicBond.create(100.0, due, maturity, 0.06, 2);
IDay settlement = Day.create(2008, 8, 12);
ICashFlow cf2 = bond.toCashFlow(settlement.toDate());

Methods

CashFlow objects provide methods to determine the (sum of) discounted cash flow(s). This can be done by either specifying corresponding discount factors or an arbitrary term structure.

[continued...]
double[] discount_factors = {96.0, 92.0, 88.0, 85.0};
double dcf1 = cf1.dcf(discount_factors);    // dcf1 = 0.9944;
ILevelTermStructure term_structure = new FlatTS(0.05);  // default: continuously compounding 
double dcf2 = cf2.dcf(term_structure);   // dcf2 = 103.83424708237374

See also