Class DiscountingFixedCouponBondProductPricer
 java.lang.Object

 com.opengamma.strata.pricer.bond.DiscountingFixedCouponBondProductPricer

public class DiscountingFixedCouponBondProductPricer extends Object
Pricer for fixed coupon bond products.This function provides the ability to price a
ResolvedFixedCouponBond
.Price
Strata uses decimal prices for bonds in the trade model, pricers and market data. For example, a price of 99.32% is represented in Strata by 0.9932.


Field Summary
Fields Modifier and Type Field Description static DiscountingFixedCouponBondProductPricer
DEFAULT
Default implementation.

Constructor Summary
Constructors Constructor Description DiscountingFixedCouponBondProductPricer(DiscountingFixedCouponBondPaymentPeriodPricer periodPricer, DiscountingPaymentPricer nominalPricer)
Creates an instance.

Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
accruedInterest(ResolvedFixedCouponBond bond, LocalDate settlementDate)
Calculates the accrued interest of the fixed coupon bond with the specified settlement date.double
accruedYearFraction(ResolvedFixedCouponBond bond, LocalDate settlementDate)
Calculates the accrued year fraction of the fixed coupon bond with the specified settlement date.double
cleanPriceFromDirtyPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice)
Calculates the clean price of the fixed coupon bond from its settlement date and dirty price.double
convexityFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the convexity of the fixed coupon bond product from yield.double
dirtyPriceFromCleanPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double cleanPrice)
Calculates the dirty price of the fixed coupon bond from its settlement date and clean price.double
dirtyPriceFromCurves(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData)
Calculates the dirty price of the fixed coupon bond.double
dirtyPriceFromCurves(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, LocalDate settlementDate)
Calculates the dirty price of the fixed coupon bond under the specified settlement date.double
dirtyPriceFromCurvesWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear, LocalDate settlementDate)
Calculates the dirty price of the fixed coupon bond under the specified settlement date with zspread.double
dirtyPriceFromCurvesWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the dirty price of the fixed coupon bond with zspread.double
dirtyPriceFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the dirty price of the fixed coupon bond from yield.ValueDerivatives
dirtyPriceFromYieldAd(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the dirty price of the fixed coupon bond from yield and its derivative wrt to the yield.PointSensitivityBuilder
dirtyPriceSensitivity(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData)
Calculates the dirty price sensitivity of the fixed coupon bond product.PointSensitivityBuilder
dirtyPriceSensitivityWithZspread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the dirty price sensitivity of the fixed coupon bond with zspread.double
macaulayDurationFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the Macaulay duration of the fixed coupon bond product from yield.double
modifiedDurationFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the modified duration of the fixed coupon bond product from yield.ValueDerivatives
modifiedDurationFromYieldAd(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the modified duration of the fixed coupon bond product from yield and its derivative wrt to the yield.CurrencyAmount
presentValue(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider)
Calculates the present value of the fixed coupon bond product.PointSensitivityBuilder
presentValueSensitivity(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider)
Calculates the present value sensitivity of the fixed coupon bond product.PointSensitivityBuilder
presentValueSensitivityWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the present value sensitivity of the fixed coupon bond with zspread.CurrencyAmount
presentValueWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the present value of the fixed coupon bond product with zspread.double
yieldFromDirtyPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice)
Calculates the yield of the fixed coupon bond product from dirty price.ValueDerivatives
yieldFromDirtyPriceAd(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice)
Calculates the yield of the fixed coupon bond product from dirty price and its derivative wrt the price.double
zSpreadFromCurvesAndDirtyPrice(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData, double dirtyPrice, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the zspread of the fixed coupon bond from curves and dirty price.



Field Detail

DEFAULT
public static final DiscountingFixedCouponBondProductPricer DEFAULT
Default implementation.


Constructor Detail

DiscountingFixedCouponBondProductPricer
public DiscountingFixedCouponBondProductPricer(DiscountingFixedCouponBondPaymentPeriodPricer periodPricer, DiscountingPaymentPricer nominalPricer)
Creates an instance. Parameters:
periodPricer
 the pricer forFixedCouponBondPaymentPeriod
nominalPricer
 the pricer forPayment


Method Detail

presentValue
public CurrencyAmount presentValue(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider)
Calculates the present value of the fixed coupon bond product.The present value of the product is the value on the valuation date. The result is expressed using the payment currency of the bond.
Coupon payments of the product are considered based on the valuation date.
 Parameters:
bond
 the productprovider
 the discounting provider Returns:
 the present value of the fixed coupon bond product

presentValueWithZSpread
public CurrencyAmount presentValueWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the present value of the fixed coupon bond product with zspread.The present value of the product is the value on the valuation date. The result is expressed using the payment currency of the bond.
The zspread is a parallel shift applied to continuously compounded rates or periodic compounded rates of the issuer discounting curve.
 Parameters:
bond
 the productprovider
 the discounting providerzSpread
 the zspreadcompoundedRateType
 the compounded rate typeperiodsPerYear
 the number of periods per year Returns:
 the present value of the fixed coupon bond product

dirtyPriceFromCurves
public double dirtyPriceFromCurves(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData)
Calculates the dirty price of the fixed coupon bond.The fixed coupon bond is represented as
Security
where standard ID of the bond is stored.Strata uses decimal prices for bonds. For example, a price of 99.32% is represented in Strata by 0.9932.
 Parameters:
bond
 the productprovider
 the discounting providerrefData
 the reference data used to calculate the settlement date Returns:
 the dirty price of the fixed coupon bond security

dirtyPriceFromCurves
public double dirtyPriceFromCurves(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, LocalDate settlementDate)
Calculates the dirty price of the fixed coupon bond under the specified settlement date.The fixed coupon bond is represented as
Security
where standard ID of the bond is stored. Parameters:
bond
 the productprovider
 the discounting providersettlementDate
 the settlement date Returns:
 the dirty price of the fixed coupon bond security

dirtyPriceFromCurvesWithZSpread
public double dirtyPriceFromCurvesWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the dirty price of the fixed coupon bond with zspread.The zspread is a parallel shift applied to continuously compounded rates or periodic compounded rates of the discounting curve.
The fixed coupon bond is represented as
Security
where standard ID of the bond is stored. Parameters:
bond
 the productprovider
 the discounting providerrefData
 the reference data used to calculate the settlement datezSpread
 the zspreadcompoundedRateType
 the compounded rate typeperiodsPerYear
 the number of periods per year Returns:
 the dirty price of the fixed coupon bond security

dirtyPriceFromCurvesWithZSpread
public double dirtyPriceFromCurvesWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear, LocalDate settlementDate)
Calculates the dirty price of the fixed coupon bond under the specified settlement date with zspread.The zspread is a parallel shift applied to continuously compounded rates or periodic compounded rates of the discounting curve.
The fixed coupon bond is represented as
Security
where standard ID of the bond is stored. Parameters:
bond
 the productprovider
 the discounting providerzSpread
 the zspreadcompoundedRateType
 the compounded rate typeperiodsPerYear
 the number of periods per yearsettlementDate
 the settlement date Returns:
 the dirty price of the fixed coupon bond security

dirtyPriceFromCleanPrice
public double dirtyPriceFromCleanPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double cleanPrice)
Calculates the dirty price of the fixed coupon bond from its settlement date and clean price. Parameters:
bond
 the productsettlementDate
 the settlement datecleanPrice
 the clean price Returns:
 the present value of the fixed coupon bond product

