Package com.opengamma.analytics.financial.credit.creditdefaultswapoption.definition

Examples of com.opengamma.analytics.financial.credit.creditdefaultswapoption.definition.CreditDefaultSwapOptionDefinition


    final FinancialSecurity underlyingSecurity = (FinancialSecurity) _securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId())); //TODO version correction
    final CreditDefaultSwapDefinition underlyingCDS = underlyingSecurity.accept(_underlyingConverter);
    //    underlyingCDS = underlyingCDS.withMaturityDate(maturityDate.plusYears(10));
    //    underlyingCDS = underlyingCDS.withEffectiveDate(maturityDate.plusDays(1));
    //    underlyingCDS = underlyingCDS.withStartDate(maturityDate);
    return new CreditDefaultSwapOptionDefinition(buySellProtection, protectionBuyer, protectionSeller, currency, startDate, maturityDate, notional, strike,
        isKnockOut, isPayer, optionExerciseType, underlyingCDS);
  }
View Full Code Here


    // Compute the bumped recovery rate
    final double bumpedRecoveryRate = getBumpedRecoveryRate(cdsSwaption, recoveryRateBump, recoveryRateBumpType);

    // Create a copy of the input CDS Swaption where the underlying CDS has the bumped recovery rate
    final CreditDefaultSwapOptionDefinition bumpedCDSSwaption = cdsSwaption.withRecoveryRate(bumpedRecoveryRate);

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

    // Create a CDS Swaption PV calculator
    final PresentValueCreditDefaultSwapOption creditDefaultSwapOption = new PresentValueCreditDefaultSwapOption();
View Full Code Here

    final RegionSource regionSource = OpenGammaExecutionContext.getRegionSource(executionContext);
    final OrganizationSource organizationSource = OpenGammaExecutionContext.getOrganizationSource(executionContext);
    final SecuritySource securitySource = OpenGammaExecutionContext.getSecuritySource(executionContext);
    final CreditDefaultSwapOptionSecurityConverter converter = new CreditDefaultSwapOptionSecurityConverter(securitySource, holidaySource, regionSource, organizationSource);
    final CreditDefaultSwapOptionSecurity security = (CreditDefaultSwapOptionSecurity) target.getSecurity();
    final CreditDefaultSwapOptionDefinition cdsOption = security.accept(converter);
    final Object yieldCurveObject = inputs.getValue(ValueRequirementNames.YIELD_CURVE);
    if (yieldCurveObject == null) {
      throw new OpenGammaRuntimeException("Could not get yield curve");
    }
    final Object spreadCurveObject = inputs.getValue(ValueRequirementNames.CREDIT_SPREAD_CURVE);
    if (spreadCurveObject == null) {
      throw new OpenGammaRuntimeException("Could not get credit spread curve");
    }
    final ISDADateCurve yieldCurve = (ISDADateCurve) yieldCurveObject;
    final NodalObjectsCurve<?, ?> spreadCurve = (NodalObjectsCurve<?, ?>) spreadCurveObject;
    final Tenor[] tenors = CreditFunctionUtils.getTenors(spreadCurve.getXData());
    final Double[] marketSpreadObjects = CreditFunctionUtils.getSpreads(spreadCurve.getYData());
    ParallelArrayBinarySort.parallelBinarySort(tenors, marketSpreadObjects);
    final int n = tenors.length;
    final List<ZonedDateTime> calibrationTimes = new ArrayList<>();
    final DoubleArrayList marketSpreads = new DoubleArrayList();
    for (int i = 0; i < n; i++) {
      final ZonedDateTime nextIMMDate = IMMDateGenerator.getNextIMMDate(valuationTime, tenors[i]).withHour(0).withMinute(0).withSecond(0).withNano(0);
      if (nextIMMDate.isAfter(cdsOption.getOptionExerciseDate())) {
        calibrationTimes.add(IMMDateGenerator.getNextIMMDate(valuationTime, tenors[i]).withHour(0).withMinute(0).withSecond(0).withNano(0));
        marketSpreads.add(marketSpreadObjects[i]);
      }
    }
    if (calibrationTimes.size() < 2) {
      throw new OpenGammaRuntimeException("Need at least two credit spread points for pricing");
    }
    final ValueProperties properties = Iterables.getOnlyElement(desiredValues).getConstraints().copy()
        .with(ValuePropertyNames.FUNCTION, getUniqueId())
        .get();
    final ISDAYieldCurveAndSpreadsProvider data = new ISDAYieldCurveAndSpreadsProvider(calibrationTimes.toArray(new ZonedDateTime[calibrationTimes.size()]),
        marketSpreads.toDoubleArray(), yieldCurve);
    final HazardRateCurve curve = CALCULATOR.calibrateHazardRateCurve(cdsOption.getUnderlyingCDS(), data, valuationTime);
    final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.HAZARD_RATE_CURVE, target.toSpecification(), properties);
    return Collections.singleton(new ComputedValue(spec, curve));
  }
