Package com.opengamma.analytics.financial.credit.hazardratecurve

Examples of com.opengamma.analytics.financial.credit.hazardratecurve.HazardRateCurve


    final ZonedDateTime now = DateUtils.getUTCDate(2013, 1, 1);
    final ZonedDateTime[] dates = new ZonedDateTime[] {now, now.plusMonths(3), now.plusMonths(6), now.plusMonths(9), now.plusMonths(12)};
    final double[] times = new double[] {0, .25, .5, .75, 1};
    final double[] rates = new double[] {0.01, 0.02, 0.03, 0.04, 0.05};
    final double offset = 1. / 360;
    final HazardRateCurve curve = new HazardRateCurve(dates, times, rates, offset);
    assertEquals(curve, cycleObject(HazardRateCurve.class, curve));
  }
View Full Code Here


    DEPRECATED_CALCULATOR.isdaCalibrateHazardRateCurve(VALUATION_DATE, CDS, MARKET_TENORS, null, YIELD_CURVE);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testNullYieldCurve() {
    final HazardRateCurve result = DEPRECATED_CALCULATOR.isdaCalibrateHazardRateCurve(VALUATION_DATE, CDS, MARKET_TENORS, MARKET_SPREADS, null);
    assertNotNull(result);
  }
View Full Code Here

   * Tests trivial example in which there is no credit risk, i.e. par spreads for all CDS are zero
   */
  @Test
  public void testCalibrationToZeroSpreadsSucceeds() {

    final HazardRateCurve result = DEPRECATED_CALCULATOR.isdaCalibrateHazardRateCurve(VALUATION_DATE, CDS, MARKET_TENORS, ZERO_SPREADS, YIELD_CURVE);
    assertNotNull(result);
  }
View Full Code Here

   * Tests trivial example in which there is no credit risk, i.e. par spreads for all CDS are zero,
   * and thus zero hazard rates for all tenors.
   */
  @Test
  public void testRegressionOnZeroSpreads() {
    final HazardRateCurve curve = DEPRECATED_CALCULATOR.isdaCalibrateHazardRateCurve(VALUATION_DATE, CDS, MARKET_TENORS, ZERO_SPREADS, YIELD_CURVE);
    final HazardRateCurve curveExpected = new HazardRateCurve(MARKET_TENORS, MARKET_TIMES, ZERO_HAZARD_RATES, 0);
    assertTrue("Calibrated hazard rates have changed.", Arrays.equals(curve.getRates(), curveExpected.getRates()));
    assertTrue("Calibrated hazard times have changed.", Arrays.equals(curve.getTimes(), curveExpected.getTimes()));
    assertTrue("Calibrated ZeroDiscountFactor has changed.", curve.getZeroDiscountFactor() == curveExpected.getZeroDiscountFactor());
    assertTrue("Calibrated hazard rate curve has changed.", curve.equals(curveExpected));
  }
View Full Code Here

   * This regression test fails because CalibrateHazardRateTermStructureISDAMethod fails to calibrate to market spreads.
   * As of writing this, 16/06/2013, it fails on the first point. See {@link ISDAHazardRateCurveCalculatorTest}
   */
  @Test(expectedExceptions = OpenGammaRuntimeException.class)
  public void testCalibrationToRealisticSpreadsSucceeds() {
    final HazardRateCurve result = DEPRECATED_CALCULATOR.isdaCalibrateHazardRateCurve(VALUATION_DATE, CDS, MARKET_TENORS, MARKET_SPREADS, YIELD_CURVE);
    assertNotNull(result);
  }
View Full Code Here

    hazTimes = new double[n];
    for (int i = 0; i < n; i++) {
      hazTimes[i] = ACT.getDayCountFraction(baseDate, hazDates[i]);
    }
    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));
