Package com.opengamma.financial.analytics.forwardcurve

Examples of com.opengamma.financial.analytics.forwardcurve.ForwardSwapCurveSpecification


  @Override
  public ForwardSwapCurveSpecification buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
    final Currency target = deserializer.fieldValueToObject(Currency.class, message.getByName(TARGET_FIELD));
    final String name = message.getString(NAME_FIELD);
    final ForwardSwapCurveInstrumentProvider provider = deserializer.fieldValueToObject(ForwardSwapCurveInstrumentProvider.class, message.getByName(INSTRUMENT_PROVIDER_FIELD));
    return new ForwardSwapCurveSpecification(name, target, provider);
  }
View Full Code Here


        final Currency currency = target.getValue(PrimitiveComputationTargetType.CURRENCY);
        final ForwardSwapCurveDefinition definition = curveDefinitionSource.getDefinition(curveName, currency.toString());
        if (definition == null) {
          throw new OpenGammaRuntimeException("Couldn't find a forward swap curve definition called " + curveName + " for target " + target);
        }
        final ForwardSwapCurveSpecification specification = curveSpecificationSource.getSpecification(curveName, currency.toString());
        if (specification == null) {
          throw new OpenGammaRuntimeException("Couldn't find a forward swap curve specification called " + curveName + " for target " + target);
        }
        final ForwardSwapCurveInstrumentProvider provider = (ForwardSwapCurveInstrumentProvider) specification.getCurveInstrumentProvider();
        final Object dataObject = inputs.getValue(ValueRequirementNames.FORWARD_SWAP_CURVE_MARKET_DATA);
        if (dataObject == null) {
          throw new OpenGammaRuntimeException("Could not get market data");
        }
        @SuppressWarnings("unchecked")
View Full Code Here

        final String forwardTenorName = forwardTenorNames.iterator().next();
        final ForwardSwapCurveDefinition definition = curveDefinitionSource.getDefinition(curveName, currency.toString());
        if (definition == null) {
          throw new OpenGammaRuntimeException("Couldn't find a forward swap curve definition called " + curveName + " with target " + target);
        }
        final ForwardSwapCurveSpecification specification = curveSpecificationSource.getSpecification(curveName, currency.toString());
        if (specification == null) {
          throw new OpenGammaRuntimeException("Couldn't find a forward swap curve specification called " + curveName + " with target " + target);
        }
        final Set<ValueRequirement> requirements = new HashSet<ValueRequirement>();
        final ForwardSwapCurveInstrumentProvider provider = (ForwardSwapCurveInstrumentProvider) specification.getCurveInstrumentProvider();
        final Tenor forwardTenor = Tenor.of(Period.parse(forwardTenorName));
        for (final Tenor tenor : definition.getTenors()) {
          final ExternalId identifier = provider.getInstrument(atZDT.toLocalDate(), tenor, forwardTenor);
          requirements.add(new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, identifier));
        }
        requirements.add(new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, provider.getSpotInstrument(forwardTenor)));
        return requirements;
      }

      @Override
      public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
        final Clock snapshotClock = executionContext.getValuationClock();
        final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
        final ValueRequirement desiredValue = desiredValues.iterator().next();
        final String curveName = desiredValue.getConstraint(ValuePropertyNames.CURVE);
        final String forwardTenorName = desiredValue.getConstraint(PROPERTY_FORWARD_TENOR);
        final Currency currencyPair = target.getValue(PrimitiveComputationTargetType.CURRENCY);
        final ForwardSwapCurveDefinition definition = curveDefinitionSource.getDefinition(curveName, currencyPair.toString());
        if (definition == null) {
          throw new OpenGammaRuntimeException("Couldn't find a forward swap curve definition called " + curveName + " for target " + target);
        }
        final ForwardSwapCurveSpecification specification = curveSpecificationSource.getSpecification(curveName, currencyPair.toString());
        if (specification == null) {
          throw new OpenGammaRuntimeException("Couldn't find FX forward curve specification called " + curveName + " for target " + target);
        }
        final ForwardSwapCurveInstrumentProvider provider = (ForwardSwapCurveInstrumentProvider) specification.getCurveInstrumentProvider();
        final Tenor forwardTenor = Tenor.of(Period.parse(forwardTenorName));
        final ValueRequirement spotRequirement = new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, provider.getSpotInstrument(forwardTenor));
        if (inputs.getValue(spotRequirement) == null) {
          throw new OpenGammaRuntimeException("Could not get value for spot; requirement was " + spotRequirement);
        }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.forwardcurve.ForwardSwapCurveSpecification

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.