View Full Code Here

    final Object recoveryRateObject = inputs.getValue(new ValueRequirement("PX_LAST", ComputationTargetType.PRIMITIVE, recoveryRateIdentifier.getExternalId()));
    if (recoveryRateObject == null) {
      throw new OpenGammaRuntimeException("Could not get recovery rate");
    }
    final double recoveryRate = (Double) recoveryRateObject;
    CreditDefaultSwapOptionDefinition definition = security.accept(converter);
    definition = definition.withRecoveryRate(recoveryRate);
    final Object yieldCurveObject = inputs.getValue(ValueRequirementNames.YIELD_CURVE);
    if (yieldCurveObject == null) {
      throw new OpenGammaRuntimeException("Could not get yield curve");
    }
    final Object spreadCurveObject = inputs.getValue(ValueRequirementNames.CREDIT_SPREAD_CURVE);
    if (spreadCurveObject == null) {
      throw new OpenGammaRuntimeException("Could not get credit spread curve");
    }
    final Object hazardRateCurveObject = inputs.getValue(ValueRequirementNames.HAZARD_RATE_CURVE);
    if (hazardRateCurveObject == null) {
      throw new OpenGammaRuntimeException("Could not get hazard rate curve");
    }
    final ISDADateCurve yieldCurve = (ISDADateCurve) yieldCurveObject;
    final double volatility = 0.3; //TODO
    final HazardRateCurve hazardRateCurve = (HazardRateCurve) hazardRateCurveObject;
    final NodalObjectsCurve<?, ?> spreadCurve = (NodalObjectsCurve<?, ?>) spreadCurveObject;
    final Tenor[] tenors = CreditFunctionUtils.getTenors(spreadCurve.getXData());
    final Double[] marketSpreadObjects = CreditFunctionUtils.getSpreads(spreadCurve.getYData());
    ParallelArrayBinarySort.parallelBinarySort(tenors, marketSpreadObjects);
    final int n = tenors.length;
    final List<ZonedDateTime> calibrationTimes = new ArrayList<>();
    final DoubleArrayList marketSpreads = new DoubleArrayList();
    for (int i = 0; i < n; i++) {
      final ZonedDateTime nextIMMDate = IMMDateGenerator.getNextIMMDate(valuationTime, tenors[i]).withHour(0).withMinute(0).withSecond(0).withNano(0);
      if (nextIMMDate.isAfter(definition.getOptionExerciseDate())) {
        calibrationTimes.add(IMMDateGenerator.getNextIMMDate(valuationTime, tenors[i]).withHour(0).withMinute(0).withSecond(0).withNano(0));
        marketSpreads.add(marketSpreadObjects[i]);
      }
    }
    if (calibrationTimes.size() < 2) {
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.credit.creditdefaultswapoption.definition.CreditDefaultSwapOptionDefinition

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.