com.ftlabs.fisa.calc
Class MultipleCashFlowCalculator

java.lang.Object
  extended by com.ftlabs.fisa.calc.AbstractCalculator
      extended by com.ftlabs.fisa.calc.MultipleCashFlowCalculator
All Implemented Interfaces:
Calculator, YieldConvergable, java.io.Serializable
Direct Known Subclasses:
MultiplePeriodCalculator

public abstract class MultipleCashFlowCalculator
extends AbstractCalculator

See Also:
Serialized Form

Field Summary
protected  boolean eomAdjust
           
protected  int interestFrequency
           
protected  FISADate nextCouponDate
           
protected  double parValue
           
protected  Redemption redemption
           
protected  FISADate settlementDate
           
 
Constructor Summary
protected MultipleCashFlowCalculator()
           
protected MultipleCashFlowCalculator(FISADate settlementDate, Redemption redemption, double parValue, int interestFrequency, boolean eomAdjust, FISADate firstInterestDate)
           
 
Method Summary
 double calculateConvexity(double periodicYield)
          Calculate the actual convexity.
 double calculateEstimatedMacaulayDuration(double pv1b, double price, double yield)
          Calculate the estimated Macaulay duration.
 double calculateEstimatedModifiedDuration(double duration, double yield)
          Calculate the estimated modified duration.
 double calculateEstimatedModifiedDuration(double pv1b, double price, double yield)
          Calculate the estimated modified duration.
 double calculateInterestOnInterest(double reinvestmentYield)
          Calculate the interest earned on reinvested interest cashflows using the provided reinvestmentYield.
 double calculateMacaulayDuration(double periodicYield)
          Calculate the actual Macaulay duration.
 double calculateModifiedDuration(double periodicYield)
          Calculate the actual modified duration.
 double calculateModifiedDuration(double macaulayDuration, double periodicYield)
          Calculate the actual modified duration using an already calculated Macaulay Duration.
 double calculateYieldValue1_32(double pv1b)
          Calculate the average yield value obtained by varying the price up and down 1/32.
 FISADate getCashFlowDate(int cashFlowIndex)
          Get a cash flow date for a particular cashflow, as specified by the provided cashFlowIndex.
 void getCashFlowDate(int cashFlowIndex, FISADate date)
          Set the provided FISADate to the cash flow date of a particular cashflow, as specified by the provided cashFlowIndex.
 double getPrincipal(int cashFlowIndex)
          Get the principal to be paid for a particular cashflow, as specified by cashFlowIndex.
 Redemption getRedemption()
          Get the Redemption to which this Calculator is bound.
 FISADate getSettlementDate()
          Get the settlement date to which this Calculator is bound.
 double getTotalCashFlow(int cashFlowIndex)
          Get the principal and interest to be paid for a particular cashflow, as specified by cashFlowIndex.
protected  void setValues(FISADate settlementDate, Redemption redemption, double parValue, int interestFrequency, boolean eomAdjust, FISADate firstInterestDate)
           
 
Methods inherited from class com.ftlabs.fisa.calc.AbstractCalculator
calculateApproximateYield, calculateMPCIPrice, calculateSPSIPrice, calculateSPSIYield, calculateTotalInterestFlows
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ftlabs.fisa.calc.Calculator
calculate, calculateAccruedInterest, calculateCurrentYield, calculateEstimatedConvexity, calculatePeriodicYield, calculatePrice, calculatePriceValue1BP, calculateYield, getCashFlowCount, getInterest, getPeriodicTimeToFlow, getTimeToFlow
 

Field Detail

settlementDate

protected FISADate settlementDate

redemption

protected Redemption redemption

parValue

protected double parValue

interestFrequency

protected int interestFrequency

eomAdjust

protected boolean eomAdjust

nextCouponDate

protected FISADate nextCouponDate
Constructor Detail

MultipleCashFlowCalculator

protected MultipleCashFlowCalculator()

MultipleCashFlowCalculator

protected MultipleCashFlowCalculator(FISADate settlementDate,
                                     Redemption redemption,
                                     double parValue,
                                     int interestFrequency,
                                     boolean eomAdjust,
                                     FISADate firstInterestDate)
Method Detail

setValues

protected void setValues(FISADate settlementDate,
                         Redemption redemption,
                         double parValue,
                         int interestFrequency,
                         boolean eomAdjust,
                         FISADate firstInterestDate)

getSettlementDate

public FISADate getSettlementDate()
Description copied from interface: Calculator
Get the settlement date to which this Calculator is bound.

Returns:
Settlement date.

getRedemption

public Redemption getRedemption()
Description copied from interface: Calculator
Get the Redemption to which this Calculator is bound.

Returns:
Redemption.

getPrincipal

public double getPrincipal(int cashFlowIndex)
Description copied from interface: Calculator
Get the principal to be paid for a particular cashflow, as specified by cashFlowIndex.

Parameters:
cashFlowIndex - The cashflow index. cashFlowIndex is zero based and must be a number from 0 to getCashFlowCount() - 1.
Returns:
The principal to be paid for the specified cashflow.

