Class CashFlowEquivalentCalculator


  • public final class CashFlowEquivalentCalculator
    extends Object
    Computes cash flow equivalent of products.

    Reference: Henrard, M. The Irony in the derivatives discounting Part II: the crisis. Wilmott Journal, 2010, 2, 301-316.

    • Method Detail

      • cashFlowEquivalentSwap

        public static ResolvedSwapLeg cashFlowEquivalentSwap​(ResolvedSwap swap,
                                                             RatesProvider ratesProvider)
        Computes cash flow equivalent of swap.

        The swap should be a fix-for-Ibor swap without compounding, and its swap legs should not involve PaymentEvent.

        The return type is ResolvedSwapLeg in which individual payments are represented in terms of NotionalExchange.

        Parameters:
        swap - the swap product
        ratesProvider - the rates provider
        Returns:
        the cash flow equivalent
      • cashFlowEquivalentIborLeg

        public static ResolvedSwapLeg cashFlowEquivalentIborLeg​(ResolvedSwapLeg iborLeg,
                                                                RatesProvider ratesProvider)
        Computes cash flow equivalent of Ibor leg.

        The return type is ResolvedSwapLeg in which individual payments are represented in terms of NotionalExchange.

        Parameters:
        iborLeg - the Ibor leg
        ratesProvider - the rates provider
        Returns:
        the cash flow equivalent
      • cashFlowEquivalentFixedLeg

        public static ResolvedSwapLeg cashFlowEquivalentFixedLeg​(ResolvedSwapLeg fixedLeg,
                                                                 RatesProvider ratesProvider)
        Computes cash flow equivalent of fixed leg.

        The return type is ResolvedSwapLeg in which individual payments are represented in terms of NotionalExchange.

        Parameters:
        fixedLeg - the fixed leg
        ratesProvider - the rates provider
        Returns:
        the cash flow equivalent
      • cashFlowEquivalentOnLeg

        public static ResolvedSwapLeg cashFlowEquivalentOnLeg​(ResolvedSwapLeg onLeg,
                                                              RatesProvider multicurve)
        Computes cash flow equivalent of overnight leg.

        Each payment period should contain one accrual period of type OvernightCompoundedRateComputation. When the payment date is not equal to the end composition date, the start and end cashflow equivalent are adjusted by the ratio of discount factors between the payment date and the end date.

        The return type is ResolvedSwapLeg in which individual payments are represented in terms of NotionalExchange.

        Parameters:
        onLeg - the overnight leg
        multicurve - the multi-curve rates provider
        Returns:
        the cash flow equivalent
      • cashFlowEquivalentAndSensitivitySwap

        public static ImmutableMap<Payment,​PointSensitivityBuilder> cashFlowEquivalentAndSensitivitySwap​(ResolvedSwap swap,
                                                                                                               RatesProvider ratesProvider)
        Computes cash flow equivalent and sensitivity of swap.

        The swap should be a fix-for-Ibor swap without compounding, and its swap legs should not involve PaymentEvent.

        The return type is a map of NotionalExchange and PointSensitivityBuilder.

        Parameters:
        swap - the swap product
        ratesProvider - the rates provider
        Returns:
        the cash flow equivalent and sensitivity
      • cashFlowEquivalentAndSensitivityIborLeg

        public static ImmutableMap<Payment,​PointSensitivityBuilder> cashFlowEquivalentAndSensitivityIborLeg​(ResolvedSwapLeg iborLeg,
                                                                                                                  RatesProvider ratesProvider)
        Computes cash flow equivalent and sensitivity of Ibor leg.

        The return type is a map of NotionalExchange and PointSensitivityBuilder.

        Parameters:
        iborLeg - the Ibor leg
        ratesProvider - the rates provider
        Returns:
        the cash flow equivalent and sensitivity
      • cashFlowEquivalentAndSensitivityFixedLeg

        public static ImmutableMap<Payment,​PointSensitivityBuilder> cashFlowEquivalentAndSensitivityFixedLeg​(ResolvedSwapLeg fixedLeg,
                                                                                                                   RatesProvider ratesProvider)
        Computes cash flow equivalent and sensitivity of fixed leg.

        The return type is a map of NotionalExchange and PointSensitivityBuilder.

        Parameters:
        fixedLeg - the fixed leg
        ratesProvider - the rates provider
        Returns:
        the cash flow equivalent and sensitivity
      • cashFlowEquivalentAndSensitivityOnLeg

        public static ImmutableMap<Payment,​PointSensitivityBuilder> cashFlowEquivalentAndSensitivityOnLeg​(ResolvedSwapLeg onLeg,
                                                                                                                RatesProvider multicurve)
        Computes cash flow equivalent of and sensitivity overnight leg.

        Each payment period should contain one accrual period of type OvernightCompoundedRateComputation. When the payment date is not equal to the end composition date, the start and end cashflow equivalent are adjusted by the ratio of discount factors between the payment date and the end date.

        The return type is a map of NotionalExchange and PointSensitivityBuilder.

        Parameters:
        onLeg - the overnight leg
        multicurve - the multi-curve rates provider
        Returns:
        the cash flow equivalent
      • normalize

        public static List<Payment> normalize​(ResolvedSwapLeg input)
        Extract the payments from the NotionalExchange in the SwapLeg. Generate a list with the dates sorted and the amounts of elements with same payment date compressed.

        The original SwapLeg is unchanged.

        Parameters:
        input - the starting swap leg
        Returns:
        the normalized list
      • normalize

        public static List<Payment> normalize​(List<Payment> input)
        Generate a new payment list with the dates sorted and the amounts of elements with same payment date compressed.

        The original list is unchanged.

        Parameters:
        input - the starting list
        Returns:
        the normalized list
      • normalize

        public static Map<Payment,​PointSensitivityBuilder> normalize​(Map<Payment,​PointSensitivityBuilder> input)
        Generate a new map with each payment date unique and the amounts and sensitivities of elements with same payment date compressed.

        The original map is unchanged.

        Parameters:
        input - the starting map
        Returns:
        the normalized map