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

Examples of com.opengamma.analytics.financial.interestrate.fra.derivative.ForwardRateAgreement


  @Test
  public void testFRA() {
    final IborIndex index = new IborIndex(CUR, Period.ofMonths(1), 2, DayCountFactory.INSTANCE.getDayCount("Actual/365"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"), true, "Ibor");
    final ForwardRateAgreement fra1 = new ForwardRateAgreement(CUR, 0.5, 0.5, 1, index, 0.5, 0.5, 1, 0.5, R1);
    final ForwardRateAgreement fra2 = new ForwardRateAgreement(CUR, 0.5, 0.5, 1, index, 0.5, 0.5, 1, 0.5, R2);
    assertEquals(fra1.accept(VISITOR, R2), fra2);
  }
View Full Code Here


   * @param notional the notional amount
   * @return A FRA
   */
  public static InstrumentDerivative makeFRA(final double time, final SimpleFrequency paymentFreq, final double rate, final double notional) {
    final double tau = 1. / paymentFreq.getPeriodsPerYear();
    return new ForwardRateAgreement(DUMMY_CUR, time - tau, tau, notional, DUMMY_INDEX, time - tau, time - tau, time, tau, rate);
  }
View Full Code Here

    final double fixingPeriodEndTime = 7. / 12;
    final double fixingTime = fixingPeriodStartTime;
    final double fixingYearFraction = 31. / 365;
    final double paymentYearFraction = 30. / 360;
    final double rate = 0.06534;
    final ForwardRateAgreement fra = new ForwardRateAgreement(CUR, paymentTime, FIVE_PC_CURVE_NAME, paymentYearFraction, 1, index, fixingTime, fixingPeriodStartTime, fixingPeriodEndTime,
        fixingYearFraction, rate, FIVE_PC_CURVE_NAME);
    final ForwardRateAgreement fraUp = new ForwardRateAgreement(CUR, paymentTime, FIVE_PC_CURVE_NAME, paymentYearFraction, 1, index, fixingTime, fixingPeriodStartTime, fixingPeriodEndTime,
        fixingYearFraction, rate + DELTA, FIVE_PC_CURVE_NAME);
    final ForwardRateAgreement fraDown = new ForwardRateAgreement(CUR, paymentTime, FIVE_PC_CURVE_NAME, paymentYearFraction, 1, index, fixingTime, fixingPeriodStartTime, fixingPeriodEndTime,
        fixingYearFraction, rate - DELTA, FIVE_PC_CURVE_NAME);
    final double pvUp = fraUp.accept(PVC, CURVES);
    final double pvDown = fraDown.accept(PVC, CURVES);
    final double temp = (pvUp - pvDown) / 2 / DELTA;
    //TODO accuracy is off compared to old FRA definition
    assertEquals(temp, fra.accept(PVCSC, CURVES), 1e-5);
  }
View Full Code Here

    final double fixingPeriodStartTime = paymentTime;
    final double fixingPeriodEndTime = 7. / 12;
    final double fixingYearFraction = 31. / 365;
    final IborIndex index = new IborIndex(CUR, Period.ofMonths(1), 2, DayCountFactory.INSTANCE.getDayCount("Actual/365"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"), true, "Ibor");
    final ForwardRateAgreement fra = new ForwardRateAgreement(CUR, paymentTime, paymentYearFraction, 1, index, fixingTime, fixingPeriodStartTime, fixingPeriodEndTime, fixingYearFraction,
        0.05);

    assertEquals(fixingPeriodEndTime, fra.accept(LDC), 1e-12);
  }
View Full Code Here

    double fixingTime = paymentTime;
    final double fixingPeriodStart = paymentTime;
    double fixingYearFraction = paymentYearFraction;
    final YieldAndDiscountCurve forwardCurve = CURVES.getCurve(FIVE_PC_CURVE_NAME);
    final double rate = (forwardCurve.getDiscountFactor(paymentTime) / forwardCurve.getDiscountFactor(fixingPeriodEnd) - 1.0) * 12.0;
    ForwardRateAgreement fra = new ForwardRateAgreement(CUR, paymentTime, fundingCurveName, paymentYearFraction, notional, index, fixingTime, fixingPeriodStart, fixingPeriodEnd, fixingYearFraction,
        rate, forwardCurveName);
    double pv = fra.accept(PVC, CURVES);
    assertEquals(0.0, pv, 1e-12);

    fixingTime = paymentTime - 2. / 365.;
    fixingYearFraction = 31. / 365;
    paymentYearFraction = 30. / 360;
    fundingCurveName = FIVE_PC_CURVE_NAME;
    final double forwardRate = (forwardCurve.getDiscountFactor(fixingPeriodStart) / forwardCurve.getDiscountFactor(fixingPeriodEnd) - 1) / fixingYearFraction;
    final double fv = (forwardRate - rate) * paymentYearFraction / (1 + forwardRate * paymentYearFraction);
    final double pv2 = fv * forwardCurve.getDiscountFactor(paymentTime);
    fra = new ForwardRateAgreement(CUR, paymentTime, fundingCurveName, paymentYearFraction, notional, index, fixingTime, fixingPeriodStart, fixingPeriodEnd, fixingYearFraction, rate, forwardCurveName);
    pv = fra.accept(PVC, CURVES);
    assertEquals(pv, pv2, 1e-12);
  }
View Full Code Here

    final double fixingPeriodStartTime = paymentTime;
    final double fixingPeriodEndTime = 7. / 12;
    final double fixingYearFraction = 31. / 365;
    final IborIndex index = new IborIndex(CUR, Period.ofMonths(1), 2, DayCountFactory.INSTANCE.getDayCount("Actual/365"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"), true);
    ForwardRateAgreement fra = new ForwardRateAgreement(CUR, paymentTime, FIVE_PC_CURVE_NAME, paymentYearFraction, 1, index, fixingTime, fixingPeriodStartTime, fixingPeriodEndTime,
        fixingYearFraction, 0, FIVE_PC_CURVE_NAME);
    final double rate = fra.accept(PRC, CURVES);
    fra = new ForwardRateAgreement(CUR, paymentTime, FIVE_PC_CURVE_NAME, paymentYearFraction, 1, index, fixingTime, fixingPeriodStartTime, fixingPeriodEndTime, fixingYearFraction, rate,
        FIVE_PC_CURVE_NAME);
    assertEquals(0.0, fra.accept(PVC, CURVES), 1e-12);
  }
View Full Code Here

    final double fixingPeriodEnd = 7.0 / 12.0;
    final double rate = 0.0;
    final double fixingPeriodStart = paymentTime;
    final double fixingYearFraction = 31.0 / 365.0;
    final double paymentYearFraction = 30.0 / 360;
    final ForwardRateAgreement fra = new ForwardRateAgreement(CUR, paymentTime, FUNDING_CURVE_NAME, paymentYearFraction, 1, index, fixingTime, fixingPeriodStart, fixingPeriodEnd, fixingYearFraction,
        rate, LIBOR_CURVE_NAME);
    doTest(fra, CURVES);
  }
View Full Code Here

  @Test
  public void testFRA() {
    final IborIndex index = new IborIndex(CUR, Period.ofMonths(1), 2, DayCountFactory.INSTANCE.getDayCount("Actual/365"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"), true);
    final ForwardRateAgreement fra1 = new ForwardRateAgreement(CUR, 0.5, N1, 0.5, 1, index, 0.5, 0.5, 1, 0.5, R1, N2);
    final ForwardRateAgreement fra2 = new ForwardRateAgreement(CUR, 0.5, N1, 0.5, 1, index, 0.5, 0.5, 1, 0.5, R2, N2);
    assertEquals(fra1.accept(VISITOR, R2), fra2);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.interestrate.fra.derivative.ForwardRateAgreement

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.