Package com.opengamma.analytics.financial.credit.creditdefaultswap.definition.vanilla

Examples of com.opengamma.analytics.financial.credit.creditdefaultswap.definition.vanilla.CreditDefaultSwapDefinition


    CALCULATOR.constructCreditDefaultSwapAccruedLegIntegrationSchedule(VALUATION_DATE, cds1, yc, hazardRateCurve, true);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void accLegNullHazardTest() {
    final CreditDefaultSwapDefinition cds1 = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final HazardRateCurve hazardRateCurve = null;

    CALCULATOR.constructCreditDefaultSwapAccruedLegIntegrationSchedule(VALUATION_DATE, cds1, YIELD_CURVE, hazardRateCurve, true);
  }
View Full Code Here


  //    }
  //  }

  @Test
  public void cngLegRegrTest() {
    CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final ZonedDateTime[] hrDates = new ZonedDateTime[HR_DATES.length];
    final double[] hrTimes = new double[HR_TIMES.length];
    final int len = HR_DATES.length;
    for (int i = 0; i < len; i++) {
      hrDates[i] = HR_DATES[i].plusDays(12);
      hrTimes[i] = DAY_COUNT.getDayCountFraction(BASE_DATE, hrDates[i]);
    }
    final HazardRateCurve hazardRateCurve = new HazardRateCurve(hrDates, hrTimes, HR_RATES, OFFSET);
    ZonedDateTime startDate = getStartDate(cds);
    final ZonedDateTime endDate = cds.getMaturityDate();

    final int lenExp = hrDates.length - 1 + YC_DATES.length - 1 + 2;
    final DayCount act365 = DayCountFactory.INSTANCE.getDayCount("ACT/365");
    final double[] ans = new double[lenExp];
    for (int i = 0; i < YC_DATES.length - 1; i++) {
View Full Code Here

  @Test
  public void testCngLegWithFixedCurve() {
    final HazardRateCurve hrCurve = new HazardRateCurve(HR_DATES, HR_TIMES, HR_RATES, OFFSET);
    for (int j = 1; j < 25; j += 3) {
      CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinitionWithProtectionStart(true)
          .withMaturityDate(YC_DATES[YC_DATES.length - 1].minusMonths(1))
          .withEffectiveDate(VALUATION_DATE.minusMonths(1).plusDays(j))
          .withStartDate(VALUATION_DATE.minusMonths(1));
      final ZonedDateTime[] hrDates = new ZonedDateTime[HR_DATES.length];
      final double[] hrTimes = new double[HR_TIMES.length];
      final int len = HR_DATES.length;
      for (int i = 0; i < len; i++) {
        hrDates[i] = HR_DATES[i].plusDays(12);
        hrTimes[i] = DAY_COUNT.getDayCountFraction(BASE_DATE, hrDates[i]);
      }
      ZonedDateTime startDate = getStartDate(cds);
      final ZonedDateTime endDate = cds.getMaturityDate();
      final int lenExp = YC_DATES.length + 2;

      final DayCount act365 = DayCountFactory.INSTANCE.getDayCount("ACT/365");
      final double[] ans = new double[lenExp];
      for (int i = 0; i < lenExp - 2; i++) {
View Full Code Here

    }
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void cngLegNullCdsTest() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final ZonedDateTime[] hrDates = new ZonedDateTime[HR_DATES.length];
    final double[] hrTimes = new double[HR_TIMES.length];
    final int len = HR_DATES.length;
    for (int i = 0; i < len; i++) {
      hrDates[i] = HR_DATES[i].plusDays(12);
      hrTimes[i] = DAY_COUNT.getDayCountFraction(BASE_DATE, hrDates[i]);
    }
    final HazardRateCurve hazardRateCurve = new HazardRateCurve(hrDates, hrTimes, HR_RATES, OFFSET);
    final ZonedDateTime startDate = getStartDate(cds);
    final ZonedDateTime endDate = cds.getMaturityDate();
    final CreditDefaultSwapDefinition cdsNull = null;

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, startDate, endDate, cdsNull, YIELD_CURVE, hazardRateCurve);
  }
View Full Code Here

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, startDate, endDate, cdsNull, YIELD_CURVE, hazardRateCurve);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void cngLegNullYieldTest() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final ZonedDateTime[] hrDates = new ZonedDateTime[HR_DATES.length];
    final double[] hrTimes = new double[HR_TIMES.length];
    final int len = HR_DATES.length;
    for (int i = 0; i < len; i++) {
      hrDates[i] = HR_DATES[i].plusDays(12);
      hrTimes[i] = DAY_COUNT.getDayCountFraction(BASE_DATE, hrDates[i]);
    }
    final HazardRateCurve hazardRateCurve = new HazardRateCurve(hrDates, hrTimes, HR_RATES, OFFSET);
    final ZonedDateTime startDate = getStartDate(cds);
    final ZonedDateTime endDate = cds.getMaturityDate();
    final ISDADateCurve yc = null;

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, startDate, endDate, cds, yc, hazardRateCurve);
  }
