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

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


    final double upFrontAmount = security.getUpfrontAmount().getAmount();
    final StubType stubType = security.getStubType().toAnalyticsType();
    final ZonedDateTime cashSettlementDate = security.getCashSettlementDate();
    final boolean adjustCashSettlementDate = security.isAdjustCashSettlementDate();
    final double coupon = security.getCoupon();
    return new LegacyVanillaCreditDefaultSwapDefinition(buySellProtection, DUMMY_OBLIGOR_A, DUMMY_OBLIGOR_B, DUMMY_OBLIGOR_C, currency,
        debtSeniority, restructuringClause, calendar, startDate, effectiveDate, maturityDate, stubType,
        couponFrequency, dayCount, businessDayConvention, immAdjustMaturityDate, adjustEffectiveDate, adjustMaturityDate,
        amount, recoveryRate, includeAccruedPremium, protectionStart, coupon);
  }
View Full Code Here


    final double recoveryRate = _recoveryRate;
    final boolean includeAccruedPremium = security.isIncludeAccruedPremium();
    final boolean protectionStart = security.isProtectionStart();
    final StubType stubType = security.getStubType().toAnalyticsType();
    final double parSpread = security.getParSpread();
    return new LegacyVanillaCreditDefaultSwapDefinition(buySellProtection, DUMMY_OBLIGOR_A, DUMMY_OBLIGOR_B, DUMMY_OBLIGOR_C, currency,
        debtSeniority, restructuringClause, calendar, startDate, effectiveDate, maturityDate, stubType,
        couponFrequency, dayCount, businessDayConvention, immAdjustMaturityDate, adjustEffectiveDate, adjustMaturityDate,
        amount, recoveryRate, includeAccruedPremium, protectionStart, parSpread);
  }
View Full Code Here

    spreads[0] = marketSpreads[0];

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

    // Create a CDS for calibration
    final LegacyVanillaCreditDefaultSwapDefinition calibrationCDS = cds;

    // Create a CDS for valuation
    final LegacyVanillaCreditDefaultSwapDefinition valuationCDS = cds;

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

    // Call the constructor to create a CDS present value object
    final PresentValueLegacyCreditDefaultSwap creditDefaultSwap = new PresentValueLegacyCreditDefaultSwap();
View Full Code Here

    }

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

    // Create a CDS for calibration
    final LegacyVanillaCreditDefaultSwapDefinition calibrationCDS = cds;

    // Call the constructor to create a calibrate hazard rate curve object
    final CalibrateHazardRateCurveLegacyCreditDefaultSwap hazardRateCurve = new CalibrateHazardRateCurveLegacyCreditDefaultSwap();

    // ----------------------------------------------------------------------------------------------------------------------------------------
View Full Code Here

    double frontendProtection = 0.0;

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

    // Create a copy of the underlying CDS for the purposes of calibration of the hazard rate term structure
    final LegacyVanillaCreditDefaultSwapDefinition underlyingCalibrationCDS = (LegacyVanillaCreditDefaultSwapDefinition) cdsSwaption.getUnderlyingCDS();

    // Build a hazard rate curve object based on the input market data
    //final HazardRateCurve calibratedHazardRateCurve = creditDefaultSwap.calibrateHazardRateCurve(valuationDate, underlyingCalibrationCDS, calibrationTenors, marketSpreads, yieldCurve);
    final HazardRateCurve calibratedHazardRateCurve = cdsCalibrator.isdaCalibrateHazardRateCurve(valuationDate, underlyingCalibrationCDS, calibrationTenors, marketSpreads, yieldCurve);
View Full Code Here

  @Deprecated
  public double calibrateAndGetPresentValue(final ZonedDateTime valuationDate, final LegacyVanillaCreditDefaultSwapDefinition cds, final ZonedDateTime[] marketTenors, final double[] marketSpreads,
      final ISDADateCurve yieldCurve, final PriceType priceType) {

    // Create a CDS for valuation
    final LegacyVanillaCreditDefaultSwapDefinition valuationCDS = cds;

    // Call the constructor to create a CDS present value object
    final PresentValueLegacyCreditDefaultSwap creditDefaultSwap = new PresentValueLegacyCreditDefaultSwap();

    // Build a hazard rate curve object based on the input market data
View Full Code Here

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

    // Create a CDS whose maturity and spreads we will vary to be that of the calibration instruments
    LegacyVanillaCreditDefaultSwapDefinition calibrationCDS = cds;

    // This vector will store the bootstrapped hazard rates that will be used to construct the calibrated hazard rate term structure object
    double[] calibratedHazardRateCurve = new double[marketTenors.length];

    // The tenorsAsDoubles vector includes time zero (valuationDate)
    final double[] tenorsAsDoubles = new double[marketTenors.length + 1];

    tenorsAsDoubles[0] = 0.0;
    for (int m = 1; m <= marketTenors.length; m++) {
      tenorsAsDoubles[m] = ACT_365.getDayCountFraction(valuationDate, marketTenors[m - 1]);
    }

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

    // Loop over each of the calibration instruments
    for (int i = 0; i < marketTenors.length; i++) {

      // Remember that the input spreads are in bps, therefore need dividing by 10,000
      final double guess = (marketSpreads[i] / 10000.0) / (1 - cds.getRecoveryRate());

      // Modify the input CDS to have the maturity of the current calibration instrument
      calibrationCDS = calibrationCDS.withMaturityDate(marketTenors[i]);

      // Modify the input CDS to have the par spread of the current calibration instrument
      calibrationCDS = calibrationCDS.withSpread(marketSpreads[i]);

      // Now need to build a HazardRateCurve object from the first i calibrated points
      double[] runningTenorsAsDoubles = new double[i + 1];
      double[] runningHazardRates = new double[i + 1];
View Full Code Here

    YIELD_CURVE = new ISDADateCurve("ISDA", BASE_DATE, YC_DATES, YC_RATES, OFFSET);
  }

  @Test(enabled = false)
  public void regressionTest() {
    final LegacyVanillaCreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double[] deprecatedResult = DEPRECATED_CALCULATOR.getCS01BucketedCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HR_DATES, HR_RATES, BP, SpreadBumpType.ADDITIVE, PriceType.CLEAN);
    final double[] result = CALCULATOR.getCS01BucketedCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HR_DATES, HR_RATES, BP, SpreadBumpType.ADDITIVE, PriceType.CLEAN);
    assertArrayEquals(deprecatedResult, result, EPS);
  }
View Full Code Here

    assertArrayEquals(deprecatedResult, result, EPS);
  }

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

    System.out.println(j);
  }

  @Test(enabled = false)
  public void timeARefactored() {
    final LegacyVanillaCreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
    final double startTime = System.currentTimeMillis();
    double j = 0;
    for (int i = 0; i < 100; i++) {
      CALCULATOR.getCS01BucketedCreditDefaultSwap(VALUATION_DATE, cds, YIELD_CURVE, HR_DATES, HR_RATES, BP, SpreadBumpType.ADDITIVE, PriceType.CLEAN);
      j += i;
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.