## Class DiscountingSwapProductPricer

• java.lang.Object
• com.opengamma.strata.pricer.swap.DiscountingSwapProductPricer

• public class DiscountingSwapProductPricer
extends Object
Pricer for for rate swap products.

This function provides the ability to price a ResolvedSwap. The product is priced by pricing each leg.

• ### Field Summary

Fields
Modifier and Type Field Description
static DiscountingSwapProductPricer DEFAULT
Default implementation.
• ### Constructor Summary

Constructors
Constructor Description
DiscountingSwapProductPricer​(DiscountingSwapLegPricer legPricer)
Creates an instance.
• ### Method Summary

All Methods
Modifier and Type Method Description
MultiCurrencyAmount accruedInterest​(ResolvedSwap swap, RatesProvider provider)
Calculates the accrued interest since the last payment.
CashFlows cashFlows​(ResolvedSwap swap, RatesProvider provider)
Calculates the future cash flows of the swap product.
MultiCurrencyAmount currencyExposure​(ResolvedSwap swap, RatesProvider provider)
Calculates the currency exposure of the swap product.
MultiCurrencyAmount currentCash​(ResolvedSwap swap, RatesProvider provider)
Calculates the current cash of the swap product.
ExplainMap explainPresentValue​(ResolvedSwap swap, RatesProvider provider)
Explains the present value of the swap product.
MultiCurrencyAmount forecastValue​(ResolvedSwap swap, RatesProvider provider)
Calculates the forecast value of the swap product.
PointSensitivityBuilder forecastValueSensitivity​(ResolvedSwap swap, RatesProvider provider)
Calculates the forecast value sensitivity of the swap product.
DiscountingSwapLegPricer getLegPricer()
Gets the underlying leg pricer.
double marketQuote​(ResolvedSwap swap, RatesProvider provider)
Computes the market quote of swaps.
PointSensitivityBuilder marketQuoteSensitivity​(ResolvedSwap swap, RatesProvider provider)
Computes the market quote curve sensitivity for swaps.
double parRate​(ResolvedSwap swap, RatesProvider provider)
Computes the par rate for swaps with a fixed leg.
PointSensitivityBuilder parRateSensitivity​(ResolvedSwap swap, RatesProvider provider)
Calculates the par rate curve sensitivity for a swap with a fixed leg.
double parSpread​(ResolvedSwap swap, RatesProvider provider)
Computes the par spread for swaps.
PointSensitivityBuilder parSpreadSensitivity​(ResolvedSwap swap, RatesProvider provider)
Calculates the par spread curve sensitivity for a swap.
CurrencyAmount presentValue​(ResolvedSwap swap, Currency currency, RatesProvider provider)
Calculates the present value of the swap product, converted to the specified currency.
MultiCurrencyAmount presentValue​(ResolvedSwap swap, RatesProvider provider)
Calculates the present value of the swap product.
PointSensitivityBuilder presentValueSensitivity​(ResolvedSwap swap, Currency currency, RatesProvider provider)
Calculates the present value sensitivity of the swap product converted in a given currency.
PointSensitivityBuilder presentValueSensitivity​(ResolvedSwap swap, RatesProvider provider)
Calculates the present value sensitivity of the swap product.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Field Detail

• #### DEFAULT

public static final DiscountingSwapProductPricer DEFAULT
Default implementation.
• ### Constructor Detail

• #### DiscountingSwapProductPricer

public DiscountingSwapProductPricer​(DiscountingSwapLegPricer legPricer)
Creates an instance.
Parameters:
legPricer - the pricer for ResolvedSwapLeg
• ### Method Detail

• #### getLegPricer

public DiscountingSwapLegPricer getLegPricer()
Gets the underlying leg pricer.
Returns:
the leg pricer
• #### presentValue

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

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

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

public MultiCurrencyAmount presentValue​(ResolvedSwap swap,
RatesProvider provider)
Calculates the present value of the swap product.

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

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

public MultiCurrencyAmount forecastValue​(ResolvedSwap swap,
RatesProvider provider)
Calculates the forecast value of the swap product.

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

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