View Full Code Here

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, startDate, endDate, cds, yc, hazardRateCurve);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void cngLegNullHazardTest() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final HazardRateCurve hazardRateCurve = null;
    final ZonedDateTime startDate = getStartDate(cds);
    final ZonedDateTime endDate = cds.getMaturityDate();

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, startDate, endDate, cds, YIELD_CURVE, hazardRateCurve);
  }
View Full Code Here

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, startDate, endDate, cds, YIELD_CURVE, hazardRateCurve);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void cngEndBeforeStartTest() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final ZonedDateTime[] hrDates = new ZonedDateTime[HR_DATES.length];
    final double[] hrTimes = new double[HR_TIMES.length];
    final int len = HR_DATES.length;
    for (int i = 0; i < len; i++) {
      hrDates[i] = HR_DATES[i].plusDays(12);
      hrTimes[i] = DAY_COUNT.getDayCountFraction(BASE_DATE, hrDates[i]);
    }
    final HazardRateCurve hazardRateCurve = new HazardRateCurve(hrDates, hrTimes, HR_RATES, OFFSET);
    final ZonedDateTime startDate = getStartDate(cds);
    final ZonedDateTime endDate = cds.getMaturityDate();

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, endDate, startDate, cds, YIELD_CURVE, hazardRateCurve);
  }
View Full Code Here

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(VALUATION_DATE, endDate, startDate, cds, YIELD_CURVE, hazardRateCurve);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void endBeforeValuateTest() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final ZonedDateTime[] hrDates = new ZonedDateTime[HR_DATES.length];
    final double[] hrTimes = new double[HR_TIMES.length];
    final int len = HR_DATES.length;
    for (int i = 0; i < len; i++) {
      hrDates[i] = HR_DATES[i].plusDays(12);
      hrTimes[i] = DAY_COUNT.getDayCountFraction(BASE_DATE, hrDates[i]);
    }
    final HazardRateCurve hazardRateCurve = new HazardRateCurve(hrDates, hrTimes, HR_RATES, OFFSET);
    final ZonedDateTime startDate = getStartDate(cds);
    final ZonedDateTime endDate = cds.getMaturityDate();
    final ZonedDateTime ev = DateUtils.getUTCDate(2043, 1, 6);

    CALCULATOR.constructCreditDefaultSwapContingentLegIntegrationSchedule(ev, endDate, startDate, cds, YIELD_CURVE, hazardRateCurve);
    //    System.out.println(new DoubleMatrix1D(res));
  }
View Full Code Here

    final HazardRateCurve calibratedHazardRateCurve = cdsCalibrator.isdaCalibrateHazardRateCurve(valuationDate, underlyingCalibrationCDS, calibrationTenors, marketSpreads, yieldCurve);

    // ----------------------------------------------------------------------------------------------------------------------------------------

    // Get the underlying CDS in the swaption contract (don't really need to do this if we fix the LegacyVanilla issue above)
    final CreditDefaultSwapDefinition underlyingCDS = cdsSwaption.getUnderlyingCDS();

    CreditDefaultSwapDefinition shortCDS = cdsSwaption.getUnderlyingCDS();

    shortCDS = shortCDS.withStartDate(cdsSwaption.getStartDate());
    shortCDS = shortCDS.withEffectiveDate(cdsSwaption.getStartDate().plusDays(1));
    shortCDS = shortCDS.withMaturityDate(cdsSwaption.getOptionExerciseDate());

    // Generate the cashflow schedule for the (forward) premium leg
    final ZonedDateTime[] underlyingCDSPremiumLegSchedule = PREMIUM_LEG_SCHEDULE_CALCULATOR.constructCreditDefaultSwapPremiumLegSchedule(underlyingCDS);

    final ZonedDateTime[] shortCDSPremiumLegSchedule = PREMIUM_LEG_SCHEDULE_CALCULATOR.constructCreditDefaultSwapPremiumLegSchedule(shortCDS);
View Full Code Here

  // Builder method to modify the recovery rate of the underlying CDS in a CDS Swaption contract

  public CreditDefaultSwapOptionDefinition withRecoveryRate(final double recoveryRate) {

    // Extract the underlying CDS from the CDS Swaption contract
    CreditDefaultSwapDefinition modifiedCDS = getUnderlyingCDS();

    // Modify the recovery rate of the underlying CDS
    modifiedCDS = modifiedCDS.withRecoveryRate(recoveryRate);

    // Return the modified CDS Swaption contract
    return new CreditDefaultSwapOptionDefinition(
        getBuySellProtection(),
        getProtectionBuyer(),
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.credit.creditdefaultswap.definition.vanilla.CreditDefaultSwapDefinition

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.