getTotalCashFlow

public double getTotalCashFlow(int cashFlowIndex)
Description copied from interface: Calculator
Get the principal and interest to be paid for a particular cashflow, as specified by cashFlowIndex.

Parameters:
cashFlowIndex - The cashflow index. cashFlowIndex is zero based and must be a number from 0 to getCashFlowCount() - 1.
Returns:
The principal + interest to be paid for the specified cashflow.

getCashFlowDate

public FISADate getCashFlowDate(int cashFlowIndex)
Description copied from interface: Calculator
Get a cash flow date for a particular cashflow, as specified by the provided cashFlowIndex.

Parameters:
cashFlowIndex - The cashflow index. cashFlowIndex is zero based and must be a number from 0 to getCashFlowCount() - 1.
Returns:
The cash flow date for the provided cash flow index.

getCashFlowDate

public void getCashFlowDate(int cashFlowIndex,
                            FISADate date)
Description copied from interface: Calculator
Set the provided FISADate to the cash flow date of a particular cashflow, as specified by the provided cashFlowIndex.

Parameters:
cashFlowIndex - The cashflow index. cashFlowIndex is zero based and must be a number from 0 to getCashFlowCount() - 1.
date - A FISADate to be set to the specified cash flow date.

calculateMacaulayDuration

public double calculateMacaulayDuration(double periodicYield)
                                 throws CalculationException
Description copied from interface: Calculator
Calculate the actual Macaulay duration.

Parameters:
periodicYield - The periodicYield as returned from the calculatePeriodicYield method.
Returns:
Macaulay duration.
Throws:
CalculationException

calculateModifiedDuration

public double calculateModifiedDuration(double periodicYield)
                                 throws CalculationException
Description copied from interface: Calculator
Calculate the actual modified duration. If Macaulay Duration has already been calculated, then it is more efficient to use the overloaded calculateModifiedDuration method that accepts the Macaulay Duration.

Parameters:
periodicYield - The periodicYield as returned from the calculatePeriodicYield method.
Returns:
modified duration.
Throws:
CalculationException

calculateModifiedDuration

public double calculateModifiedDuration(double macaulayDuration,
                                        double periodicYield)
                                 throws CalculationException
Description copied from interface: Calculator
Calculate the actual modified duration using an already calculated Macaulay Duration.

Parameters:
macaulayDuration - The Macaulay Duration as calculated by the calculateMacaulayDuration method.
periodicYield - The periodicYield as returned from the calculatePeriodicYield method.
Returns:
modified duration.
Throws:
CalculationException

calculateConvexity

public double calculateConvexity(double periodicYield)
                          throws CalculationException
Description copied from interface: Calculator
Calculate the actual convexity.

Parameters:
periodicYield - The periodicYield as returned from the calculatePeriodicYield method.
Returns:
convexity.
Throws:
CalculationException

calculateYieldValue1_32

public double calculateYieldValue1_32(double pv1b)
                               throws CalculationException
Description copied from interface: Calculator
Calculate the average yield value obtained by varying the price up and down 1/32.

Parameters:
pv1b - The average price value obtained by varying the yield up and down one basis point, as returned by the calculatePriceValue1BP method.
Returns:
the average yield value obtained by varying the price up and down 1/32.
Throws:
CalculationException

calculateEstimatedMacaulayDuration

public double calculateEstimatedMacaulayDuration(double pv1b,
                                                 double price,
                                                 double yield)
                                          throws CalculationException
Description copied from interface: Calculator
Calculate the estimated Macaulay duration.

Parameters:
pv1b - The average price value obtained by varying the yield up and down one basis point, as returned by the calculatePriceValue1BP method.
price - the price.
yield - the yield.
Returns:
estimated Macaulay duration.
Throws:
CalculationException

calculateEstimatedModifiedDuration

public double calculateEstimatedModifiedDuration(double pv1b,
                                                 double price,
                                                 double yield)
                                          throws CalculationException
Description copied from interface: Calculator
Calculate the estimated modified duration.

Parameters:
pv1b - The average price value obtained by varying the yield up and down one basis point, as returned by the calculatePriceValue1BP method.
price - the price.
yield - the yield.
Returns:
estimated modified duration.
Throws:
CalculationException

calculateEstimatedModifiedDuration

public double calculateEstimatedModifiedDuration(double duration,
                                                 double yield)
                                          throws CalculationException
Description copied from interface: Calculator
Calculate the estimated modified duration.

Parameters:
duration - the estimated Macaulay Duration.
yield - the yield.
Returns:
estimated modified duration.
Throws:
CalculationException

calculateInterestOnInterest

public double calculateInterestOnInterest(double reinvestmentYield)
                                   throws CalculationException
Description copied from interface: Calculator
Calculate the interest earned on reinvested interest cashflows using the provided reinvestmentYield.

Parameters:
reinvestmentYield - The assumed yield of the reinvested interest cashflows.
Returns:
The interest earned on reinvested interest cashflows.
Throws:
CalculationException