com.ftlabs.fisa.calc
Class PerpetualPreferredCalculator

java.lang.Object
  extended by com.ftlabs.fisa.calc.PreferredCalculator
      extended by com.ftlabs.fisa.calc.PerpetualPreferredCalculator
All Implemented Interfaces:
Calculator, YieldConvergable, java.io.Serializable

public class PerpetualPreferredCalculator
extends PreferredCalculator

An implementation of Calculator for Perpetual Preferred securities.

See Also:
Serialized Form

Constructor Summary
PerpetualPreferredCalculator(FISADate tradeDate, FISADate settlementDate, double parValue, double interestRate, InterestFrequency interestFrequency, DayCountBasis dayCountBasis, boolean eomAdjust, FISADate datedDate, FISADate dividendPaymentDate, FISADate exDividendDate)
          Create a new PreferredFixedCouponCalculator.
 
Method Summary
 Analytics calculate(AnalyticValueType givenType, double givenValue)
          Calculate an Analytics object using the provided AnalyticValueType and value.
 double calculateConvexity(double periodicYield)
          Calculate the actual convexity.
 double calculateCurrentYield(double price)
          Calculate current yield for the given price.
 double calculateEstimatedConvexity(double pv1b, double price, double yield)
          Calculate the estimated 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 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 calculatePriceValue1BP(double price, double yield)
          Calculate the average price value obtained by varying the yield up and down one basis point.
 double calculateTotalInterestFlows()
          A convenience method to total all interest cashflows between the settlement to redemption period.
 double calculateYield(double price)
          Calculate yield for the given price.
 double calculateYieldValue1_32(double price)
          Calculate the average yield value obtained by varying the price up and down 1/32.
 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.
protected  Calculator getDelegate()
           
 double getInterest(int cashFlowIndex)
          Get the interest to be paid for a particular cashflow, as specified by cashFlowIndex.
 double getPeriodicTimeToFlow(int cashFlowIndex)
          Get the periodic time to flow as calculated with an actual day count method for a particular cashflow, as specified by 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 getTimeToFlow(int cashFlowIndex)
          Get the time to flow for a particular cashflow, as specified by cashFlowIndex.
 double getTotalCashFlow(int cashFlowIndex)
          Get the principal and interest to be paid for a particular cashflow, as specified by cashFlowIndex.
protected  void setDelegate(Calculator _delegate)
           
 void setValues(FISADate tradeDate, FISADate settlementDate, double parValue, double interestRate, InterestFrequency interestFrequency, DayCountBasis dayCountBasis, boolean eomAdjust, FISADate datedDate, FISADate dividendPaymentDate, FISADate exDividendDate)
           
 
Methods inherited from class com.ftlabs.fisa.calc.PreferredCalculator
calculateAccruedDividend, calculateAccruedInterest, calculateAnnualDividend, calculateStripPrice, calculateStripYield, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerpetualPreferredCalculator

public PerpetualPreferredCalculator(FISADate tradeDate,
                                    FISADate settlementDate,
                                    double parValue,
                                    double interestRate,
                                    InterestFrequency interestFrequency,
                                    DayCountBasis dayCountBasis,
                                    boolean eomAdjust,
                                    FISADate datedDate,
                                    FISADate dividendPaymentDate,
                                    FISADate exDividendDate)
                             throws CalculationException
Create a new PreferredFixedCouponCalculator.

Throws:
CalculationException
Method Detail

setValues

public void setValues(FISADate tradeDate,
                      FISADate settlementDate,
                      double parValue,
                      double interestRate,
                      InterestFrequency interestFrequency,
                      DayCountBasis dayCountBasis,
                      boolean eomAdjust,
                      FISADate datedDate,
                      FISADate dividendPaymentDate,
                      FISADate exDividendDate)
               throws CalculationException
Throws:
CalculationException

setDelegate

protected void setDelegate(Calculator _delegate)

getDelegate

protected Calculator getDelegate()

getSettlementDate

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

Specified by:
getSettlementDate in interface Calculator
Returns:
Settlement date.

getRedemption

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

Specified by:
getRedemption in interface Calculator
Returns:
Redemption.

calculatePrice

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

Specified by:
calculatePrice in interface Calculator
Specified by:
calculatePrice in interface YieldConvergable
Parameters:
yield - yield
Returns:
price as calculated for the given yield.
Throws:
CalculationException