public MultiCurrencyAmount accruedInterest​(ResolvedSwap swap,
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.

Parameters:
swap - the product
provider - the rates provider
Returns:
the accrued interest of the swap product
• #### parRate

public double parRate​(ResolvedSwap swap,
RatesProvider provider)
Computes the par rate for swaps with a fixed leg.

The par rate is the common rate on all payments of the fixed leg for which the total swap present value is 0.

At least one leg must be a fixed leg. The par rate will be computed with respect to the first fixed leg in which all the payments are fixed payments with a unique accrual period (no compounding) and no FX reset. If the fixed leg is compounding, the par rate is computed only when the number of fixed coupon payments is 1 and accrual factor of each sub-period is 1

Parameters:
swap - the product
provider - the rates provider
Returns:
the par rate
Throws:
IllegalArgumentException - if there is no fixed leg
• #### marketQuote

public double marketQuote​(ResolvedSwap swap,
RatesProvider provider)
Computes the market quote of swaps.

For swaps with a fixed leg, this is equal to the par rate. For swaps without a fixed leg, this is the constant spread on the first leg required to have a PV of 0.

All the payment periods of the first leg must be of the type RatePaymentPeriod.

Parameters:
swap - the product
provider - the rates provider
Returns:
the market quote
Throws:
IllegalArgumentException - if there is no fixed leg and not all the payment periods of the first leg are of the type RatePaymentPeriod

public double parSpread​(ResolvedSwap swap,
RatesProvider provider)
Computes the par spread for swaps.

The par spread is the common spread on all payments of the first leg for which the total swap present value is 0.

The par spread will be computed with respect to the first leg. For that leg, all the payments have a unique accrual period or multiple accrual periods with Flat compounding and no FX reset.

Parameters:
swap - the product
provider - the rates provider
Returns:
the par rate
• #### presentValueSensitivity

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

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

Parameters:
swap - the product
provider - the rates provider
Returns:
the present value curve sensitivity of the swap product
• #### presentValueSensitivity

public PointSensitivityBuilder presentValueSensitivity​(ResolvedSwap swap,
Currency currency,
RatesProvider provider)
Calculates the present value sensitivity of the swap product converted in a given currency.

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

Parameters:
swap - the product
currency - the currency to convert to
provider - the rates provider
Returns:
the present value curve sensitivity of the swap product converted in the given currency
• #### forecastValueSensitivity

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

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

Parameters:
swap - the product
provider - the rates provider
Returns:
the forecast value curve sensitivity of the swap product
• #### parRateSensitivity

public PointSensitivityBuilder parRateSensitivity​(ResolvedSwap swap,
RatesProvider provider)
Calculates the par rate curve sensitivity for a swap with a fixed leg.

The par rate is the common rate on all payments of the fixed leg for which the total swap present value is 0.

At least one leg must be a fixed leg. The par rate will be computed with respect to the first fixed leg. All the payments in that leg should be fixed payments with a unique accrual period (no compounding) and no FX reset.

Parameters:
swap - the product
provider - the rates provider
Returns:
the par rate curve sensitivity of the swap product
Throws:
IllegalArgumentException - if there is no fixed leg
• #### marketQuoteSensitivity

public PointSensitivityBuilder marketQuoteSensitivity​(ResolvedSwap swap,
RatesProvider provider)
Computes the market quote curve sensitivity for swaps.

For swaps with a fixed leg, this is equal to the par rate. For swaps without a fixed leg, this is the constant spread on the first leg required to have a PV of 0.

All the payment periods of the first leg must be of the type RatePaymentPeriod.

The figures are reported in the currency of the first leg, even if in theory they should be dimensionless.

Parameters:
swap - the product
provider - the rates provider
Returns:
the par rate curve sensitivity of the swap product
Throws:
IllegalArgumentException - if there is no fixed leg and not all the payment periods of the first leg are of the type RatePaymentPeriod

public PointSensitivityBuilder parSpreadSensitivity​(ResolvedSwap swap,
RatesProvider provider)
Calculates the par spread curve sensitivity for a swap.

The par spread is the common spread on all payments of the first leg for which the total swap present value is 0.

The par spread is computed with respect to the first leg. For that leg, all the payments have a unique accrual period (no compounding) and no FX reset.

Parameters:
swap - the product
provider - the rates provider
Returns:
the par spread curve sensitivity of the swap product
• #### cashFlows

public CashFlows cashFlows​(ResolvedSwap swap,
RatesProvider provider)
Calculates the future cash flows of the swap product.

Each expected cash flow is added to the result. This is based on forecastValue(ResolvedSwap, RatesProvider).

Parameters:
swap - the product
provider - the rates provider
Returns:
the cash flow
• #### explainPresentValue

public ExplainMap explainPresentValue​(ResolvedSwap swap,
RatesProvider provider)
Explains the present value of the swap product.

This returns explanatory information about the calculation.

Parameters:
swap - the product
provider - the rates provider
Returns:
the explanatory information
• #### currencyExposure

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

public MultiCurrencyAmount currentCash​(ResolvedSwap swap,
RatesProvider provider)
Calculates the current cash of the swap product.
Parameters:
swap - the product
provider - the rates provider
Returns:
the current cash of the swap product