finMath lib documentation
net.finmath.marketdata.products

## Class Swap

• All Implemented Interfaces:
AnalyticProduct, DescribedProduct<InterestRateSwapProductDescriptor>, Product

public class Swap
extends AbstractAnalyticProduct
implements AnalyticProduct, DescribedProduct<InterestRateSwapProductDescriptor>
Implements the valuation of a swap using curves (discount curve, forward curve). The swap valuation supports distinct discounting and forward curve. Support for day counting is limited to the capabilities of TimeDiscretization. The swap is just the composition of two SwapLegs, namely the receiver leg and the payer leg. The value of the swap is the value of the receiver leg minus the value of the payer leg.
Version:
1.0
Author:
Christian Fries
• ### Constructor Summary

Constructors
Constructor and Description
Swap(AnalyticProduct legReceiver, AnalyticProduct legPayer)
Create a swap which values as legReceiver - legPayer.
Swap(Schedule scheduleReceiveLeg, double spreadReceive, String discountCurveReceiveName, Schedule schedulePayLeg, String forwardCurvePayName, String discountCurvePayName)
Creates a swap with notional exchange.
Swap(Schedule scheduleReceiveLeg, String forwardCurveReceiveName, double spreadReceive, String discountCurveReceiveName, Schedule schedulePayLeg, String forwardCurvePayName, double spreadPay, String discountCurvePayName)
Creates a swap with notional exchange.
Swap(Schedule scheduleReceiveLeg, String forwardCurveReceiveName, double spreadReceive, String discountCurveReceiveName, Schedule schedulePayLeg, String forwardCurvePayName, double spreadPay, String discountCurvePayName, boolean isNotionalExchanged)
Creates a swap with notional exchange.
• ### Method Summary

All Methods
Modifier and Type Method and Description
InterestRateSwapProductDescriptor getDescriptor()
Return a product descriptor representing this product.
static double getForwardSwapRate(Schedule fixSchedule, Schedule floatSchedule, ForwardCurve forwardCurve)
static double getForwardSwapRate(Schedule fixSchedule, Schedule floatSchedule, ForwardCurve forwardCurve, AnalyticModel model)
static double getForwardSwapRate(TimeDiscretization fixTenor, TimeDiscretization floatTenor, ForwardCurve forwardCurve)
static double getForwardSwapRate(TimeDiscretization fixTenor, TimeDiscretization floatTenor, ForwardCurve forwardCurve, DiscountCurve discountCurve)
AnalyticProduct getLegPayer()
Return the payer leg of the swap, i.e. the leg who's value is subtracted from the swap value.
AnalyticProduct getLegReceiver()
Return the receiver leg of the swap, i.e. the leg who's value is added to the swap value.
double getValue(double evaluationTime, AnalyticModel model)
Return the valuation of the product using the given model.
String toString()
• ### Methods inherited from class net.finmath.marketdata.products.AbstractAnalyticProduct

getValue, getValue
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
• ### Methods inherited from interface net.finmath.modelling.Product

getValue, getValues
• ### Constructor Detail

• #### Swap

public Swap(AnalyticProduct legReceiver,
AnalyticProduct legPayer)
Create a swap which values as legReceiver - legPayer.
Parameters:
legReceiver - The receiver leg.
legPayer - The payler leg.
• #### Swap

public Swap(Schedule scheduleReceiveLeg,
Schedule schedulePayLeg,
String forwardCurvePayName,
String discountCurvePayName,
boolean isNotionalExchanged)
Creates a swap with notional exchange. The swap has a unit notional of 1.
Parameters:
scheduleReceiveLeg - ScheduleFromPeriods of the receiver leg.
forwardCurveReceiveName - Name of the forward curve, leave empty if this is a fix leg.
spreadReceive - Fixed spread on the forward or fix rate.
discountCurveReceiveName - Name of the discount curve for the receiver leg.
schedulePayLeg - ScheduleFromPeriods of the payer leg.
forwardCurvePayName - Name of the forward curve, leave empty if this is a fix leg.
spreadPay - Fixed spread on the forward or fix rate.
discountCurvePayName - Name of the discount curve for the payer leg.
isNotionalExchanged - If true, both 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).
• #### Swap

public Swap(Schedule scheduleReceiveLeg,
Schedule schedulePayLeg,
String forwardCurvePayName,
String discountCurvePayName)
Creates a swap with notional exchange. The swap has a unit notional of 1.
Parameters:
scheduleReceiveLeg - ScheduleFromPeriods of the receiver leg.
forwardCurveReceiveName - Name of the forward curve, leave empty if this is a fix leg.
spreadReceive - Fixed spread on the forward or fix rate.
discountCurveReceiveName - Name of the discount curve for the receiver leg.
schedulePayLeg - ScheduleFromPeriods of the payer leg.
forwardCurvePayName - Name of the forward curve, leave empty if this is a fix leg.
spreadPay - Fixed spread on the forward or fix rate.
discountCurvePayName - Name of the discount curve for the payer leg.
• #### Swap

public Swap(Schedule scheduleReceiveLeg,
Schedule schedulePayLeg,
String forwardCurvePayName,
String discountCurvePayName)
Creates a swap with notional exchange. The swap has a unit notional of 1.
Parameters:
scheduleReceiveLeg - ScheduleFromPeriods of the receiver leg.
spreadReceive - Fixed spread on the forward or fix rate.
discountCurveReceiveName - Name of the discount curve for the receiver leg.
schedulePayLeg - ScheduleFromPeriods of the payer leg.
forwardCurvePayName - Name of the forward curve, leave empty if this is a fix leg.
discountCurvePayName - Name of the discount curve for the payer leg.
• ### Method Detail

• #### 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.
• #### getForwardSwapRate

public static double getForwardSwapRate(TimeDiscretization fixTenor,
TimeDiscretization floatTenor,
ForwardCurve forwardCurve)
• #### getForwardSwapRate

public static double getForwardSwapRate(TimeDiscretization fixTenor,
TimeDiscretization floatTenor,
ForwardCurve forwardCurve,
DiscountCurve discountCurve)
• #### getForwardSwapRate

public static double getForwardSwapRate(Schedule fixSchedule,
Schedule floatSchedule,
ForwardCurve forwardCurve)
• #### getForwardSwapRate

public static double getForwardSwapRate(Schedule fixSchedule,
Schedule floatSchedule,
ForwardCurve forwardCurve,
AnalyticModel model)

public AnalyticProduct getLegReceiver()
Return the receiver leg of the swap, i.e. the leg who's value is added to the swap value.
Returns:
The receiver leg of the swap.
• #### getLegPayer

public AnalyticProduct getLegPayer()
Return the payer leg of the swap, i.e. the leg who's value is subtracted from the swap value.
Returns:
The payer leg of the swap.
• #### toString

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

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