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

Examples of com.opengamma.analytics.financial.credit.creditdefaultswap.definition.legacy.LegacyVanillaCreditDefaultSwapDefinition


        CALCULATOR.getPresentValue(buy, CURVE_PROVIDER, VALUATION_DATE, PriceType.CLEAN));
  }

  @Test(enabled = true)
  public void regressionTestCleanPrice() {
    final LegacyVanillaCreditDefaultSwapDefinition cds = getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double deprecatedResult = DEPRECATED_CALCULATOR.getPresentValueLegacyCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_RATE_CURVE, PriceType.CLEAN);
    final double result = CALCULATOR.getPresentValue(cds, CURVE_PROVIDER, VALUATION_DATE, PriceType.CLEAN);
    assertEquals(deprecatedResult, result, EPS);
  }
View Full Code Here


    assertEquals(deprecatedResult, result, EPS);
  }
 
  @Test(enabled = true)
  public void regressionTestDirtyPrice() {
    final LegacyVanillaCreditDefaultSwapDefinition cds = getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double deprecatedResult = DEPRECATED_CALCULATOR.getPresentValueLegacyCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_RATE_CURVE, PriceType.DIRTY);
    final double result = CALCULATOR.getPresentValue(cds, CURVE_PROVIDER, VALUATION_DATE, PriceType.DIRTY);
    assertEquals(deprecatedResult, result, EPS);
  }
View Full Code Here

    assertEquals(deprecatedResult, result, EPS);
  }

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

  /**
   * Test that the entire swap value is equal to the value of the contingent leg when the par spread on the premium leg is zero.
   */
  @Test
  public void testParSpreadEqualsZero() {
    final LegacyVanillaCreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinitionWithParSpread(0).withMaturityDate(VALUATION_DATE.plusYears(10));
    final double contingentLeg = CALCULATOR.calculateContingentLeg(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_CURVE);
    final double cleanPrice = LEGACY_CALCULATOR.getPresentValueLegacyCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_CURVE, PriceType.CLEAN);
    final double dirtyPrice = LEGACY_CALCULATOR.getPresentValueLegacyCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HAZARD_CURVE, PriceType.DIRTY);
    assertEquals(contingentLeg, cleanPrice, EPS);
    assertEquals(contingentLeg, dirtyPrice, EPS);
