Package com.opengamma.analytics.math.interpolation

Examples of com.opengamma.analytics.math.interpolation.Interpolator1D


    final List<Double> result = new ArrayList<>();
    if (!(curve.getCurve() instanceof InterpolatedDoublesCurve)) {
      throw new IllegalArgumentException("Can only handle interpolated curves at the moment");
    }
    final InterpolatedDoublesCurve interpolatedCurve = (InterpolatedDoublesCurve) curve.getCurve();
    final Interpolator1D interpolator = interpolatedCurve.getInterpolator();
    final Interpolator1DDataBundle data = interpolatedCurve.getDataBundle();
    if (sensitivityList != null && sensitivityList.size() > 0) {
      final double[][] sensitivityDD = new double[sensitivityList.size()][];
      // Implementation note: Sensitivity of the interpolated discount factor to the node discount factor
      final double[] df = new double[sensitivityList.size()];
      int k = 0;
      for (final DoublesPair timeAndS : sensitivityList) {
        df[k] = interpolator.interpolate(data, timeAndS.first);
        sensitivityDD[k++] = interpolator.getNodeSensitivitiesForValue(data, timeAndS.getFirst());
      }
      for (int j = 0; j < sensitivityDD[0].length; j++) {
        double temp = 0.0;
        k = 0;
        for (final DoublesPair timeAndS : sensitivityList) {
View Full Code Here


    final LinkedHashMap<String, InterpolatedDoublesCurve> res = new LinkedHashMap<>();
    int index = 0;

    for (final String name : _interpolators.keySet()) {
      final Interpolator1D interpolator = _interpolators.get(name);
      final double[] nodes = _knotPoints.get(name);
      final double[] values = Arrays.copyOfRange(x.getData(), index, index + nodes.length);
      index += nodes.length;
      final InterpolatedDoublesCurve curve = InterpolatedDoublesCurve.from(nodes, values, interpolator);
      res.put(name, curve);
View Full Code Here

    private static final String LOG_VALUE_FIELD_NAME = "logValueField";

    @Override
    public VolatilitySurfaceInterpolator buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final GeneralSmileInterpolator smileInterpolator = deserializer.fieldValueToObject(GeneralSmileInterpolator.class, message.getByName(SMILE_INTERPOLATOR_FIELD_NAME));
      final Interpolator1D timeInterpolator = deserializer.fieldValueToObject(Interpolator1D.class, message.getByName(TIME_INTERPOLATOR_FIELD_NAME));
      final boolean useLogTime = message.getBoolean(LOG_TIME_FIELD_NAME);
      final boolean useIntegratedVariance = message.getBoolean(INTEGRATED_VARIANCE_FIELD_NAME);
      final boolean useLogValue = message.getBoolean(LOG_VALUE_FIELD_NAME);
      return new VolatilitySurfaceInterpolator(smileInterpolator, timeInterpolator, useLogTime, useIntegratedVariance, useLogValue);
    }
View Full Code Here

    private static final String INTERPOLATOR_FIELD_NAME = "interpolatorField";
    private static final String EXTRAPOLATOR_FAILURE_BEHAVIOUR_FIELD_NAME = "extrapolatorFailureBehaviourField";

    @Override
    public SmileInterpolatorSpline buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final Interpolator1D interpolator = deserializer.fieldValueToObject(Interpolator1D.class, message.getByName(INTERPOLATOR_FIELD_NAME));
      final String extrapolatorFailureBehaviourName = message.getString(EXTRAPOLATOR_FAILURE_BEHAVIOUR_FIELD_NAME);
      return new SmileInterpolatorSpline(interpolator, extrapolatorFailureBehaviourName);
    }
View Full Code Here

    for (int i = 0; i < nStrikes; i++) {
      k[i] = strikeNprice[i][0];
      price[i] = strikeNprice[i][1];
    }

    final Interpolator1D interpolator = Interpolator1DFactory.getInterpolator("DoubleQuadratic");
    final Interpolator1DDataBundle dataBundle = interpolator.getDataBundleFromSortedArrays(k, price);

    final double fftPrice = interpolator.interpolate(dataBundle, STRIKE);

    // System.out.println(fftPrice + "\t" + pdfPrice);
    assertEquals(fftPrice, pdfPrice, 2e-6);

    // for (int i = 0; i < strikeNprice.length; i++) {
View Full Code Here

    }
    final String interpolatorName = definition.getInterpolatorName();
    final String leftExtrapolatorName = definition.getLeftExtrapolatorName();
    final String rightExtrapolatorName = definition.getRightExtrapolatorName();
    final boolean interpolateYield = definition.isInterpolateYields();
    final Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName, leftExtrapolatorName, rightExtrapolatorName);
    return new InterpolatedYieldCurveSpecification(curveDate, definition.getName(), definition.getCurrency(), interpolator, interpolateYield,
        ids, definition.getRegionId());
  }
