Class SwapLeg

All Implemented Interfaces:
Serializable, AnalyticProduct, DescribedProduct<InterestRateSwapLegProductDescriptor>, Product

Implements the valuation of a swap leg with unit notional of 1 using curves (discount curve, forward curve). The swap leg valuation supports distinct discounting and forward curves. Support for day counting is provided via the class implementing Schedule.
Version:
1.0
Author:
Christian Fries
See Also:
  • Constructor Details

    • SwapLeg

      public SwapLeg(LocalDateTime cashFlowEffectiveDate, Schedule legSchedule, String forwardCurveName, double[] notionals, double[] spreads, String discountCurveName, boolean isNotionalExchanged)
      Creates a swap leg.
      Parameters:
      cashFlowEffectiveDate - If present, cash-flows are effective after this date, otherwise cash-flows are effective after the valuation date.
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      notionals - Array of notionals for each period.
      spreads - Array of fixed spreads on the forward or fix rate for each period.
      discountCurveName - Name of the discount curve for the leg.
      isNotionalExchanged - If true, the leg will pay notional at the beginning of each swap period and receive notional at the end of the swap period. Note that the cash flow date for the notional is periodStart and periodEnd (not fixingDate and paymentDate).
    • SwapLeg

      @Deprecated public SwapLeg(Optional<LocalDateTime> cashFlowEffectiveDate, Schedule legSchedule, String forwardCurveName, double[] notionals, double[] spreads, String discountCurveName, boolean isNotionalExchanged)
      Deprecated.
      Creates a swap leg.
      Parameters:
      cashFlowEffectiveDate - If present, cash-flows are effective after this date, otherwise cash-flows are effective after the valuation date.
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      notionals - Array of notionals for each period.
      spreads - Array of fixed spreads on the forward or fix rate for each period.
      discountCurveName - Name of the discount curve for the leg.
      isNotionalExchanged - If true, the leg will pay notional at the beginning of each swap period and receive notional at the end of the swap period. Note that the cash flow date for the notional is periodStart and periodEnd (not fixingDate and paymentDate).
    • SwapLeg

      public SwapLeg(Schedule legSchedule, String forwardCurveName, double[] notionals, double[] spreads, String discountCurveName, boolean isNotionalExchanged)
      Creates a swap leg.
      Parameters:
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      notionals - Array of notionals for each period.
      spreads - Array of fixed spreads on the forward or fix rate for each period.
      discountCurveName - Name of the discount curve for the leg.
      isNotionalExchanged - If true, the leg will pay notional at the beginning of each swap period and receive notional at the end of the swap period. Note that the cash flow date for the notional is periodStart and periodEnd (not fixingDate and paymentDate).
    • SwapLeg

      public SwapLeg(Optional<LocalDateTime> cashFlowEffectiveDate, Schedule legSchedule, String forwardCurveName, double spread, String discountCurveName, String discountCurveForNotionalResetName, boolean isNotionalExchanged)
      Creates a swap leg.
      Parameters:
      cashFlowEffectiveDate - If present, cash-flows are effective after this date, otherwise cash-flows are effective after the valuation date.
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      spread - Fixed spread on the forward or fix rate.
      discountCurveName - Name of the discount curve for the leg.
      discountCurveForNotionalResetName - Name of the discount curve used for notional reset. If it is left empty or equal to discountCurveName then there is no notional reset.
      isNotionalExchanged - If true, the leg will pay notional at the beginning of each swap period and receive notional at the end of the swap period. Note that the cash flow date for the notional is periodStart and periodEnd (not fixingDate and paymentDate).
    • SwapLeg

      public SwapLeg(Schedule legSchedule, String forwardCurveName, double spread, String discountCurveName, String discountCurveForNotionalResetName, boolean isNotionalExchanged)
      Creates a swap leg.
      Parameters:
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      spread - Fixed spread on the forward or fix rate.
      discountCurveName - Name of the discount curve for the leg.
      discountCurveForNotionalResetName - Name of the discount curve used for notional reset. If it is left empty or equal to discountCurveName then there is no notional reset.
      isNotionalExchanged - If true, the leg will pay notional at the beginning of each swap period and receive notional at the end of the swap period. Note that the cash flow date for the notional is periodStart and periodEnd (not fixingDate and paymentDate).
    • SwapLeg

      public SwapLeg(Schedule legSchedule, String forwardCurveName, double spread, String discountCurveName, boolean isNotionalExchanged)
      Creates a swap leg without notional reset.
      Parameters:
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      spread - Fixed spread on the forward or fix rate.
      discountCurveName - Name of the discount curve for the leg.
      isNotionalExchanged - If true, the leg will pay notional at the beginning of each swap period and receive notional at the end of the swap period. Note that the cash flow date for the notional is periodStart and periodEnd (not fixingDate and paymentDate).
    • SwapLeg

      public SwapLeg(Optional<LocalDateTime> cashFlowEffectiveDate, Schedule legSchedule, String forwardCurveName, double spread, String discountCurveName)
      Creates a swap leg without notional reset and without notional exchange.
      Parameters:
      cashFlowEffectiveDate - If present, cash-flows are effective after this date, otherwise cash-flows are effective after the valuation date.
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      spread - Fixed spread on the forward or fix rate.
      discountCurveName - Name of the discount curve for the leg.
    • SwapLeg

      public SwapLeg(Schedule legSchedule, String forwardCurveName, double spread, String discountCurveName)
      Creates a swap leg without notional reset and without notional exchange.
      Parameters:
      legSchedule - ScheduleFromPeriods of the leg.
      forwardCurveName - Name of the forward curve, leave empty if this is a fix leg.
      spread - Fixed spread on the forward or fix rate.
      discountCurveName - Name of the discount curve for the leg.
  • Method Details

    • getValue

      public double getValue(double evaluationTime, AnalyticModel model)
      Description copied from interface: AnalyticProduct
      Return the valuation of the product using the given model. The model has to implement the modes of AnalyticModel.
      Specified by:
      getValue in interface AnalyticProduct
      Parameters:
      evaluationTime - The evaluation time as double. Cash flows prior and including this time are not considered.
      model - The model under which the product is valued.
      Returns:
      The value of the product using the given model.
    • getSchedule

      public Schedule getSchedule()
    • getForwardCurveName

      public String getForwardCurveName()
    • getSpreads

      public double[] getSpreads()
    • getSpread

      public double getSpread()
      Returns the constant spread, , if the spread of this leg is constant. Otherwise an UnsupportedOperationException is thrown.
      Returns:
      The constant spread.
    • getDiscountCurveName

      public String getDiscountCurveName()
    • isNotionalExchanged

      public boolean isNotionalExchanged()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDescriptor

      public InterestRateSwapLegProductDescriptor getDescriptor()
      Description copied from interface: DescribedProduct
      Return a product descriptor representing this product.
      Specified by:
      getDescriptor in interface DescribedProduct<InterestRateSwapLegProductDescriptor>
      Returns:
      The product descriptor of this product.