Package com.opengamma.analytics.math.curve

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


  }

  @Override
  public PriceIndexCurve generateCurve(String name, double[] parameters) {
    ArgumentChecker.isTrue(parameters.length == 1, "Constant curve should have one parameter");
    return new PriceIndexCurve(new ConstantDoublesCurve(parameters[0], name));
  }
View Full Code Here


  //CSOFF
  public static double y = 0.02;
  //CSON

  public static void constantYieldCurveDemo(PrintStream out) {
    DoublesCurve curve = new ConstantDoublesCurve(y);
    YieldCurve yieldCurve = YieldCurve.from(curve);

    out.println(yieldCurve.getInterestRate(1.0));
    out.println(yieldCurve.getInterestRate(2.0));
    out.println(yieldCurve.getInterestRate(10.0));
View Full Code Here

    out.println(yieldCurve.getDiscountFactor(10.0));
  }

  // @export yieldCurveBundleDemo
  public static void yieldCurveBundleDemo(PrintStream out) {
    DoublesCurve curve = new ConstantDoublesCurve(y);
    YieldCurve yieldCurve = YieldCurve.from(curve);

    YieldCurveBundle bundle = new YieldCurveBundle();
    bundle.setCurve("Constant 2% Yield Curve", yieldCurve);
View Full Code Here

*/
public class CurveExample {

  // @export "constantDoublesCurveDemo"
  public static void constantDoublesCurveDemo(PrintStream out) {
    Curve<Double, Double> curve = new ConstantDoublesCurve(5.0);

    out.println(curve.getYValue(0.0));
    out.println(curve.getYValue(10.0));
    out.println(curve.getYValue(-10.0));
  }
View Full Code Here

    out.println(loan.getInterestAmount());
  }

  public static YieldCurveBundle getBundle() {
    final YieldCurveBundle bundle = new YieldCurveBundle();
    final ConstantDoublesCurve curve = new ConstantDoublesCurve(y);
    final YieldCurve yieldCurve = YieldCurve.from(curve);
    bundle.setCurve(yieldCurveName, yieldCurve);
    return bundle;
  }
View Full Code Here

  }

  @Override
  public YieldAndDiscountCurve generateCurve(final String name, final double[] x) {
    ArgumentChecker.isTrue(x.length == 1, "Constant curve should have one parameter");
    return new YieldCurve(name, new ConstantDoublesCurve(x[0], name));
  }
View Full Code Here

    assertEquals(bsPrice, pdePrice, bsPrice * 1e-4);

    //now price in terms of the forward - gives around 3 times improvement in accuracy
    final ForwardCurve fc = new ForwardCurve(FWD_CURVE.getForward(T));
    final ConstantDoublesCurve r = ConstantDoublesCurve.from(0.0);
    pdePrice = DF * PRICER.price(fc, r, option, LOCAL_VOL_SUR, false, xNodes, tNodes, 0.1, 0.0, 5.0);

    // resErr = Math.abs((pdePrice-bsPrice)/bsPrice);
    // System.out.println(bsPrice +"\t"+pdePrice+"\t"+resErr);
    assertEquals(bsPrice, pdePrice, bsPrice * 3e-5);
 
View Full Code Here

          final int numberOfNodes = dataBundle.size();
          final double[] yields1 = Arrays.copyOfRange(x.getData(), index2, index2 + numberOfNodes);
          final double spread1 = x.getData()[index2 + numberOfNodes];
          index2 += numberOfNodes + 1;
          final YieldCurve newYieldCurve = YieldCurve.from(InterpolatedDoublesCurve.from(dataBundle.getKeys(), yields1, ((InterpolatedDoublesCurve) yieldCurve.getCurve()).getInterpolator()));
          final YieldCurve newSpreadCurve = YieldCurve.from(new ConstantDoublesCurve(spread1));
          final YieldAndDiscountCurve newCurve = new YieldAndDiscountAddZeroSpreadCurve("NewYield+Spread", false, newYieldCurve, newSpreadCurve);
          curves.replaceCurve(name, newCurve);
        }
        if (fixedCurves != null) {
          curves.addAll(fixedCurves);
View Full Code Here

  }

  @Test
  public void generateCurveYieldConstant() {
    final YieldAndDiscountCurve curveGenerated = GENERATOR_YIELD_CONSTANT.generateCurve(CURVE_NAME_1, new double[] {CST});
    final YieldAndDiscountCurve curveExpected = new YieldCurve(CURVE_NAME_1, new ConstantDoublesCurve(CST, CURVE_NAME_1));
    assertEquals("GeneratorCurveYieldConstant: generate curve", curveExpected, curveGenerated);
  }
View Full Code Here

    final double[] x = new double[YIELD.length + 1];
    System.arraycopy(YIELD, 0, x, 0, YIELD.length);
    x[YIELD.length] = CST;
    final YieldAndDiscountCurve curveGenerated = GENERATOR_SPREAD.generateCurve(CURVE_NAME_1, x);
    final YieldAndDiscountCurve curveExpected0 = new YieldCurve(CURVE_NAME_1 + "-0", new InterpolatedDoublesCurve(NODES, YIELD, LINEAR_FLAT, true, CURVE_NAME_1 + "-0"));
    final YieldAndDiscountCurve curveExpected1 = new YieldCurve(CURVE_NAME_1 + "-1", new ConstantDoublesCurve(CST, CURVE_NAME_1 + "-1"));
    final YieldAndDiscountCurve curveExpected = new YieldAndDiscountAddZeroSpreadCurve(CURVE_NAME_1, false, curveExpected0, curveExpected1);
    assertEquals("GeneratorCurveYieldConstant: generate curve", curveExpected, curveGenerated);
  }
View Full Code Here

TOP

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

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.