Package com.opengamma.analytics.financial.interestrate.payments.derivative

Examples of com.opengamma.analytics.financial.interestrate.payments.derivative.Payment


  /**
   * Tests the cash flow equivalent of a Ibor coupon.
   */
  public void iborCoupon() {
    final int cpnIndex = 17; // To have payment different from end fixing.
    final Payment cpn = SWAP.getSecondLeg().getNthPayment(cpnIndex);
    final CouponIbor cpnIbor = (CouponIbor) cpn;
    final AnnuityPaymentFixed cfe = cpn.accept(CFEC, CURVES);
    assertEquals("Fixed coupon: Number of flows", 2, cfe.getNumberOfPayments());
    assertEquals("Fixed coupon: Time", cpn.getPaymentTime(), cfe.getNthPayment(1).getPaymentTime(), 1E-5);
    assertEquals("Fixed coupon: Amount", -NOTIONAL * (FIXED_IS_PAYER ? 1.0 : -1.0) * cpnIbor.getPaymentYearFraction() / cpnIbor.getFixingAccrualFactor(), cfe.getNthPayment(1).getAmount(), 1E-2);
    assertEquals("Fixed coupon: Time", cpnIbor.getFixingPeriodStartTime(), cfe.getNthPayment(0).getPaymentTime(), 1E-5);
    final double beta = CURVES.getCurve(FORWARD_CURVE_NAME).getDiscountFactor(cpnIbor.getFixingPeriodStartTime()) /
        CURVES.getCurve(FORWARD_CURVE_NAME).getDiscountFactor(cpnIbor.getFixingPeriodEndTime())
        * CURVES.getCurve(FUNDING_CURVE_NAME).getDiscountFactor(cpnIbor.getPaymentTime()) / CURVES.getCurve(FUNDING_CURVE_NAME).getDiscountFactor(cpnIbor.getFixingPeriodStartTime());
    assertEquals("Fixed coupon: Amount", beta * NOTIONAL * (FIXED_IS_PAYER ? 1.0 : -1.0) * cpnIbor.getPaymentYearFraction() / cpnIbor.getFixingAccrualFactor(), cfe.getNthPayment(0).getAmount(), 1E-4);
    final double pvCpn = cpn.accept(PVC, CURVES);
    final double pvCfe = cfe.accept(PVC, CURVES);
    assertEquals("Cash flow equivalent - Swap: present value", pvCpn, pvCfe, 1E-5);
  }
View Full Code Here


   */
  public void testToDerivativeAfterFixing() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 1, 10, 12, 0);
    final double paymentTime = TimeCalculator.getTimeBetween(referenceDate, IBOR_AVERAGE_COUPON_DEFINITION_1.getPaymentDate());
    final CouponFixed coupon = new CouponFixed(CUR, paymentTime, ACCRUAL_FACTOR, NOTIONAL, FIXING_RATE);
    final Payment couponConverted = IBOR_AVERAGE_COUPON_DEFINITION_1.toDerivative(referenceDate, FIXING_TS);
    assertEquals("CouponIborAverageDefinition: toDerivative", coupon, couponConverted);
  }
View Full Code Here

    final double fixingPeriodEndTime1 = TimeCalculator.getTimeBetween(referenceDate, IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodEndDate1());
    final double fixingPeriodStartTime2 = TimeCalculator.getTimeBetween(referenceDate, IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodStartDate2());
    final double fixingPeriodEndTime2 = TimeCalculator.getTimeBetween(referenceDate, IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodEndDate2());
    // The fixing is known
    final CouponFixed coupon = new CouponFixed(CUR, paymentTime, ACCRUAL_FACTOR, NOTIONAL, FIXING_RATE);
    final Payment couponConverted = IBOR_AVERAGE_COUPON_DEFINITION_1.toDerivative(referenceDate, FIXING_TS);
    assertEquals(coupon, couponConverted);
    // The fixing is not known
    final DoubleTimeSeries<ZonedDateTime> fixingTS2 = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {ScheduleCalculator.getAdjustedDate(FIXING_DATE, -1, CALENDAR) },
        new double[] {FIXING_RATE });
    final CouponIborAverage coupon2 = new CouponIborAverage(CUR, paymentTime, ACCRUAL_FACTOR, NOTIONAL, fixingTime, INDEX_1, fixingPeriodStartTime1, fixingPeriodEndTime1,
        IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodAccrualFactor1(), INDEX_2, fixingPeriodStartTime2, fixingPeriodEndTime2,
        IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodAccrualFactor2(), WEIGHT_1, WEIGHT_2);
    final Payment couponConverted2 = IBOR_AVERAGE_COUPON_DEFINITION_1.toDerivative(referenceDate, fixingTS2);
    assertEquals("CouponIborAverageDefinition: toDerivative", coupon2, couponConverted2);
    final Payment couponConverted3 = IBOR_AVERAGE_COUPON_DEFINITION_1.toDerivative(referenceDate);
    assertEquals("CouponIborAverageDefinition: toDerivative", coupon2, couponConverted3);
  }
View Full Code Here

        final Annuity<Payment> firstLeg = swap.getFirstLeg();
        final Annuity<Payment> secondLeg = swap.getSecondLeg();
        if ((firstLeg.getPayments().length <= 1 && secondLeg.getPayments().length == 1) || (firstLeg.getPayments().length == 1 && secondLeg.getPayments().length <= 1)) {
          boolean firstPaymentFixed = true;
          if (firstLeg.getNumberOfPayments() > 0) {
            final Payment lastPayment = firstLeg.getNthPayment(0);
            firstPaymentFixed = lastPayment instanceof CouponFixed || lastPayment instanceof PaymentFixed;
          }
          boolean secondPaymentFixed = true;
          if (secondLeg.getPayments().length > 0) {
            final Payment lastPayment = secondLeg.getNthPayment(0);
            secondPaymentFixed = lastPayment instanceof CouponFixed || lastPayment instanceof PaymentFixed;
          }
          if (firstPaymentFixed && secondPaymentFixed) {
            // This will happen in the case where the final floating payment has fixed and the PV01 to the forward curve is requested.
            // In this case, it is reasonable to return 0.
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.interestrate.payments.derivative.Payment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.