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

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


    assertFalse("CouponArithmeticAverageON: equal-hash", FEDFUND_CPN_3M_DEF.equals(modified));
  }

  @Test
  public void toDerivativesNoData() {
    final CouponArithmeticAverageON cpnConverted = FEDFUND_CPN_3M_DEF.toDerivative(REFERENCE_DATE);
    final double payTime = TimeCalculator.getTimeBetween(REFERENCE_DATE, FEDFUND_CPN_3M_DEF.getPaymentDate());
    final double[] fixingTime = TimeCalculator.getTimeBetween(REFERENCE_DATE, FEDFUND_CPN_3M_DEF.getFixingPeriodDates());
    final CouponArithmeticAverageON cpnExpected = CouponArithmeticAverageON.from(payTime, FEDFUND_CPN_3M_DEF.getPaymentYearFraction(), NOTIONAL, FEDFUND, fixingTime,
        FEDFUND_CPN_3M_DEF.getFixingPeriodAccrualFactors(), 0);
    assertEquals("CouponArithmeticAverageONDefinition: toDerivative", cpnExpected, cpnConverted);
  }
View Full Code Here


  /**
   * Tests the toDerivative method.
   */
  public void toDerivativeNoFixing() {
    final String[] curvesNames = new String[] {"Funding", "Forward" };
    final CouponArithmeticAverageON cpnConverted = FEDFUND_CPN_3M_DEF.toDerivative(TRADE_DATE, curvesNames);
    final double paymentTime = TimeCalculator.getTimeBetween(TRADE_DATE, PAYMENT_DATE_3M);
    final double[] fixingPeriodTimes = TimeCalculator.getTimeBetween(TRADE_DATE, FEDFUND_CPN_3M_DEF.getFixingPeriodDates());
    final CouponArithmeticAverageON cpnExpected = CouponArithmeticAverageON.from(paymentTime, ACCURAL_FACTOR_3M, NOTIONAL, FEDFUND, fixingPeriodTimes,
        FEDFUND_CPN_3M_DEF.getFixingPeriodAccrualFactors(), 0.0);
    assertEquals("CouponArithmeticAverageON definition: toDerivative", cpnExpected, cpnConverted);
  }
View Full Code Here

   * Tests the toDerivative method.
   */
  public void toDerivativeFixingBeforeStart() {
    final ZonedDateTime referenceDate = ScheduleCalculator.getAdjustedDate(TRADE_DATE, 1, NYC);
    final DoubleTimeSeries<ZonedDateTime> fixingTS = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2011, 9, 7) }, new double[] {0.01 });
    final CouponArithmeticAverageON cpnConverted = (CouponArithmeticAverageON) FEDFUND_CPN_3M_DEF.toDerivative(referenceDate, fixingTS);
    final double paymentTime = TimeCalculator.getTimeBetween(referenceDate, PAYMENT_DATE_3M);
    final double[] fixingPeriodTimes = TimeCalculator.getTimeBetween(referenceDate, FEDFUND_CPN_3M_DEF.getFixingPeriodDates());
    final CouponArithmeticAverageON cpnExpected = CouponArithmeticAverageON.from(paymentTime, ACCURAL_FACTOR_3M, NOTIONAL, FEDFUND, fixingPeriodTimes,
        FEDFUND_CPN_3M_DEF.getFixingPeriodAccrualFactors(), 0.0);

    assertEquals("CouponArithmeticAverageON definition: toDerivative", cpnExpected, cpnConverted);
  }
View Full Code Here

    final DoubleTimeSeries<ZonedDateTime> fixingTS = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2011, 9, 7), DateUtils.getUTCDate(2011, 9, 8) },
        new double[] {0.01, 0.01 });
    final Payment cpnConverted = FEDFUND_CPN_3M_DEF.toDerivative(referenceDate, fixingTS);
    final double paymentTime = TimeCalculator.getTimeBetween(referenceDate, PAYMENT_DATE_3M);
    final double[] fixingPeriodTimes = TimeCalculator.getTimeBetween(referenceDate, FEDFUND_CPN_3M_DEF.getFixingPeriodDates());
    final CouponArithmeticAverageON cpnExpected = CouponArithmeticAverageON.from(paymentTime, ACCURAL_FACTOR_3M, NOTIONAL, FEDFUND, fixingPeriodTimes,
        FEDFUND_CPN_3M_DEF.getFixingPeriodAccrualFactors(), 0.0);
    assertEquals("CouponArithmeticAverageON definition: toDerivative", cpnExpected, cpnConverted);
  }
