コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
 /**
  * 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);
 }
 @Test
 /** Test the cap/floor/forward parity above the cut-off strike. */
 public void presentValueCapFloorParityAboveCutOff() {
   final CurrencyAmount priceCap = METHOD.presentValue(CAP_HIGH_LONG, SABR_BUNDLE);
   final CurrencyAmount priceFloor = METHOD.presentValue(FLOOR_HIGH_SHORT, SABR_BUNDLE);
   final double priceCouponStrike = COUPON_STRIKE_HIGH.accept(PVC, CURVES);
   final double priceCouponIbor = COUPON_IBOR.accept(PVC, CURVES);
   assertEquals(
       "Cap/floor: SABR with extrapolation pricing: cap/floor parity",
       priceCouponIbor - priceCouponStrike,
       priceCap.getAmount() + priceFloor.getAmount(),
       1E-2);
 }
コード例 #5
0
 /**
  * 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);
 }
 @Override
 public Map<String, List<DoublesPair>> visitCouponFixed(
     final CouponFixed payment, final YieldCurveBundle data) {
   return visitFixedPayment(payment.toPaymentFixed(), data);
 }