Package com.opengamma.financial.analytics.curve

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


        resolvedStrips.add(deserializer.fieldValueToObject(CurveNodeWithIdentifier.class, resolvedStripField));
      }
      final String interpolatorName = message.getString(INTERPOLATOR_NAME_FIELD);
      final String rightExtrapolatorName = message.getString(RIGHT_EXTRAPOLATOR_NAME_FIELD);
      final String leftExtrapolatorName = message.getString(LEFT_EXTRAPOLATOR_NAME_FIELD);
      return new InterpolatedCurveSpecification(curveDate, name, resolvedStrips, interpolatorName, rightExtrapolatorName, leftExtrapolatorName);
    }
View Full Code Here


    assertEquals(specification, cycleObject(CurveSpecification.class, specification));
  }

  @Test
  public void testInterpolatedCurveSpecification() {
    final InterpolatedCurveSpecification specification = new InterpolatedCurveSpecification(LocalDate.of(2013, 1, 1), "NAME", NODES, "A", "B", "C");
    assertEquals(specification, cycleObject(InterpolatedCurveSpecification.class, specification));
  }
View Full Code Here

        }
        final Object dataObject = inputs.getValue(ValueRequirementNames.CURVE_MARKET_DATA);
        if (dataObject == null) {
          throw new OpenGammaRuntimeException("Could not get yield curve data");
        }
        final InterpolatedCurveSpecification specification = (InterpolatedCurveSpecification) specificationObject;
        final SnapshotDataBundle marketData = (SnapshotDataBundle) dataObject;
        final int n = marketData.size();
        final double[] times = new double[n];
        final double[] yields = new double[n];
        final double[][] jacobian = new double[n][n];
        Boolean isYield = null;
        int i = 0;
        for (final CurveNodeWithIdentifier node : specification.getNodes()) {
          if (node.getCurveNode() instanceof ContinuouslyCompoundedRateNode) {
            if (i == 0) {
              isYield = true;
            } else {
              if (!isYield) {
                throw new OpenGammaRuntimeException("Was expecting only continuously-compounded rate nodes; have " + node.getCurveNode());
              }
            }
          } else if (node.getCurveNode() instanceof DiscountFactorNode) {
            if (i == 0) {
              isYield = false;
            } else {
              if (isYield) {
                throw new OpenGammaRuntimeException("Was expecting only discount factor nodes; have " + node.getCurveNode());
              }
            }
          } else {
            throw new OpenGammaRuntimeException("Can only handle discount factor or continuously-compounded rate nodes; have " + node.getCurveNode());
          }
          //TODO add check to make sure it's only discounting or rate curve nodes
          final Double marketValue = marketData.getDataPoint(node.getIdentifier());
          final Tenor maturity = node.getCurveNode().getResolvedMaturity();
          if (marketValue == null) {
            throw new OpenGammaRuntimeException("Could not get market data for " + node);
          }
          times[i] = DateUtils.estimatedDuration(maturity.getPeriod()).toDays() / 365.0; //TODO check if this is correct
          yields[i] = marketValue;
          jacobian[i][i] = 1;
          i++;
        }
        final String interpolatorName = specification.getInterpolatorName();
        final String rightExtrapolatorName = specification.getRightExtrapolatorName();
        final String leftExtrapolatorName = specification.getLeftExtrapolatorName();
        final Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName, leftExtrapolatorName, rightExtrapolatorName);
        final InterpolatedDoublesCurve curve = InterpolatedDoublesCurve.from(times, yields, interpolator, curveName);
        final ValueProperties curveProperties = createValueProperties()
            .with(ValuePropertyNames.CURVE, curveName)
            .with(ValuePropertyNames.CURVE_CALCULATION_CONFIG, curveCalculationConfig)
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.curve.InterpolatedCurveSpecification

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.