Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

CashFlow.cpp

Go to the documentation of this file.
00001 #include "./cashflow.h"
00002 
00003 CashFlow::CashFlow(SwapLeg swapLeg, Real fixedRate)
00004 {
00005         flowAmount=swapLeg.returnAmounts();
00006         flowDates=swapLeg.returnDates();
00007         Date d;
00008         d.setDateToToday();
00009         flowAmount[0]=flowAmount[0]*fixedRate*(flowDates[0].serialNumber()-d.serialNumber())/365.0;
00010         for (Natural i=1;i<flowDates.size();i++) {
00011                 flowAmount[i]=flowAmount[i]*fixedRate*(flowDates[i].serialNumber()-flowDates[i-1].serialNumber())/365.0;
00012         }
00013 }
00014 
00015 CashFlow::CashFlow(SwapLeg swapLeg, yieldCurve floatCurve)
00016 {
00017         flowAmount=swapLeg.returnAmounts();
00018         flowDates=swapLeg.returnDates();
00019         Date d;
00020         d.setDateToToday();
00021         flowAmount[0]=flowAmount[0]*floatCurve.forwardRate(d,flowDates[0],Discrete)*(flowDates[0].serialNumber()-d.serialNumber())/365.0;
00022         for (Natural i=1;i<flowDates.size();i++) {
00023                 flowAmount[i]=flowAmount[i]*floatCurve.forwardRate(flowDates[i-1],flowDates[i],Discrete)*(flowDates[i].serialNumber()-flowDates[i-1].serialNumber())/365.0;
00024         }
00025 }
00026 
00027 Real CashFlow::getFairValue(yieldCurve* curve)
00028 {
00029         Real result=0;
00030         for (Natural i=0;i<flowAmount.size();i++) {
00031                 result+=flowAmount[i]*curve->discountFactor(flowDates[i],Discrete);
00032         }
00033         return result;
00034 }
00035 
00036 CashFlow::~CashFlow(void)
00037 {
00038 }

Note: Generated nightly - reload for latest version
Generated on Thu Dec 22 23:12:35 2005 for terreneuve by doxygen 1.3.6