View Full Code Here

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

  @Test(enabled = false)
  public void timeACRefactored() {
    final LegacyVanillaCreditDefaultSwapDefinition cds = getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double startTime = System.currentTimeMillis();
    int j = 0;
    for (int i = 0; i < 100000; i++) {
      CALCULATOR.getPresentValue(cds, CURVE_PROVIDER, VALUATION_DATE, PriceType.CLEAN);
      j++;
View Full Code Here

  /**
   * Test trivial case with zero par spreads, zero hazard rates. This is a test that the methods in {@link PresentValueCreditDefaultSwap} are in sync with {@link PresentValueLegacyCreditDefaultSwap}
   */
  @Test
  public void testCreditSpreadsEqualZero() {
    final LegacyVanillaCreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double contingentLeg = CALCULATOR.calculateContingentLeg(VALUATION_DATE, cds, YIELD_CURVE, ZERO_HAZARD_CURVE);
    final double cleanRiskyAnnuity = CALCULATOR.calculatePremiumLeg(VALUATION_DATE, cds, YIELD_CURVE, ZERO_HAZARD_CURVE, PriceType.CLEAN);
    final double dirtyRiskyAnnuity = CALCULATOR.calculatePremiumLeg(VALUATION_DATE, cds, YIELD_CURVE, ZERO_HAZARD_CURVE, PriceType.DIRTY);
    final double cleanPremiumLeg = -cleanRiskyAnnuity * cds.getParSpread() / BP;
    final double dirtyPremiumLeg = -dirtyRiskyAnnuity * cds.getParSpread() / BP;
    final double cleanPrice = CALCULATOR.calibrateAndGetPresentValue(VALUATION_DATE, cds, MARKET_TENORS, ZERO_SPREADS, YIELD_CURVE, PriceType.CLEAN);
    final double dirtyPrice = CALCULATOR.calibrateAndGetPresentValue(VALUATION_DATE, cds, MARKET_TENORS, ZERO_SPREADS, YIELD_CURVE, PriceType.DIRTY);
    assertEquals(0, contingentLeg, EPS);
    assertEquals(cleanPremiumLeg / cleanPrice - 1.0, 0.0, EPS);
    assertEquals(dirtyPremiumLeg / dirtyPrice - 1.0, 0.0, EPS);
View Full Code Here

    final double calibrationRecoveryRate = 0.40;

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

    // Create a calibration CDS (will be a modified version of the baseline CDS)
    final LegacyVanillaCreditDefaultSwapDefinition calibrationCDS = cds;

    /*

    // Set the recovery rate of the calibration CDS used for the curve calibration (this appears in the calculation of the contingent leg)
    calibrationCDS = calibrationCDS.withRecoveryRate(calibrationRecoveryRate);
View Full Code Here

    final ZonedDateTime valuationDate = DateUtils.getUTCDate(2008, 6, 19);
    final ZonedDateTime startDate = DateUtils.getUTCDate(2008, 6, 25); // TODO: meaningful dates
    final ZonedDateTime effectiveDate = DateUtils.getUTCDate(2008, 6, 27);
    final ZonedDateTime maturityDate = DateUtils.getUTCDate(2014, 6, 27);

    final LegacyVanillaCreditDefaultSwapDefinition cds = new LegacyVanillaCreditDefaultSwapDefinition(buySellProtection, protectionBuyer, protectionSeller, referenceEntity, currency, debtSeniority,
        restructuringClause, calendar, startDate, effectiveDate, maturityDate, stubType, couponFrequency, daycountFractionConvention, businessdayAdjustmentConvention, immAdjustMaturityDate,
        adjustEffectiveDate, adjustMaturityDate, notional, recoveryRate, includeAccruedPremium, protectionStart, parSpread);

    final PresentValueCreditDefaultSwap pvcds = new PresentValueCreditDefaultSwap();
View Full Code Here

  private static final boolean PROTECTION_START = true;

  private static final double PAR_SPREAD = 123.0;

  public static LegacyVanillaCreditDefaultSwapDefinition getLegacyVanillaDefinition() {
    return new LegacyVanillaCreditDefaultSwapDefinition(BUY_SELL_PROTECTION, getObligor1(), getObligor2(), getObligor3(), CURRENCY,
        DEBT_SENIORITY, RESTRUCTURING_CLAUSE, CALENDAR, START_DATE, EFFECTIVE_DATE, MATURITY_DATE, STUB_TYPE,
        COUPON_FREQUENCY, DAY_COUNT, BUSINESS_DAY, IMM_ADJUST_MATURITY_DATE, ADJUST_EFFECTIVE_DATE, ADJUST_MATURITY_DATE,
        NOTIONAL, RECOVERY_RATE, INCLUDE_ACCRUED_PREMIUM, PROTECTION_START, PAR_SPREAD);
  }
View Full Code Here

        NOTIONAL, RECOVERY_RATE, INCLUDE_ACCRUED_PREMIUM, PROTECTION_START, PAR_SPREAD, StandardCDSCoupon._1000bps,
        100, EFFECTIVE_DATE, false);
  }

  public static LegacyVanillaCreditDefaultSwapDefinition getLegacyVanillaDefinition(final BuySellProtection buySell) {
    return new LegacyVanillaCreditDefaultSwapDefinition(buySell, getObligor1(), getObligor2(), getObligor3(), CURRENCY,
        DEBT_SENIORITY, RESTRUCTURING_CLAUSE, CALENDAR, START_DATE, EFFECTIVE_DATE, MATURITY_DATE, STUB_TYPE,
        COUPON_FREQUENCY, DAY_COUNT, BUSINESS_DAY, IMM_ADJUST_MATURITY_DATE, ADJUST_EFFECTIVE_DATE, ADJUST_MATURITY_DATE,
        NOTIONAL, RECOVERY_RATE, INCLUDE_ACCRUED_PREMIUM, PROTECTION_START, PAR_SPREAD);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.credit.creditdefaultswap.definition.legacy.LegacyVanillaCreditDefaultSwapDefinition

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.