Package com.opengamma.analytics.math.curve

Examples of com.opengamma.analytics.math.curve.InterpolatedDoublesCurve


  }

  @Override
  public PriceIndexCurve generateCurve(String name, double[] parameters) {
    ArgumentChecker.isTrue(parameters.length == _nbPoints, "Incorrect dimension for the price indices");
    return new PriceIndexCurve(new InterpolatedDoublesCurve(_nodePoints, parameters, _interpolator, true, name));
  }
View Full Code Here


  // @export "interpolatedDoublesCurveDemo"
  public static void interpolatedDoublesCurveDemo(PrintStream out) {
    double[] xdata = {1.0, 2.0, 3.0};
    double[] ydata = {2.0, 4.0, 6.0};
    LinearInterpolator1D interpolator = new LinearInterpolator1D();
    Curve<Double, Double> curve = new InterpolatedDoublesCurve(xdata, ydata, interpolator, true);

    out.println(curve.getYValue(1.0));
    out.println(curve.getYValue(2.0));
    out.println(curve.getYValue(3.0));

    out.println(curve.getYValue(1.5));
    try {
      out.println("Trying to get y value for too large an x...");
      curve.getYValue(4.0);
    } catch (java.lang.IllegalArgumentException e) {
      out.println("IllegalArgumentException called");
    }
  }
View Full Code Here

    Interpolator1D interpolator = new LinearInterpolator1D();
    Interpolator1D leftExtrapolator = new LinearExtrapolator1D(interpolator);
    Interpolator1D rightExtrapolator = new LinearExtrapolator1D(interpolator);
    Interpolator1D combined = new CombinedInterpolatorExtrapolator(interpolator, leftExtrapolator, rightExtrapolator);

    Curve<Double, Double> curve = new InterpolatedDoublesCurve(xdata, ydata, combined, true);

    out.println(curve.getYValue(1.0));
    out.println(curve.getYValue(2.0));
    out.println(curve.getYValue(3.0));

    out.println(curve.getYValue(1.5));
    out.println(curve.getYValue(4.0));
  }
View Full Code Here

  public static YieldCurveBundle getBundle() {
    final YieldCurveBundle bundle = new YieldCurveBundle();

    final Interpolator1D extrapolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(Interpolator1DFactory.DOUBLE_QUADRATIC, LINEAR_EXTRAPOLATOR, FLAT_EXTRAPOLATOR);

    final InterpolatedDoublesCurve fCurve = InterpolatedDoublesCurve.from(FUNDING_CURVE_TIMES, FUNDING_YIELDS, extrapolator);
    final YieldCurve fundingCurve = YieldCurve.from(fCurve);
    bundle.setCurve(FUNDING_CURVE_NAME, fundingCurve);

    final InterpolatedDoublesCurve lcurve = InterpolatedDoublesCurve.from(LIBOR_CURVE_TIMES, LIBOR_YIELDS, extrapolator);
    final YieldCurve liborCurve = YieldCurve.from(lcurve);
    bundle.setCurve(LIBOR_CURVE_NAME, liborCurve);

    return bundle;
  }
View Full Code Here

    ArgumentChecker.isTrue(nodePoints.length == nbYields, "Yields array of incorrect length");
    final double[] discountFactor = new double[nbYields];
    for (int loopy = 0; loopy < nbYields; loopy++) {
      discountFactor[loopy] = Math.exp(-nodePoints[loopy] * yields[loopy]);
    }
    final InterpolatedDoublesCurve curve = new InterpolatedDoublesCurve(nodePoints, discountFactor, interpolator, false);
    return new DiscountCurve(name, curve);
  }
View Full Code Here

  }

  @Override
  public YieldAndDiscountCurve generateCurve(final String name, final double[] x) {
    ArgumentChecker.isTrue(x.length == _nbPoints, "Incorrect dimension for the rates");
    return new YieldPeriodicCurve(name, _compoundingPeriodsPerYear, new InterpolatedDoublesCurve(_nodePoints, x, _interpolator, true, name));
  }
View Full Code Here

  }

  @Override
  public YieldAndDiscountCurve generateCurve(final String name, final double[] x) {
    ArgumentChecker.isTrue(x.length == _nbPoints, "Incorrect dimension for the rates");
    return new YieldCurve(name, new InterpolatedDoublesCurve(_nodePoints, x, _interpolator, true, name));
  }
View Full Code Here

    final double[] yieldPeriodic = new double[nbYields];
    for (int loopy = 0; loopy < nbYields; loopy++) {
      final InterestRate continous = new ContinuousInterestRate(yields[loopy]);
      yieldPeriodic[loopy] = continous.toPeriodic(compoundingPeriodsPerYear).getRate();
    }
    final InterpolatedDoublesCurve curve = new InterpolatedDoublesCurve(nodePoints, yieldPeriodic, interpolator, false);
    return new YieldPeriodicCurve(name, compoundingPeriodsPerYear, curve);
  }
View Full Code Here

    ArgumentChecker.isTrue(nodePoints.length == nbDF, "Yields array of incorrect length");
    final double[] yields = new double[nbDF];
    for (int loopy = 0; loopy < nbDF; loopy++) {
      yields[loopy] = -Math.log(discountFactors[loopy]) / nodePoints[loopy];
    }
    final InterpolatedDoublesCurve curve = new InterpolatedDoublesCurve(nodePoints, yields, interpolator, false);
    return new YieldCurve(name, curve);
  }
View Full Code Here

  }

  @Override
  public YieldAndDiscountCurve generateCurve(final String name, final double[] x) {
    ArgumentChecker.isTrue(x.length == _nbPoints, "Incorrect dimension for the rates");
    return new DiscountCurve(name, new InterpolatedDoublesCurve(_nodePoints, x, _interpolator, true, name));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.curve.InterpolatedDoublesCurve

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.