View Full Code Here

  @Test
  /**
   * Regression test to highlight any changes made to the calibrator
   */
  public void testRegression() {
    final HazardRateCurve curve = CALCULATOR.calibrateHazardRateCurve(CDS, CURVES_DATA, VALUATION_DATE);
    final HazardRateCurve curveExpected = new HazardRateCurve(MARKET_TENORS, MARKET_TIMES, HAZARD_RATES, 0);
    assertTrue("Calibrated hazard rates have changed.", Arrays.equals(curve.getRates(), curveExpected.getRates()));
    assertTrue("Calibrated hazard times have changed.", Arrays.equals(curve.getTimes(), curveExpected.getTimes()));
    assertTrue("Calibrated ZeroDiscountFactor has changed.", curve.getZeroDiscountFactor() == curveExpected.getZeroDiscountFactor());
    assertTrue("Calibrated hazard rate curve has changed.", curve.equals(curveExpected));
  }
View Full Code Here

   * This regression test fails because CalibrateHazardRateTermStructureISDAMethod fails to calibrate to market spreads.
   * As of writing this, 16/06/2013, it fails on the first point. See {@link CalibrateHazardRateTermStructureISDAMethodTest}
   */
  @Test(expectedExceptions = OpenGammaRuntimeException.class)
  public void testDeprecated() {
    final HazardRateCurve curve1 = CALCULATOR.calibrateHazardRateCurve(CDS, CURVES_DATA, VALUATION_DATE);
    final HazardRateCurve curve2 = DEPRECATED_CALCULATOR.isdaCalibrateHazardRateCurve(VALUATION_DATE, CDS, MARKET_TENORS, MARKET_SPREADS, YIELD_CURVE);
    assertEquals(curve1, curve2);
  }
View Full Code Here

      times[m] = ACT_365.getDayCountFraction(valuationDate, marketTenors[m]);
    }
    final double[] calibratedHazardRates = HAZARD_RATE_CALCULATOR.getCalibratedHazardRateTermStructure(valuationDate, cds, marketTenors,
        marketSpreads, yieldCurve, priceType);
    final double bumpedRecoveryRate = getBumpedRecoveryRate(cds, recoveryRateBump, recoveryRateBumpType);
    final HazardRateCurve calibratedHazardRateCurve = new HazardRateCurve(marketTenors, times, calibratedHazardRates, 0.0);
    final CreditDefaultSwapDefinition bumpedCDS = cds.withRecoveryRate(bumpedRecoveryRate);
    final ISDAYieldCurveAndHazardRateCurveProvider curves = new ISDAYieldCurveAndHazardRateCurveProvider(yieldCurve, calibratedHazardRateCurve);
    final double presentValue = CALCULATOR.getPresentValue(cds, curves, valuationDate, priceType);
    final double bumpedPresentValue = CALCULATOR.getPresentValue(bumpedCDS, curves, valuationDate, priceType);
    return bumpedPresentValue - presentValue;
View Full Code Here

    ArgumentChecker.notNegative(spreadBump, "Spread bump");
    DATA_CHECKER.checkSpreadData(valuationDate, marketTenors, marketSpreads);
    final int nSpreads = marketSpreads.length;
    final double[] bucketedCS01 = new double[nSpreads];
    ISDAYieldCurveAndSpreadsProvider calibrationData = new ISDAYieldCurveAndSpreadsProvider(marketTenors, marketSpreads, yieldCurve);
    HazardRateCurve hazardRateCurve = HAZARD_RATE_CALCULATOR.calibrateHazardRateCurve(cds, calibrationData, valuationDate);
    ISDAYieldCurveAndHazardRateCurveProvider curveProvider = new ISDAYieldCurveAndHazardRateCurveProvider(yieldCurve, hazardRateCurve);
    final double presentValue = PV_CALCULATOR.getPresentValue(cds, curveProvider, valuationDate, priceType);
    // Loop through and bump each of the spreads at each tenor
    for (int m = 0; m < nSpreads; m++) {
      // Calculate the bumped spreads vector
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.credit.hazardratecurve.HazardRateCurve

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.