Package com.opengamma.analytics.financial.instrument.payment

Examples of com.opengamma.analytics.financial.instrument.payment.CouponFixedDefinition


  @Test
  public void testToDerivative() {
    final double sign = IS_PAYER ? -1.0 : 1.0;
    final CouponFixedDefinition[] coupons = new CouponFixedDefinition[PAYMENT_DATES.length];
    //First coupon uses settlement date
    coupons[0] = new CouponFixedDefinition(CUR, PAYMENT_DATES[0], SETTLEMENT_DATE, PAYMENT_DATES[0], DAY_COUNT.getDayCountFraction(SETTLEMENT_DATE, PAYMENT_DATES[0]), sign * NOTIONAL, RATE);
    for (int loopcpn = 1; loopcpn < PAYMENT_DATES.length; loopcpn++) {
      coupons[loopcpn] = new CouponFixedDefinition(CUR, PAYMENT_DATES[loopcpn], PAYMENT_DATES[loopcpn - 1], PAYMENT_DATES[loopcpn], DAY_COUNT.getDayCountFraction(PAYMENT_DATES[loopcpn - 1],
          PAYMENT_DATES[loopcpn]), sign * NOTIONAL, RATE);
    }
    final AnnuityCouponFixedDefinition fixedAnnuity = new AnnuityCouponFixedDefinition(coupons, CALENDAR);
    final CouponFixed[] couponFixedConverted = new CouponFixed[PAYMENT_DATES.length];
    for (int loopcpn = 0; loopcpn < PAYMENT_DATES.length; loopcpn++) {
View Full Code Here


   */
  public void presentValue() {
    final CurrencyAmount pv = METHOD.presentValue(COUPON, CURVES_BUNDLE);
    final CouponIborDefinition couponIborDefinition = new CouponIborDefinition(CUR, ACCRUAL_END_DATE, ACCRUAL_START_DATE, ACCRUAL_END_DATE, ACCRUAL_FACTOR, NOTIONAL, FIXING_DATE, INDEX, CALENDAR);
    final Payment couponIbor = couponIborDefinition.toDerivative(REFERENCE_DATE, CURVES_NAMES);
    final CouponFixedDefinition couponFixedDefinition = new CouponFixedDefinition(couponIborDefinition, SPREAD);
    final Payment couponFixed = couponFixedDefinition.toDerivative(REFERENCE_DATE, CURVES_NAMES);
    final PresentValueCalculator pvc = PresentValueCalculator.getInstance();
    final double pvIbor = couponIbor.accept(pvc, CURVES_BUNDLE);
    final double pvFixed = couponFixed.accept(pvc, CURVES_BUNDLE);
    assertEquals("Present value by discounting", pvIbor * FACTOR + pvFixed, pv.getAmount());
  }
View Full Code Here

    final AnnuityCouponFixedDefinition coupons = bond.getCoupons();
    final int n = coupons.getNumberOfPayments();
    final LocalDate[] dates = new LocalDate[n];
    final double[] payments = new double[n];
    for (int i = 0; i < n; i++) {
      final CouponFixedDefinition coupon = coupons.getNthPayment(i);
      dates[i] = coupon.getPaymentDate().toLocalDate();
      payments[i] = coupon.getAmount() * coupon.getNotional();
    }
    payments[n - 1] += coupons.getNthPayment(n - 1).getNotional();
    final LocalDateLabelledMatrix1D matrix = new LocalDateLabelledMatrix1D(dates, payments);
    return Collections.singleton(new ComputedValue(new ValueSpecification(ValueRequirementNames.BOND_COUPON_PAYMENT_TIMES, target.toSpecification(), createValueProperties().get()), matrix));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.instrument.payment.CouponFixedDefinition

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.