Examples of CurveSpecification


Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
    final DoubleLabelledMatrix1D sensitivities = ((DoubleLabelledMatrix1D) inputs.getValue(YIELD_CURVE_NODE_SENSITIVITIES));
    final String currency = inputs.getComputedValue(YIELD_CURVE_NODE_SENSITIVITIES).getSpecification().getProperty(CURRENCY);
    final double[] ycns = sensitivities.getValues();
    final Object[] labels = sensitivities.getLabels();
    final CurveSpecification curveSpec = (CurveSpecification) inputs.getValue(CURVE_SPECIFICATION);
    final int n = ycns.length;
    if (n != curveSpec.getNodes().size()) {
      throw new OpenGammaRuntimeException("Do not have a sensitivity for each node");
    }
    final Tenor[] tenors = new Tenor[n];
    final LocalDateDoubleTimeSeries[] returnSeries = new LocalDateDoubleTimeSeries[n];
    final HistoricalTimeSeriesBundle tsBundle = (HistoricalTimeSeriesBundle) inputs.getValue(CURVE_HISTORICAL_TIME_SERIES);
    final Iterator<CurveNodeWithIdentifier> iterator = curveSpec.getNodes().iterator();
    for (int i = 0; i < n; i++) {
      final double sensitivity = ycns[i];
      final CurveNodeWithIdentifier curveNode = iterator.next();
      final HistoricalTimeSeries ts = tsBundle.get(curveNode.getDataField(), curveNode.getIdentifier());
      if (ts == null) {
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
    final DoubleLabelledMatrix1D sensitivities = ((DoubleLabelledMatrix1D) inputs.getValue(FX_FORWARD_POINTS_NODE_SENSITIVITIES));
    final String currency = inputs.getComputedValue(FX_FORWARD_POINTS_NODE_SENSITIVITIES).getSpecification().getProperty(CURRENCY);
    final double[] fcns = sensitivities.getValues();
    final Object[] labels = sensitivities.getLabels();
    final CurveSpecification curveSpec = (CurveSpecification) inputs.getValue(CURVE_SPECIFICATION);
    final int n = fcns.length;
    if (n != curveSpec.getNodes().size()) {
      throw new OpenGammaRuntimeException("Do not have a sensitivity for each node");
    }
    final Tenor[] tenors = new Tenor[n];
    final LocalDateDoubleTimeSeries[] returnSeries = new LocalDateDoubleTimeSeries[n];
    final HistoricalTimeSeriesBundle tsBundle = (HistoricalTimeSeriesBundle) inputs.getValue(CURVE_HISTORICAL_TIME_SERIES);
    final Iterator<CurveNodeWithIdentifier> iterator = curveSpec.getNodes().iterator();
    for (int i = 0; i < n; i++) {
      final double sensitivity = fcns[i];
      final CurveNodeWithIdentifier curveNode = iterator.next();
      final HistoricalTimeSeries ts = tsBundle.get(curveNode.getDataField(), curveNode.getIdentifier());
      if (ts == null) {
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

        for (final Map.Entry<String, List<CurveTypeConfiguration>> entry : group.getTypesForCurves().entrySet()) {
          final List<IborIndex> iborIndex = new ArrayList<>();
          final List<IndexON> overnightIndex = new ArrayList<>();
          final String curveName = entry.getKey();
          final ValueProperties properties = ValueProperties.builder().with(CURVE, curveName).get();
          final CurveSpecification specification =
              (CurveSpecification) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_SPECIFICATION, ComputationTargetSpecification.NULL, properties));
          final CurveDefinition definition =
              (CurveDefinition) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_DEFINITION, ComputationTargetSpecification.NULL, properties));
          final SnapshotDataBundle snapshot =
              (SnapshotDataBundle) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_MARKET_DATA, ComputationTargetSpecification.NULL, properties));
          final int nNodes = specification.getNodes().size();
          final InstrumentDerivative[] derivativesForCurve = new InstrumentDerivative[nNodes];
          final double[] parameterGuessForCurves = new double[nNodes];
          int k = 0;
          for (final CurveNodeWithIdentifier node : specification.getNodes()) { // Node points - start
            final Double marketData = snapshot.getDataPoint(node.getIdentifier());
            if (marketData == null) {
              throw new OpenGammaRuntimeException("Could not get market data for " + node.getIdentifier());
            }
            parameterGuessForCurves[k] = 0.02; // For FX forward, the FX rate is not a good initial guess. // TODO: change this // marketData
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final Object curveSpecObject = inputs.getValue(curveSpecRequirement);
    if (curveSpecObject == null) {
      throw new OpenGammaRuntimeException("Could not get " + curveSpecRequirement);
    }
    if (curveCalculationMethod.equals(InterpolatedDataProperties.CALCULATION_METHOD_NAME)) {
      final CurveSpecification curveSpec = (CurveSpecification) curveSpecObject;
      return YieldCurveNodeSensitivitiesHelper.getInstrumentLabelledSensitivitiesForCurve(curveName + "_" + currency.getCode(), curves, sensitivities, curveSpec, resultSpec);
    }
    final InterpolatedYieldCurveSpecificationWithSecurities curveSpec = (InterpolatedYieldCurveSpecificationWithSecurities) curveSpecObject;
    return YieldCurveNodeSensitivitiesHelper.getInstrumentLabelledSensitivitiesForCurve(curveName + "_" + currency.getCode(), curves, sensitivities, curveSpec, resultSpec);
  }
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final Object curveSpecObject = inputs.getValue(curveSpecRequirement);
    if (curveSpecObject == null) {
      throw new OpenGammaRuntimeException("Could not get " + curveSpecRequirement);
    }
    if (curveCalculationMethod.equals(InterpolatedDataProperties.CALCULATION_METHOD_NAME)) {
      final CurveSpecification curveSpec = (CurveSpecification) curveSpecObject;
      return YieldCurveNodeSensitivitiesHelper.getInstrumentLabelledSensitivitiesForCurve(curveName + "_" + currency.getCode(), curves, scaledSensitivities, curveSpec, resultSpec);
    }
    final InterpolatedYieldCurveSpecificationWithSecurities curveSpec = (InterpolatedYieldCurveSpecificationWithSecurities) curveSpecObject;
    return YieldCurveNodeSensitivitiesHelper.getInstrumentLabelledSensitivitiesForCurve(curveName + "_" + currency.getCode(), curves, scaledSensitivities, curveSpec, resultSpec);
  }
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

        for (final Map.Entry<String, List<CurveTypeConfiguration>> entry : group.getTypesForCurves().entrySet()) {
          final List<IborIndex> iborIndex = new ArrayList<>();
          final List<IndexON> overnightIndex = new ArrayList<>();
          final String curveName = entry.getKey();
          final ValueProperties properties = ValueProperties.builder().with(CURVE, curveName).get();
          final CurveSpecification specification =
              (CurveSpecification) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_SPECIFICATION, ComputationTargetSpecification.NULL, properties));
          final CurveDefinition definition =
              (CurveDefinition) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_DEFINITION, ComputationTargetSpecification.NULL, properties));
          final SnapshotDataBundle snapshot =
              (SnapshotDataBundle) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_MARKET_DATA, ComputationTargetSpecification.NULL, properties));
          final int nNodes = specification.getNodes().size();
          final InstrumentDerivative[] derivativesForCurve = new InstrumentDerivative[nNodes];
          final double[] parameterGuessForCurves = new double[nNodes];
          int k = 0;
          for (final CurveNodeWithIdentifier node : specification.getNodes()) { // Node points - start
            final Double marketData = snapshot.getDataPoint(node.getIdentifier());
            if (marketData == null) {
              throw new OpenGammaRuntimeException("Could not get market data for " + node.getIdentifier());
            }
            parameterGuessForCurves[k] = 0.02; // For FX forward, the FX rate is not a good initial guess. // TODO: change this // marketData
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

      @PathParam("valuationTime") String valuationTimeStr,
      @PathParam("date") String curveDateStr,
      CurveDefinition definition) {
    final Instant valuationTime = Instant.parse(valuationTimeStr);
    final LocalDate curveDate = LocalDate.parse(curveDateStr);
    CurveSpecification result = getCurveSpecificationBuilder().buildCurve(valuationTime, curveDate, definition);
    return responseOkFudge(result);
  }
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

      public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
          final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
        final ZonedDateTime now = ZonedDateTime.now(executionContext.getValuationClock());
        final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
        //TODO
        CurveSpecification curveSpecification;
        final ConfigSource configSource = OpenGammaExecutionContext.getConfigSource(executionContext);
        final String idName = desiredValue.getConstraint(ValuePropertyNames.CURVE);
        String curveName;
        try {
          curveName = "SAMEDAY_" + idName;
          curveSpecification = CurveUtils.getCurveSpecification(now.toInstant(), configSource, now.toLocalDate(), curveName);
        } catch (final Exception e) {
          curveName = idName;
          curveSpecification = CurveUtils.getCurveSpecification(now.toInstant(), configSource, now.toLocalDate(), idName);
        }

        final List<Tenor> tenors = new ArrayList<>();
        final List<Double> marketSpreads = new ArrayList<>();
        for (final CurveNodeWithIdentifier strip : curveSpecification.getNodes()) {
          final Object marketSpreadObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, strip.getIdentifier()));
          if (marketSpreadObject != null) {
            tenors.add(strip.getCurveNode().getResolvedMaturity());
            marketSpreads.add(10000 * (Double) marketSpreadObject);
          } else {
            s_logger.warn("Could not get spread data for {}, defaulting", strip.getIdentifier());
            tenors.add(strip.getCurveNode().getResolvedMaturity());
            if (!marketSpreads.isEmpty()) {
              //TODO: Find out why some tails are missing - for now set flat spread
              marketSpreads.add(marketSpreads.get(marketSpreads.size() - 1));
            } else {
              marketSpreads.add(105.0);
              //throw new OpenGammaRuntimeException("Couldnt get spreads for " + strip.getIdentifier());
            }
          }
        }
        if (tenors.size() == 0) {
          throw new OpenGammaRuntimeException("Could not get any credit spread data for curve called " + curveName);
        }
        final NodalObjectsCurve<Tenor, Double> curve = NodalObjectsCurve.from(tenors, marketSpreads);
        final ValueProperties properties = createValueProperties()
            .with(ValuePropertyNames.CURVE, idName)
            .get();
        final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.CREDIT_SPREAD_CURVE, target.toSpecification(), properties);
        return Collections.singleton(new ComputedValue(spec, curve));
      }

      @Override
      public ComputationTargetType getTargetType() {
        return ComputationTargetType.NULL;
      }

      @Override
      public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target) {
        @SuppressWarnings("synthetic-access")
        final ValueProperties properties = createValueProperties()
        .withAny(ValuePropertyNames.CURVE)
        .get();
        return Collections.singleton(new ValueSpecification(ValueRequirementNames.CREDIT_SPREAD_CURVE, target.toSpecification(), properties));
      }

      @Override
      public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {
        final ValueProperties constraints = desiredValue.getConstraints();
        final Set<String> curveNames = constraints.getValues(ValuePropertyNames.CURVE);
        if (curveNames == null || curveNames.size() != 1) {
          return null;
        }
        //TODO
        String curveName = "SAMEDAY_" + Iterables.getOnlyElement(curveNames);
        final Set<ValueRequirement> requirements = new HashSet<>();
        final ConfigSource configSource = OpenGammaCompilationContext.getConfigSource(context);
        try {
          final CurveSpecification specification = CurveUtils.getCurveSpecification(atInstant, configSource, atZDT.toLocalDate(), curveName);
          for (final CurveNodeWithIdentifier strip : specification.getNodes()) {
            if (strip.getCurveNode() instanceof CreditSpreadNode) {
              requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, strip.getIdentifier()));
            }
          }
          return requirements;
        } catch (final Exception e) {
          s_logger.error(e.getMessage());
          //TODO backwards compatibility - remove when upstream functions select the correct prefix
          curveName = Iterables.getOnlyElement(curveNames);
          try {
            final CurveSpecification specification = CurveUtils.getCurveSpecification(atInstant, configSource, atZDT.toLocalDate(), curveName);
            for (final CurveNodeWithIdentifier strip : specification.getNodes()) {
              if (strip.getCurveNode() instanceof CreditSpreadNode) {
                requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, strip.getIdentifier()));
              }
            }
            return requirements;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.