com.ftlabs.fisa.calc.cd
Class CDLastPeriodCalculator

java.lang.Object
  extended by com.ftlabs.fisa.calc.AbstractCalculator
      extended by com.ftlabs.fisa.calc.LastPeriodCalculator
          extended by com.ftlabs.fisa.calc.cd.CDLastPeriodCalculator
All Implemented Interfaces:
Calculator, YieldConvergable, java.io.Serializable

public class CDLastPeriodCalculator
extends LastPeriodCalculator

See Also:
Serialized Form

Field Summary
protected  int interestFrequency
           
protected  double interestRate
           
protected  double parValue
           
protected  Redemption redemption
           
protected  FISADate settlementDate
           
protected  double taxAdjustedInterestRate
           
protected  double taxAdjustedRedemptionValue
           
protected  double yearFraction
           
 
Fields inherited from class com.ftlabs.fisa.calc.LastPeriodCalculator
act_df, aif, df, lcf
 
Constructor Summary
protected CDLastPeriodCalculator()
           
  CDLastPeriodCalculator(FISADate settlementDate, Redemption redemption, double parValue, double interestRate, DayCountBasis dayCountBasis, int interestFrequency, boolean eomAdjust)
           
 
Method Summary
 Analytics calculate(AnalyticValueType givenType, double givenValue)
          Calculate an Analytics object using the provided AnalyticValueType and value.
 double calculateAccruedInterest()
          Calculate the accrued interest to the settlement date.
 double calculateConvexity(double periodicYield)
          Calculate the actual convexity.
 double calculateCurrentYield(double price)
          Calculate current yield for the given price.
 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, given the Macaulay Duration.
 double calculatePeriodicYield(double price)
          Calculate a periodic discounted cash flow yield for use with convexity/duration methods.
 double calculatePrice(double yield)
          Calculate price for the given yield.
 double calculateYield(double price)
          Calculate yield for the given price.
 int getCashFlowCount()
          Get the number of cashflows within the supported settlement to Redemption period.
 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 getInterest(int cashFlowIndex)
          Get the interest 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.
 void setValues(FISADate settlementDate, Redemption redemption, double parValue, double interestRate, DayCountBasis dayCountBasis, int interestFrequency, boolean eomAdjust)
           
protected  void setValues(FISADate settlementDate, Redemption redemption, double parValue, int interestFrequency)
           
 
Methods inherited from class com.ftlabs.fisa.calc.LastPeriodCalculator
calculateEstimatedConvexity, calculateEstimatedMacaulayDuration, calculateEstimatedModifiedDuration, calculateEstimatedModifiedDuration, calculatePriceValue1BP, calculateYieldValue1_32, getPeriodicTimeToFlow, getPrincipal, getTimeToFlow, setValues
 
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
 

Field Detail

interestRate

protected double interestRate

yearFraction

protected double yearFraction

taxAdjustedInterestRate

protected double taxAdjustedInterestRate

taxAdjustedRedemptionValue

protected double taxAdjustedRedemptionValue

settlementDate

protected FISADate settlementDate

redemption

protected Redemption redemption

parValue

protected double parValue

interestFrequency

protected int interestFrequency
Constructor Detail

CDLastPeriodCalculator

protected CDLastPeriodCalculator()

CDLastPeriodCalculator

public CDLastPeriodCalculator(FISADate settlementDate,
                              Redemption redemption,
                              double parValue,
                              double interestRate,
                              DayCountBasis dayCountBasis,
                              int interestFrequency,
                              boolean eomAdjust)
                       throws CalculationException
Throws:
CalculationException
Method Detail

setValues

public void setValues(FISADate settlementDate,
                      Redemption redemption,
                      double parValue,
                      double interestRate,
                      DayCountBasis dayCountBasis,
                      int interestFrequency,
                      boolean eomAdjust)
               throws CalculationException
Throws:
CalculationException

calculateCurrentYield

public double calculateCurrentYield(double price)
                             throws CalculationException
Description copied from interface: Calculator
Calculate current yield for the given price.

Parameters:
price - price
Returns:
current yield as calculated for the given price.
Throws:
CalculationException

calculateYield

public double calculateYield(double price)
                      throws CalculationException
Description copied from interface: Calculator
Calculate yield for the given price.

Parameters:
price - price
Returns:
yield as calculated for the given price.
Throws:
CalculationException

calculatePrice

public double calculatePrice(double yield)
                      throws CalculationException
Description copied from interface: Calculator
Calculate price for the given yield.

Parameters:
yield - yield
Returns:
price as calculated for the given yield.
Throws:
CalculationException

calculateAccruedInterest

public double calculateAccruedInterest()
                                throws CalculationException
Description copied from interface: Calculator
Calculate the accrued interest to the settlement date.

Returns:
The accrued interest to the settlement date.
Throws:
CalculationException

getInterest

public double getInterest(int cashFlowIndex)
Description copied from interface: Calculator
Get the 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 interest to be paid for the specified cashflow.

setValues

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

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.

getCashFlowCount

public int getCashFlowCount()
Description copied from interface: Calculator
Get the number of cashflows within the supported settlement to Redemption period.

Returns:
The number of cashflows within the supported settlement to Redemption period.

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.

calculatePeriodicYield

public double calculatePeriodicYield(double price)
                              throws CalculationException
Calculate a periodic discounted cash flow yield for use with convexity/duration methods.

Parameters:
price - the price.
Returns:
Periodic discounted cash flow yield.
Throws:
CalculationException

calculateMacaulayDuration

public double calculateMacaulayDuration(double periodicYield)
                                 throws CalculationException
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
Calculate the actual modified 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
Calculate the actual modified duration, given the Macaulay Duration.

Parameters:
macaulayDuration - The macaulayDuration as returned from 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
Calculate the actual convexity.

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

calculate

public Analytics calculate(AnalyticValueType givenType,
                           double givenValue)
                    throws CalculationException
Description copied from interface: Calculator
Calculate an Analytics object using the provided AnalyticValueType and value.

Parameters:
givenType - The AnalyticValueType of the givenValue.
givenValue - The value to calculate the Analytics from.
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