cleanPriceFromDirtyPrice
public double cleanPriceFromDirtyPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice)
Calculates the clean price of the fixed coupon bond from its settlement date and dirty price.Strata uses decimal prices for bonds. For example, a price of 99.32% is represented in Strata by 0.9932.
 Parameters:
bond
 the productsettlementDate
 the settlement datedirtyPrice
 the dirty price Returns:
 the present value of the fixed coupon bond product

zSpreadFromCurvesAndDirtyPrice
public double zSpreadFromCurvesAndDirtyPrice(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData, double dirtyPrice, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the zspread of the fixed coupon bond from curves and dirty price.The zspread is a parallel shift applied to continuously compounded rates or periodic compounded rates of the discounting curve associated to the bond (Issuer Entity) to match the dirty price.
 Parameters:
bond
 the productprovider
 the discounting providerrefData
 the reference data used to calculate the settlement datedirtyPrice
 the dirtyPricecompoundedRateType
 the compounded rate typeperiodsPerYear
 the number of periods per year Returns:
 the zspread of the fixed coupon bond security

presentValueSensitivity
public PointSensitivityBuilder presentValueSensitivity(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider)
Calculates the present value sensitivity of the fixed coupon bond product.The present value sensitivity of the product is the sensitivity of the present value to the underlying curves.
 Parameters:
bond
 the productprovider
 the discounting provider Returns:
 the present value curve sensitivity of the product

presentValueSensitivityWithZSpread
public PointSensitivityBuilder presentValueSensitivityWithZSpread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the present value sensitivity of the fixed coupon bond with zspread.The present value sensitivity of the product is the sensitivity of the present value to the underlying curves.
The zspread is a parallel shift applied to continuously compounded rates or periodic compounded rates of the issuer discounting curve.
 Parameters:
bond
 the productprovider
 the discounting providerzSpread
 the zspreadcompoundedRateType
 the compounded rate typeperiodsPerYear
 the number of periods per year Returns:
 the present value curve sensitivity of the product

dirtyPriceSensitivity
public PointSensitivityBuilder dirtyPriceSensitivity(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData)
Calculates the dirty price sensitivity of the fixed coupon bond product.The dirty price sensitivity of the security is the sensitivity of the present value to the underlying curves.
 Parameters:
bond
 the productprovider
 the discounting providerrefData
 the reference data used to calculate the settlement date Returns:
 the dirty price value curve sensitivity of the security

dirtyPriceSensitivityWithZspread
public PointSensitivityBuilder dirtyPriceSensitivityWithZspread(ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the dirty price sensitivity of the fixed coupon bond with zspread.The dirty price sensitivity of the security is the sensitivity of the present value to the underlying curves.
The zspread is a parallel shift applied to continuously compounded rates or periodic compounded rates of the discounting curve.
 Parameters:
bond
 the productprovider
 the discounting providerrefData
 the reference data used to calculate the settlement datezSpread
 the zspreadcompoundedRateType
 the compounded rate typeperiodsPerYear
 the number of periods per year Returns:
 the dirty price curve sensitivity of the security

accruedInterest
public double accruedInterest(ResolvedFixedCouponBond bond, LocalDate settlementDate)
Calculates the accrued interest of the fixed coupon bond with the specified settlement date. Parameters:
bond
 the productsettlementDate
 the settlement date Returns:
 the accrued interest of the product

accruedYearFraction
public double accruedYearFraction(ResolvedFixedCouponBond bond, LocalDate settlementDate)
Calculates the accrued year fraction of the fixed coupon bond with the specified settlement date. Parameters:
bond
 the productsettlementDate
 the settlement date Returns:
 the accrued year fraction of the product

dirtyPriceFromYield
public double dirtyPriceFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the dirty price of the fixed coupon bond from yield.The yield must be fractional. The dirty price is computed for
FixedCouponBondYieldConvention
, and the result is expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement dateyield
 the yield Returns:
 the dirty price of the product

dirtyPriceFromYieldAd
public ValueDerivatives dirtyPriceFromYieldAd(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the dirty price of the fixed coupon bond from yield and its derivative wrt to the yield.The yield must be fractional. The dirty price is computed for
FixedCouponBondYieldConvention
, and the result is expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement dateyield
 the yield Returns:
 the dirty price of the product and its derivative

yieldFromDirtyPrice
public double yieldFromDirtyPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice)
Calculates the yield of the fixed coupon bond product from dirty price.The dirty price must be fractional. If the analytic formula is not available, the yield is computed by solving a rootfinding problem with
dirtyPriceFromYield(ResolvedFixedCouponBond, LocalDate, double)
. The result is also expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement datedirtyPrice
 the dirty price Returns:
 the yield of the product

yieldFromDirtyPriceAd
public ValueDerivatives yieldFromDirtyPriceAd(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice)
Calculates the yield of the fixed coupon bond product from dirty price and its derivative wrt the price.The dirty price must be fractional. If the analytic formula is not available, the yield is computed by solving a rootfinding problem with
dirtyPriceFromYield(ResolvedFixedCouponBond, LocalDate, double)
. The result is also expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement datedirtyPrice
 the dirty price Returns:
 the yield of the product

modifiedDurationFromYield
public double modifiedDurationFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the modified duration of the fixed coupon bond product from yield.The modified duration is defined as the minus of the first derivative of dirty price with respect to yield, divided by the dirty price.
The input yield must be fractional. The dirty price and its derivative are computed for
FixedCouponBondYieldConvention
, and the result is expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement dateyield
 the yield Returns:
 the modified duration of the product

modifiedDurationFromYieldAd
public ValueDerivatives modifiedDurationFromYieldAd(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the modified duration of the fixed coupon bond product from yield and its derivative wrt to the yield.The modified duration is defined as the minus of the first derivative of dirty price with respect to yield, divided by the dirty price.
The input yield must be fractional. The dirty price and its derivative are computed for
FixedCouponBondYieldConvention
, and the result is expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement dateyield
 the yield Returns:
 the modified duration of the product

macaulayDurationFromYield
public double macaulayDurationFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the Macaulay duration of the fixed coupon bond product from yield.Macaulay defined an alternative way of weighting the future cash flows.
The input yield must be fractional. The dirty price and its derivative are computed for
FixedCouponBondYieldConvention
, and the result is expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement dateyield
 the yield Returns:
 the modified duration of the product

convexityFromYield
public double convexityFromYield(ResolvedFixedCouponBond bond, LocalDate settlementDate, double yield)
Calculates the convexity of the fixed coupon bond product from yield.The convexity is defined as the second derivative of dirty price with respect to yield, divided by the dirty price.
The input yield must be fractional. The dirty price and its derivative are computed for
FixedCouponBondYieldConvention
, and the result is expressed in fraction. Parameters:
bond
 the productsettlementDate
 the settlement dateyield
 the yield Returns:
 the convexity of the product

