/** * Computes the present value of a fixed coupon by discounting. * * @param cpn The coupon. * @param curves The curve bundle. * @return The present value. */ public CurrencyAmount presentValue(CouponFixed cpn, YieldCurveBundle curves) { Validate.notNull(curves); Validate.notNull(cpn); final YieldAndDiscountCurve fundingCurve = curves.getCurve(cpn.getFundingCurveName()); double pv = cpn.getAmount() * fundingCurve.getDiscountFactor(cpn.getPaymentTime()); return CurrencyAmount.of(cpn.getCurrency(), pv); }
/** * Compute the the present value curve sensitivity of a fixed coupon by discounting to a parallel * curve movement. * * @param cpn The coupon. * @param curves The curve bundle. * @return The sensitivity. */ public StringValue presentValueParallelCurveSensitivity( CouponFixed cpn, YieldCurveBundle curves) { final String curveName = cpn.getFundingCurveName(); final YieldAndDiscountCurve discountingCurve = curves.getCurve(curveName); final double time = cpn.getPaymentTime(); double sensitivity = -time * cpn.getAmount() * discountingCurve.getDiscountFactor(time); return StringValue.from(curveName, sensitivity); }
/** * Computes the present value of the fixed coupon with positive notional (abs(notional) is used) * by discounting. * * @param cpn The coupon. * @param curves The curve bundle. * @return The present value. */ public CurrencyAmount presentValuePositiveNotional(CouponFixed cpn, YieldCurveBundle curves) { Validate.notNull(curves); Validate.notNull(cpn); final YieldAndDiscountCurve fundingCurve = curves.getCurve(cpn.getFundingCurveName()); double pv = cpn.getPaymentYearFraction() * Math.abs(cpn.getNotional()) * cpn.getFixedRate() * fundingCurve.getDiscountFactor(cpn.getPaymentTime()); return CurrencyAmount.of(cpn.getCurrency(), pv); }
/** * Computes the present value curve sensitivity of a fixed coupon by discounting. * * @param cpn The coupon. * @param curves The curve bundle. * @return The sensitivity. */ public InterestRateCurveSensitivity presentValueCurveSensitivity( CouponFixed cpn, YieldCurveBundle curves) { final String curveName = cpn.getFundingCurveName(); final YieldAndDiscountCurve discountingCurve = curves.getCurve(curveName); final double time = cpn.getPaymentTime(); final DoublesPair s = new DoublesPair(time, -time * cpn.getAmount() * discountingCurve.getDiscountFactor(time)); final List<DoublesPair> list = new ArrayList<DoublesPair>(); list.add(s); final Map<String, List<DoublesPair>> result = new HashMap<String, List<DoublesPair>>(); result.put(curveName, list); return new InterestRateCurveSensitivity(result); }