calculateYield

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

Specified by:
calculateYield in interface Calculator
Parameters:
price - price
Returns:
yield as calculated for the given price.
Throws:
CalculationException

calculateCurrentYield

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

Specified by:
calculateCurrentYield in interface Calculator
Parameters:
price - price
Returns:
current yield as calculated for the given price.
Throws:
CalculationException

getCashFlowCount

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

Specified by:
getCashFlowCount in interface Calculator
Returns:
The number of cashflows within the supported settlement to Redemption period.

calculatePeriodicYield

public double calculatePeriodicYield(double price)
                              throws CalculationException
Description copied from interface: Calculator
Calculate a periodic discounted cash flow yield for use with convexity/duration methods.

Specified by:
calculatePeriodicYield in interface Calculator
Parameters:
price - the price.
Returns:
Periodic discounted cash flow yield.
Throws:
CalculationException

calculateMacaulayDuration

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

Specified by:
calculateMacaulayDuration in interface Calculator
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.

Specified by:
calculateModifiedDuration in interface Calculator
Parameters:
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.

Specified by:
calculateConvexity in interface Calculator
Parameters:
periodicYield - The periodicYield as returned from the calculatePeriodicYield method.
Returns:
convexity.
Throws:
CalculationException

calculateYieldValue1_32

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

Specified by:
calculateYieldValue1_32 in interface Calculator
Parameters:
price - 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

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.

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

Specified by:
getInterest in interface Calculator
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.

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.

Specified by:
getPrincipal in interface Calculator
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.

Specified by:
getTotalCashFlow in interface Calculator
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.

getTimeToFlow

public double getTimeToFlow(int cashFlowIndex)
Description copied from interface: Calculator
Get the time to flow for a particular cashflow, as specified by cashFlowIndex.

Specified by:
getTimeToFlow in interface Calculator
Parameters:
cashFlowIndex - The cashflow index. cashFlowIndex is zero based and must be a number from 0 to getCashFlowCount() - 1.
Returns:
The time to flow for the specified cashflow.

getPeriodicTimeToFlow

public double getPeriodicTimeToFlow(int cashFlowIndex)
Description copied from interface: Calculator
Get the periodic time to flow as calculated with an actual day count method for a particular cashflow, as specified by cashFlowIndex. This value is generally used in actual convexity and duration methods.

Specified by:
getPeriodicTimeToFlow in interface Calculator
Parameters:
cashFlowIndex - The cashflow index. cashFlowIndex is zero based and must be a number from 0 to getCashFlowCount() - 1.
Returns:
The periodic time to flow as calculated with an actual day count method 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.

Specified by:
getCashFlowDate in interface Calculator
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.

Specified by:
getCashFlowDate in interface Calculator
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.

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.

Specified by:
calculateModifiedDuration in interface Calculator
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

calculatePriceValue1BP

public double calculatePriceValue1BP(double price,
                                     double yield)
                              throws CalculationException
Description copied from interface: Calculator
Calculate the average price value obtained by varying the yield up and down one basis point.

Specified by:
calculatePriceValue1BP in interface Calculator
Returns:
the average price value obtained by varying the yield up and down one basis point.
Throws:
CalculationException

calculateEstimatedMacaulayDuration

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

Specified by:
calculateEstimatedMacaulayDuration in interface Calculator
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.

Specified by:
calculateEstimatedModifiedDuration in interface Calculator
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.

Specified by:
calculateEstimatedModifiedDuration in interface Calculator
Parameters:
duration - the estimated Macaulay Duration.
yield - the yield.
Returns:
estimated modified duration.
Throws:
CalculationException

calculateEstimatedConvexity

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

Specified by:
calculateEstimatedConvexity in interface Calculator
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 convexity.
Throws:
CalculationException

calculateTotalInterestFlows

public double calculateTotalInterestFlows()
                                   throws CalculationException
Description copied from interface: Calculator
A convenience method to total all interest cashflows between the settlement to redemption period.

Specified by:
calculateTotalInterestFlows in interface Calculator
Returns:
The total interest cashflows between the settlement to redemption period.
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.

Specified by:
calculateInterestOnInterest in interface Calculator
Parameters:
reinvestmentYield - The assumed yield of the reinvested interest cashflows.
Returns:
The interest earned on reinvested interest cashflows.
Throws:
CalculationException