View Full Code Here

    final double[] fixingAccrualFactorsLeft = new double[FEDFUND_CPN_3M_DEF.getFixingPeriodAccrualFactors().length - 1];
    for (int loopperiod = 1; loopperiod < FEDFUND_CPN_3M_DEF.getFixingPeriodAccrualFactors().length; loopperiod++) {
      fixingAccrualFactorsLeft[loopperiod - 1] = FEDFUND_CPN_3M_DEF.getFixingPeriodAccrualFactors()[loopperiod];
    }
    final CouponArithmeticAverageON cpnExpected = CouponArithmeticAverageON.from(paymentTime, ACCURAL_FACTOR_3M, NOTIONAL, FEDFUND, fixingPeriodTimes,
        fixingAccrualFactorsLeft, rateAccrued);
    assertEquals("CouponArithmeticAverageON definition: toDerivative", cpnExpected, cpnConverted);
  }
View Full Code Here

    final double[] fixingAccrualFactorsLeft = new double[FEDFUND_CPN_7D_DEF.getFixingPeriodAccrualFactors().length - 2];
    for (int loopperiod = 2; loopperiod < FEDFUND_CPN_7D_DEF.getFixingPeriodAccrualFactors().length; loopperiod++) {
      fixingAccrualFactorsLeft[loopperiod - 2] = FEDFUND_CPN_7D_DEF.getFixingPeriodAccrualFactors()[loopperiod];
    }
    final CouponArithmeticAverageON cpnExpected = CouponArithmeticAverageON.from(paymentTime, ACCURAL_FACTOR_7D, NOTIONAL, FEDFUND, fixingPeriodTimes,
        fixingAccrualFactorsLeft, rateAccrued);
    assertEquals("CouponArithmeticAverageON definition: toDerivative", cpnExpected, cpnConverted);
  }
View Full Code Here

    final double[] fixingAccrualFactorsLeft = new double[FEDFUND_CPN_7D_DEF.getFixingPeriodAccrualFactors().length - 3];
    for (int loopperiod = 3; loopperiod < FEDFUND_CPN_7D_DEF.getFixingPeriodAccrualFactors().length; loopperiod++) {
      fixingAccrualFactorsLeft[loopperiod - 3] = FEDFUND_CPN_7D_DEF.getFixingPeriodAccrualFactors()[loopperiod];
    }
    final CouponArithmeticAverageON cpnExpected = CouponArithmeticAverageON.from(paymentTime, ACCURAL_FACTOR_7D, NOTIONAL, FEDFUND, fixingPeriodTimes,
        fixingAccrualFactorsLeft, rateAccrued);
    assertEquals("CouponArithmeticAverageON definition: toDerivative", cpnExpected, cpnConverted);
  }
View Full Code Here

        }

        for (int loopperiod = 0; loopperiod < _fixingPeriodAccrualFactors.length - fixedPeriod; loopperiod++) {
          fixingAccrualFactorsLeft[loopperiod] = _fixingPeriodAccrualFactors[loopperiod + fixedPeriod];
        }
        final CouponArithmeticAverageON cpn = CouponArithmeticAverageON.from(paymentTime, getPaymentYearFraction(), getNotional(), _index, fixingPeriodTimes,
            fixingAccrualFactorsLeft, accruedRate);
        return cpn;
      }
      return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), accruedRate / getPaymentYearFraction());