View Full Code Here

      }
      final String interpolatorName = curveDefinition.getInterpolatorName();
      final String leftExtrapolatorName = curveDefinition.getLeftExtrapolatorName();
      final String rightExtrapolatorName = curveDefinition.getRightExtrapolatorName();
      final boolean interpolateYield = curveDefinition.isInterpolateYields();
      final Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName, leftExtrapolatorName, rightExtrapolatorName);
      return new InterpolatedYieldCurveSpecification(curveDate, curveDefinition.getName(), curveDefinition.getCurrency(), interpolator, interpolateYield,
          securities, curveDefinition.getRegionId());
    } catch (final OpenGammaRuntimeException e) {
      throw new OpenGammaRuntimeException("Error constructing " + curveDefinition.getName() + "_" + curveDefinition.getCurrency().getCode() + ": " + e.getMessage());
    }
View Full Code Here

    Validate.notNull(kInterpolatorName, "k interpolator name");
    Validate.notNull(kLeftExtrapolatorName, "k left extrapolator name");
    Validate.notNull(kRightExtrapolatorName, "k right extrapolator name");
    _definitionName = definitionName;
    _instrumentType = instrumentType;
    final Interpolator1D tInterpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(tInterpolatorName, tLeftExtrapolatorName, tRightExtrapolatorName);
    final Interpolator1D kInterpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(kInterpolatorName, kLeftExtrapolatorName, kRightExtrapolatorName);
    _interpolator = new GridInterpolator2D(tInterpolator, kInterpolator);
  }
View Full Code Here

      ccy2 = putCurrency;
      spot = 1. / (Double) spotObject;
    }
    final InstrumentDerivative fxOption = definition.toDerivative(now, allCurveNames);
    final YieldCurveBundle yieldCurves = new YieldCurveBundle(allCurveNames, curves);
    final Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName, leftExtrapolatorName, rightExtrapolatorName);
    final ValueRequirement fxVolatilitySurfaceRequirement = getSurfaceRequirement(surfaceName, putCurrency, callCurrency, interpolatorName, leftExtrapolatorName, rightExtrapolatorName);
    final Object volatilitySurfaceObject = inputs.getValue(fxVolatilitySurfaceRequirement);
    if (volatilitySurfaceObject == null) {
      throw new OpenGammaRuntimeException("Could not get " + fxVolatilitySurfaceRequirement);
    }
View Full Code Here

    private static final String RIGHT_EXTRAPOLATOR_FIELD_NAME = "rightExtrapolator";
    private static final String INTERPOLATOR_FIELD_NAME = "interpolator";

    @Override
    protected void buildMessage(final FudgeSerializer serializer, final MutableFudgeMsg message, final CombinedInterpolatorExtrapolator object) {
      final Interpolator1D interpolator = object.getInterpolator();
      message.add(INTERPOLATOR_FIELD_NAME, Interpolator1DFactory.getInterpolatorName(interpolator));
      message.add(LEFT_EXTRAPOLATOR_FIELD_NAME, Interpolator1DFactory.getInterpolatorName(object.getLeftExtrapolator()));
      message.add(RIGHT_EXTRAPOLATOR_FIELD_NAME, Interpolator1DFactory.getInterpolatorName(object.getRightExtrapolator()));
    }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.interpolation.Interpolator1D

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.