Package com.opengamma.financial.security.cds

Examples of com.opengamma.financial.security.cds.CDSSecurity


    ZonedDateTime maturity = LocalDateTime.of(2020, 12, 20, 0, 0, 0, 0).atZone(ZoneOffset.UTC);
    ZonedDateTime startDate = LocalDateTime.of(2010, 12, 20, 0, 0, 0, 0).atZone(ZoneOffset.UTC);
    SimpleFrequency frequency = SimpleFrequency.ANNUAL;
    DayCount dayCount = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    BusinessDayConvention businessDayConvention = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
    final CDSSecurity cds1 = new CDSSecurity(1.0, 0.6, 0.4, Currency.USD, maturity, startDate,
                                             frequency,
                                             dayCount,
                                             businessDayConvention, 
                                             StubType.SHORT_START, 3,
                                             "US Treasury", Currency.USD, "Senior", "No Restructuring");
    cds1.addExternalId(ExternalId.of(ExternalSchemes.OG_SYNTHETIC_TICKER, "TEST_CDS_00001--US912828KY53-A"));
    cds1.setName("TEST CDS" + _counter++);
   
    return cds1;
  }
View Full Code Here


  }

  @Override
  public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {

    final CDSSecurity cds = (CDSSecurity) target.getSecurity();

    final Set<ValueRequirement> requirements = new HashSet<>();

    requirements.add(new ValueRequirement(ValueRequirementNames.YIELD_CURVE, ComputationTargetSpecification.of(cds.getCurrency()), ValueProperties.with(ValuePropertyNames.CALCULATION_METHOD,
        ISDAFunctionConstants.ISDA_METHOD_NAME).get()));

    // TODO: Are extra value properties needed here? (see ISDAApproxFlatSpreadFunction)
    requirements.add(new ValueRequirement(ValueRequirementNames.SPOT_RATE, target.toSpecification(), ValueProperties.none()));
View Full Code Here

    // Set up converter (could this be compiled?)
    final HolidaySource holidaySource = OpenGammaExecutionContext.getHolidaySource(executionContext);
    final ISDACDSSecurityConverter converter = new ISDACDSSecurityConverter(holidaySource);

    // Security being priced
    final CDSSecurity cds = (CDSSecurity) target.getSecurity();
    final ISDACDSDefinition cdsDefinition = (ISDACDSDefinition) cds.accept(converter);

    // Time point to price for
    // TODO: Supply an option for the user to specify non-standard step-in and settlement dates
    final ZonedDateTime pricingDate = ZonedDateTime.now(executionContext.getValuationClock());
    final ZonedDateTime stepinDate = pricingDate.plusDays(1);
View Full Code Here

        .with(ValuePropertyNames.CURRENCY, security.getCurrency().getCode());
  }

  @Override
  public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target) {
    final CDSSecurity cds = (CDSSecurity) target.getSecurity();
    final ValueProperties properties = createValueProperties(cds).get();
    final ComputationTargetSpecification targetSpec = target.toSpecification();
    final ValueSpecification cleanPriceSpec = new ValueSpecification(ValueRequirementNames.CLEAN_PRICE, targetSpec, properties);
    final ValueSpecification dirtyPriceSpec = new ValueSpecification(ValueRequirementNames.DIRTY_PRICE, targetSpec, properties);
    final ValueSpecification presentValueSpec = new ValueSpecification(ValueRequirementNames.PRESENT_VALUE, targetSpec, properties);
View Full Code Here

  }

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {

    final CDSSecurity cds = (CDSSecurity) target.getSecurity();
    final ComputationTargetSpecification targetSpec = target.toSpecification();
    final ValueProperties properties = createValueProperties(cds).get();

    final DoublesPair calculationResult = executeImpl(executionContext, inputs, target, desiredValues);
    final Double cleanPrice = calculationResult.getFirst();
View Full Code Here

  @Override
  public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {
    if (canApplyTo(context, target)) {

      final CDSSecurity cds = (CDSSecurity) target.getSecurity();

      final Set<ValueRequirement> requirements = new HashSet<ValueRequirement>();

      requirements.add(new ValueRequirement(
        ValueRequirementNames.YIELD_CURVE,
          ComputationTargetSpecification.of(cds.getCurrency()),
        ValueProperties
          .with(ValuePropertyNames.CALCULATION_METHOD, ISDAFunctionConstants.ISDA_METHOD_NAME)
          .get()));

      requirements.add(new ValueRequirement(
        ValueRequirementNames.YIELD_CURVE,
          ComputationTargetSpecification.of(cds.getCurrency()),
        ValueProperties
          .with(ValuePropertyNames.CURVE, "HAZARD_" + cds.getUnderlyingIssuer() + "_" + cds.getUnderlyingSeniority() + "_" + cds.getRestructuringClause())
          .with(ValuePropertyNames.CALCULATION_METHOD, ISDAFunctionConstants.ISDA_METHOD_NAME)
          .get()));

      return requirements;
    }
View Full Code Here

    // Set up converter (could this be compiled?)
    final HolidaySource holidaySource = OpenGammaExecutionContext.getHolidaySource(executionContext);
    final ISDACDSSecurityConverter converter = new ISDACDSSecurityConverter(holidaySource);

    // Security being priced
    final CDSSecurity cds = (CDSSecurity) target.getSecurity();
    final ISDACDSDefinition cdsDefinition = (ISDACDSDefinition) cds.accept(converter);

    // Time point to price for
    // TODO: Supply an option for the user to specify non-standard step-in and settlement dates
    final ZonedDateTime pricingDate = ZonedDateTime.now(executionContext.getValuationClock());
    final ZonedDateTime stepinDate = pricingDate.plusDays(1);
    final ZonedDateTime settlementDate = findSettlementDate(pricingDate, cdsDefinition.getConvention());

    // Discount curve
    final ISDACurve discountCurve = (ISDACurve) inputs.getValue(new ValueRequirement(
        ValueRequirementNames.YIELD_CURVE, ComputationTargetSpecification.of(cds.getCurrency()),
      ValueProperties.with(ValuePropertyNames.CALCULATION_METHOD, ISDAFunctionConstants.ISDA_METHOD_NAME).get()));

    // Hazard rate curve
    final ISDACurve hazardRateCurve = (ISDACurve) inputs.getValue(new ValueRequirement(
        ValueRequirementNames.YIELD_CURVE, ComputationTargetSpecification.of(cds.getCurrency()),
      ValueProperties
        .with(ValuePropertyNames.CURVE, "HAZARD_" + cds.getUnderlyingIssuer() + "_" + cds.getUnderlyingSeniority() + "_" + cds.getRestructuringClause())
        .with(ValuePropertyNames.CALCULATION_METHOD, ISDAFunctionConstants.ISDA_METHOD_NAME)
        .get()));

    // Convert security in to format suitable for pricing
    final ISDACDSDerivative cdsDerivative = cdsDefinition.toDerivative(pricingDate, stepinDate, settlementDate, discountCurve.getName(), hazardRateCurve.getName());
View Full Code Here

    return bean;
  }

  @Override
  public CDSSecurity createSecurity(OperationContext context, CDSSecurityBean bean) {
    return new CDSSecurity(
      bean.getNotional(),
      bean.getRecoveryRate(),
      bean.getSpread(),
      currencyBeanToCurrency(bean.getCurrency()),
      zonedDateTimeBeanToDateTimeWithZone(bean.getMaturity()),
View Full Code Here

TOP

Related Classes of com.opengamma.financial.security.cds.CDSSecurity

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.