View Full Code Here

    startTime = System.currentTimeMillis();
    for (int looptest = 0; looptest < nbTest; looptest++) {
      final CouponArithmeticAverageONDefinition ffDefinition = CouponArithmeticAverageONDefinition.from(FEDFUND, ScheduleCalculator.getAdjustedDate(REFERENCE_DATE, TENOR_1Y, USDLIBOR3M, NYC), TENOR_3M,
          NOTIONAL, 0, USDLIBOR3M.getBusinessDayConvention(), true, NYC);
      final CouponArithmeticAverageON ff = ffDefinition.toDerivative(REFERENCE_DATE);
      pvExact = METHOD_FF_EXACT.presentValue(ff, MULTICURVES);
      //      pvExact = METHOD_FF_EXACT.presentValue(FEDFUND_CPN_3MFWD, MULTICURVES);
    }
    endTime = System.currentTimeMillis();
    System.out.println("CouponArithmeticAverageONDiscountingMethod: " + nbTest + " pv Arithmetic Average ON - Exact: " + (endTime - startTime) + " ms");
    // Performance note: AA ON exact pv: 26-Mar-2013: On Mac Pro 3.2 GHz Quad-Core Intel Xeon: 200 ms for 10000 coupons.
    // Performance note: AA ON exact constr. + pv: 26-Mar-2013: On Mac Pro 3.2 GHz Quad-Core Intel Xeon: 460 ms for 10000 coupons.

    startTime = System.currentTimeMillis();
    for (int looptest = 0; looptest < nbTest; looptest++) {
      final CouponArithmeticAverageONDefinition ffDefinition = CouponArithmeticAverageONDefinition.from(FEDFUND, ScheduleCalculator.getAdjustedDate(REFERENCE_DATE, TENOR_1Y, USDLIBOR3M, NYC), TENOR_3M,
          NOTIONAL, 0, USDLIBOR3M.getBusinessDayConvention(), true, NYC);
      final CouponArithmeticAverageON ff = ffDefinition.toDerivative(REFERENCE_DATE);
      pvAppro = METHOD_FF_APPRO.presentValue(ff, MULTICURVES);
      //      pvAppro = METHOD_FF_APPRO.presentValue(FEDFUND_CPN_3MFWD, MULTICURVES);
    }
    endTime = System.currentTimeMillis();
    System.out.println("CouponArithmeticAverageONDiscountingMethod: " + nbTest + " pv Arithmetic Average ON - Approximation: " + (endTime - startTime) + " ms");
View Full Code Here

      for (int loopstart = 0; loopstart < nbStart; loopstart++) {
        effectiveDate[loopstart] = ScheduleCalculator.getAdjustedDate(effectiveDate[0], step.multipliedBy(loopstart), USDLIBOR3M, NYC);
        final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(effectiveDate[loopstart], TENOR_3M, USDLIBOR3M, NYC);
        final CouponArithmeticAverageONDefinition cpnONDefinition = CouponArithmeticAverageONDefinition.from(FEDFUND, effectiveDate[loopstart], endDate, NOTIONAL, 0, NYC);
        final CouponArithmeticAverageON cpnON = cpnONDefinition.toDerivative(REFERENCE_DATE);
        // Compute daily forwards
        final int nbON = cpnON.getFixingPeriodAccrualFactors().length;
        final double fwdON[] = new double[nbON];
        for (int loopon = 0; loopon < nbON; loopon++) {
          fwdON[loopon] = multicurvesCst.getForwardRate(FEDFUND, cpnON.getFixingPeriodTimes()[loopon], cpnON.getFixingPeriodTimes()[loopon + 1], cpnON.getFixingPeriodAccrualFactors()[loopon]);
        }
        // Compounded period forward
        payComp[looplevel][loopstart] = multicurvesCst.getForwardRate(FEDFUND, cpnON.getFixingPeriodTimes()[0], cpnON.getFixingPeriodTimes()[nbON], cpnON.getFixingPeriodRemainingAccrualFactor())
            * cpnON.getFixingPeriodRemainingAccrualFactor();
        payAA[looplevel][loopstart] = 0;
        for (int loopon = 0; loopon < nbON; loopon++) {
          payAA[looplevel][loopstart] += fwdON[loopon] * cpnON.getFixingPeriodAccrualFactors()[loopon];
        }
        payAAApprox[looplevel][loopstart] = Math.log(1 + payComp[looplevel][loopstart]);
        rateComp[looplevel][loopstart] = payComp[looplevel][loopstart] / cpnON.getFixingPeriodRemainingAccrualFactor();
        rateAA[looplevel][loopstart] = payAA[looplevel][loopstart] / cpnON.getFixingPeriodRemainingAccrualFactor();
        rateAAApprox[looplevel][loopstart] = payAAApprox[looplevel][loopstart] / cpnON.getFixingPeriodRemainingAccrualFactor();
      }

    }
    //    int t = 0;
    //    t++;
View Full Code Here

TOP

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

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.