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

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


    System.out.println(j);
  }

  @Test(enabled = false)
  public void timeARefactored() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double startTime = System.currentTimeMillis();
    double j = 0;
    for (int i = 0; i < 100; i++) {
      CALCULATOR.getGammaCS01BucketedCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HR_DATES, HR_RATES, BP, SpreadBumpType.ADDITIVE, PriceType.CLEAN);
      j += i;
View Full Code Here


    CURVES = new ISDAYieldCurveAndHazardRateCurveProvider(YIELD_CURVE, HAZARD_RATE_CURVE);
  }

  @Test(enabled = false)
  public void regressionTest() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double deprecatedResult = DEPRECATED_CALCULATOR.calculateContingentLeg(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_RATE_CURVE);
    final double result = CALCULATOR.calculateLeg(VALUATION_DATE, cds, CURVES, PriceType.CLEAN);
    assertEquals(deprecatedResult, result, EPS);
  }
View Full Code Here

    assertEquals(deprecatedResult, result, EPS);
  }

  @Test(enabled = false)
  public void timeBDeprecated() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double startTime = System.currentTimeMillis();
    int j = 0;
    for (int i = 0; i < 500000; i++) {
      DEPRECATED_CALCULATOR.calculateContingentLeg(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_RATE_CURVE);
      j++;
View Full Code Here

    System.out.println("Deprecated:\t" + (endTime - startTime) / j * 100);
  }

  @Test(enabled = false)
  public void timeARefactored() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double startTime = System.currentTimeMillis();
    int j = 0;
    for (int i = 0; i < 500000; i++) {
      CALCULATOR.calculateLeg(VALUATION_DATE, cds, CURVES, PriceType.CLEAN);
      j++;
View Full Code Here

    CALCULATOR.getPresentValue(cds, CURVE_PROVIDER, VALUATION_DATE, null);
  }

  @Test
  public void testCDSTypes() {
    final CreditDefaultSwapDefinition cds = getLegacyVanillaDefinition();
    final PriceType priceType = PriceType.DIRTY;
    final double pv = CALCULATOR.getPresentValue(cds, CURVE_PROVIDER, VALUATION_DATE, priceType);
    assertEquals(pv, CALCULATOR.getPresentValue(getStandardVanillaDefinition(), CURVE_PROVIDER, VALUATION_DATE, priceType));
    assertEquals(pv, CALCULATOR.getPresentValue(getStandardFixedRecoveryDefinition(), CURVE_PROVIDER, VALUATION_DATE, priceType));
    assertEquals(pv, CALCULATOR.getPresentValue(getStandardForwardStartingDefinition(), CURVE_PROVIDER, VALUATION_DATE, priceType));
View Full Code Here

    assertEquals(pv, CALCULATOR.getPresentValue(getLegacySovereignDefinition(), CURVE_PROVIDER, VALUATION_DATE, priceType));
  }

  @Test
  public void testBuySell() {
    CreditDefaultSwapDefinition buy = getStandardVanillaDefinition(BuySellProtection.BUY);
    CreditDefaultSwapDefinition sell = getStandardVanillaDefinition(BuySellProtection.SELL);
    assertEquals(-CALCULATOR.getPresentValue(sell, CURVE_PROVIDER, VALUATION_DATE, PriceType.CLEAN),
        CALCULATOR.getPresentValue(buy, CURVE_PROVIDER, VALUATION_DATE, PriceType.CLEAN));
    buy = getLegacyVanillaDefinition(BuySellProtection.BUY);
    sell = getLegacyVanillaDefinition(BuySellProtection.SELL);
    assertEquals(-CALCULATOR.getPresentValue(sell, CURVE_PROVIDER, VALUATION_DATE, PriceType.CLEAN),
View Full Code Here

    }
    yieldCurve = new ISDADateCurve("ISDA", baseDate, ycDates, ycRates, offset);
    final HazardRateCurve hazardRateCurve = new HazardRateCurve(hazDates, hazTimes, hazRates, offset);

    for (int j = 5; j < 21; j += 3) {
      final CreditDefaultSwapDefinition cds1 = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(valDate.plusYears(j));

      final LocalDate[] res1Deprecated = ISDACompliantScheduleGenerator.toLocalDate(calculator.constructCreditDefaultSwapAccruedLegIntegrationSchedule(valDate, cds1, yieldCurve, hazardRateCurve, true));
      final int nRes1Deprecated = res1Deprecated.length;

      final LocalDate startDateLocal = ISDACompliantScheduleGenerator.toLocalDate(new ZonedDateTime[] {cds1.getStartDate() })[0];
      /*
       * Note cds1.getProtectionStart() == ture by default, thus .plusDays(1) is needed
       */
      final LocalDate endDateLocal = ISDACompliantScheduleGenerator.toLocalDate(new ZonedDateTime[] {cds1.getMaturityDate().plusDays(1) })[0];
      final LocalDate baseDateLocal = ISDACompliantScheduleGenerator.toLocalDate(new ZonedDateTime[] {baseDate })[0];
      final LocalDate[] hazDatesLocal = ISDACompliantScheduleGenerator.toLocalDate(hazDates);
      final LocalDate[] ycDatesLocal = ISDACompliantScheduleGenerator.toLocalDate(ycDates);

      final LocalDate[] res1 = ISDACompliantScheduleGenerator.getIntegrationNodesAsDates(startDateLocal, endDateLocal, ycDatesLocal, hazDatesLocal);
      final int nRes1 = res1.length;
      //      for (int i = 0; i < nRes1Deprecated; ++i) {
      //        System.out.println(res1Deprecated[i]);
      //      }
      //      System.out.println("\n");
      //      for (int i = 0; i < nRes1; ++i) {
      //        System.out.println(res1[i]);
      //      }
      //      System.out.println("\n");

      assertEquals(nRes1Deprecated, nRes1);
      for (int i = 0; i < nRes1; ++i) {
        assertTrue(res1[i].equals(res1Deprecated[i]));
      }

      /*
       * Note that valuation date is used only for start date and end date
       * Other date points are computed with the base date contained in yield curve and hazard rate curve
       */
      final double[] res2Deprecated = calculator.constructCreditDefaultSwapContingentLegIntegrationSchedule(baseDate, cds1.getStartDate(), cds1.getMaturityDate().plusDays(1),
          cds1, yieldCurve, hazardRateCurve);
      final int nRes2Deprecated = res2Deprecated.length;

      final int m = ycDatesLocal.length;
      /*
 
View Full Code Here

    CURVES = new ISDAYieldCurveAndHazardRateCurveProvider(YIELD_CURVE, HAZARD_RATE_CURVE);
  }

  @Test(enabled = false)
  public void regressionTest() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double deprecatedResult = DEPRECATED_CALCULATOR.calculatePremiumLeg(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_RATE_CURVE, PriceType.CLEAN);
    final double result = CALCULATOR.calculateLeg(VALUATION_DATE, cds, CURVES, PriceType.CLEAN);
    assertEquals(deprecatedResult, result, EPS);
  }
View Full Code Here

    assertEquals(deprecatedResult, result, EPS);
  }

  @Test(enabled = false)
  public void timeBDeprecated() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double startTime = System.currentTimeMillis();
    int j = 0;
    for (int i = 0; i < 100000; i++) {
      DEPRECATED_CALCULATOR.calculatePremiumLeg(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_RATE_CURVE, PriceType.CLEAN);
      j++;
View Full Code Here

    System.out.println("Deprecated:\t" + (endTime - startTime) / j * 100);
  }

  @Test(enabled = false)
  public void timeARefactored() {
    final CreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double startTime = System.currentTimeMillis();
    int j = 0;
    for (int i = 0; i < 100000; i++) {
      CALCULATOR.calculateLeg(VALUATION_DATE, cds, CURVES, PriceType.CLEAN);
      j++;
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.