Class DiscountingSwapLegPricer


  • public class DiscountingSwapLegPricer
    extends Object
    Pricer for for rate swap legs.

    This function provides the ability to price a ResolvedSwapLeg. The product is priced by pricing each period and event.

    • Method Detail

      • presentValue

        public CurrencyAmount presentValue​(ResolvedSwapLeg leg,
                                           Currency currency,
                                           RatesProvider provider)
        Calculates the present value of the swap leg, converted to the specified currency.

        The present value of the leg is the value on the valuation date. This is the discounted forecast value. The result is converted to the specified currency.

        Parameters:
        leg - the leg
        currency - the currency to convert to
        provider - the rates provider
        Returns:
        the present value of the swap leg in the specified currency
      • presentValue

        public CurrencyAmount presentValue​(ResolvedSwapLeg leg,
                                           RatesProvider provider)
        Calculates the present value of the swap leg.

        The present value of the leg is the value on the valuation date. This is the discounted forecast value. The result is returned using the payment currency of the leg.

        Parameters:
        leg - the leg
        provider - the rates provider
        Returns:
        the present value of the swap leg
      • forecastValue

        public CurrencyAmount forecastValue​(ResolvedSwapLeg leg,
                                            RatesProvider provider)
        Calculates the forecast value of the swap leg.

        The forecast value of the leg is the value on the valuation date without present value discounting. The result is returned using the payment currency of the leg.

        Parameters:
        leg - the leg
        provider - the rates provider
        Returns:
        the forecast value of the swap leg
      • accruedInterest

        public CurrencyAmount accruedInterest​(ResolvedSwapLeg leg,
                                              RatesProvider provider)
        Calculates the accrued interest since the last payment.

        This determines the payment period applicable at the valuation date and calculates the accrued interest since the last payment. The result is returned using the payment currency of the leg.

        Parameters:
        leg - the leg
        provider - the rates provider
        Returns:
        the accrued interest of the swap leg
      • pvbp

        public double pvbp​(ResolvedSwapLeg leg,
                           RatesProvider provider)
        Computes the Present Value of a Basis Point for a swap leg.

        The Present Value of a Basis Point is the value of the leg when the rate is equal to 1. A better name would be "Present Value of 1". The quantity is also known as "physical annuity" or "level".

        Each period must not have FX reset or compounding. They must not be of type KnownAmountSwapPaymentPeriod.

        Parameters:
        leg - the swap leg
        provider - the rates provider
        Returns:
        the Present Value of a Basis Point
      • couponEquivalent

        public double couponEquivalent​(ResolvedSwapLeg leg,
                                       RatesProvider provider,
                                       double pvbp)
        Calculates the coupon equivalent of a swap leg.

        The coupon equivalent is the common fixed coupon for all the periods which would result in the same present value of the leg.

        This is used in particular for swaption pricing with a model on the swap rate.

        Parameters:
        leg - the swap leg
        provider - the rates provider
        pvbp - the present value of a basis point
        Returns:
        the fixed coupon equivalent
      • presentValueSensitivity

        public PointSensitivityBuilder presentValueSensitivity​(ResolvedSwapLeg leg,
                                                               RatesProvider provider)
        Calculates the present value sensitivity of the swap leg.

        The present value sensitivity of the leg is the sensitivity of the present value to the underlying curves.

        Parameters:
        leg - the leg
        provider - the rates provider
        Returns:
        the present value curve sensitivity of the swap leg
      • forecastValueSensitivity

        public PointSensitivityBuilder forecastValueSensitivity​(ResolvedSwapLeg leg,
                                                                RatesProvider provider)
        Calculates the forecast value sensitivity of the swap leg.

        The forecast value sensitivity of the leg is the sensitivity of the forecast value to the underlying curves.

        Parameters:
        leg - the leg
        provider - the rates provider
        Returns:
        the forecast value curve sensitivity of the swap leg
      • pvbpSensitivity

        public PointSensitivityBuilder pvbpSensitivity​(ResolvedSwapLeg fixedLeg,
                                                       RatesProvider provider)
        Calculates the Present Value of a Basis Point curve sensitivity for a fixed swap leg.

        The Present Value of a Basis Point is the value of the leg when the rate is equal to 1. A better name would be "Present Value of 1". The quantity is also known as "physical annuity" or "level".

        Each period must not have FX reset or compounding. They must not be of type KnownAmountSwapPaymentPeriod.

        Parameters:
        fixedLeg - the swap fixed leg
        provider - the rates provider
        Returns:
        the Present Value of a Basis Point sensitivity to the curves
      • annuityCash

        public double annuityCash​(ResolvedSwapLeg fixedLeg,
                                  double yield)
        Computes the conventional cash annuity from a swap leg.

        The computation is relevant only for standard swaps with constant notional and regular payments. The swap leg must be a fixed leg. However, this is not checked internally.

        Parameters:
        fixedLeg - the fixed leg of the swap
        yield - the yield
        Returns:
        the cash annuity
      • annuityCash

        public double annuityCash​(int nbPaymentsPerYear,
                                  int nbPeriods,
                                  double yield)
        Computes the conventional cash annuity for a given yield.
        Parameters:
        nbPaymentsPerYear - the number of payment per year
        nbPeriods - the total number of periods
        yield - the yield
        Returns:
        the cash annuity
      • annuityCash1

        public ValueDerivatives annuityCash1​(int nbPaymentsPerYear,
                                             int nbPeriods,
                                             double yield)
        Computes the conventional cash annuity for a given yield and its first derivative with respect to the yield.
        Parameters:
        nbPaymentsPerYear - the number of payment per year
        nbPeriods - the total number of periods
        yield - the yield
        Returns:
        the cash annuity and its first derivative
      • annuityCash2

        public ValueDerivatives annuityCash2​(int nbPaymentsPerYear,
                                             int nbPeriods,
                                             double yield)
        Computes the conventional cash annuity for a given yield and its first two derivatives with respect to the yield.
        Parameters:
        nbPaymentsPerYear - the number of payment per year
        nbPeriods - the total number of periods
        yield - the yield
        Returns:
        the cash annuity and its first two derivatives
      • annuityCash3

        public ValueDerivatives annuityCash3​(int nbPaymentsPerYear,
                                             int nbPeriods,
                                             double yield)
        Computes the conventional cash annuity for a given yield and its first three derivatives with respect to the yield.
        Parameters:
        nbPaymentsPerYear - the number of payment per year
        nbPeriods - the total number of periods
        yield - the yield
        Returns:
        the cash annuity and its first three derivatives
      • annuityCashDerivative

        public ValueDerivatives annuityCashDerivative​(ResolvedSwapLeg fixedLeg,
                                                      double yield)
        Computes the derivative of the conventional cash annuity with respect to the yield from a swap leg.

        The computation is relevant only for standard swaps with constant notional and regular payments. The swap leg must be a fixed leg. However, this is not checked internally.

        Parameters:
        fixedLeg - the fixed leg of the swap
        yield - the yield
        Returns:
        the cash annuity
      • explainPresentValue

        public ExplainMap explainPresentValue​(ResolvedSwapLeg leg,
                                              RatesProvider provider)
        Explain present value for a swap leg.
        Parameters:
        leg - the swap log
        provider - the rates provider
        Returns:
        the explain PV map
      • currencyExposure

        public MultiCurrencyAmount currencyExposure​(ResolvedSwapLeg leg,
                                                    RatesProvider provider)
        Calculates the currency exposure of the swap leg.
        Parameters:
        leg - the leg
        provider - the rates provider
        Returns:
        the currency exposure of the swap leg
      • currentCash

        public CurrencyAmount currentCash​(ResolvedSwapLeg leg,
                                          RatesProvider provider)
        Calculates the current cash of the swap leg.
        Parameters:
        leg - the leg
        provider - the rates provider
        Returns:
        the current cash of the swap leg