Examples of YieldCurveBundle


Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

    return _knownData;
  }

  @Override
  public YieldCurveBundle evaluate(final DoubleMatrix1D x) {
    final YieldCurveBundle bundle = _knownData.copy();
    final Set<String> names = _curveGenerators.keySet();
    int index = 0;
    for (final String name : names) {
      final GeneratorYDCurve gen = _curveGenerators.get(name);
      final double[] paramCurve = Arrays.copyOfRange(x.getData(), index, index + gen.getNumberOfParameter());
      index += gen.getNumberOfParameter();
      final YieldAndDiscountCurve newCurve = gen.generateCurve(name, bundle, paramCurve);
      bundle.setCurve(name, newCurve);
    }
    return bundle;
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

    _data = data;
  }

  @Override
  public DoubleMatrix1D evaluate(final DoubleMatrix1D x) {
    final YieldCurveBundle bundle = _data.getKnownData().copy();
    final YieldCurveBundle newCurves = _data.getBuildingFunction().evaluate(x);
    bundle.addAll(newCurves);
    final double[] res = new double[_data.getNumberOfInstruments()];
    for (int i = 0; i < _data.getNumberOfInstruments(); i++) {
      res[i] = _data.getInstrument(i).accept(_calculator, bundle);
    }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

    super(ycBundle, smile, currencyPair);
  }

  @Override
  public SmileDeltaTermStructureDataBundle copy() {
    final YieldCurveBundle curves = getCurvesCopy();
    final SmileDeltaTermStructureParametersStrikeInterpolation smile = getVolatilityModel().copy();
    final Pair<Currency, Currency> currencyPair = Pair.of(getCurrencyPair().getFirst(), getCurrencyPair().getSecond());
    return new SmileDeltaTermStructureDataBundle(curves, smile, currencyPair);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

  public void presentValueFromZSpread() {
    final double pv = METHOD.presentValue(BOND_FIXED_SECURITY_1, CURVES);
    double zSpread = 0.0;
    final double pvZ0 = METHOD.presentValueFromZSpread(BOND_FIXED_SECURITY_1, CURVES, zSpread);
    assertEquals("Fixed coupon bond security: present value from z-spread", pv, pvZ0, TOLERANCE_PRICE);
    final YieldCurveBundle shiftedBundle = new YieldCurveBundle();
    shiftedBundle.addAll(CURVES);
    YieldAndDiscountCurve shiftedCredit = CURVES.getCurve(CREDIT_CURVE_NAME).withParallelShift(zSpread);
    shiftedBundle.replaceCurve(CREDIT_CURVE_NAME, shiftedCredit);
    double pvZ = METHOD.presentValueFromZSpread(BOND_FIXED_SECURITY_1, CURVES, zSpread);
    double pvZExpected = METHOD.presentValue(BOND_FIXED_SECURITY_1, shiftedBundle);
    assertEquals("Fixed coupon bond security: present value from z-spread", pvZExpected, pvZ, TOLERANCE_PRICE);
    zSpread = 0.0010; // 10bps
    shiftedCredit = CURVES.getCurve(CREDIT_CURVE_NAME).withParallelShift(zSpread);
    shiftedBundle.replaceCurve(CREDIT_CURVE_NAME, shiftedCredit);
    pvZ = METHOD.presentValueFromZSpread(BOND_FIXED_SECURITY_1, CURVES, zSpread);
    pvZExpected = METHOD.presentValue(BOND_FIXED_SECURITY_1, shiftedBundle);
    assertEquals("Fixed coupon bond security: present value from z-spread", pvZExpected, pvZ, TOLERANCE_PRICE);
    final double pvZ2 = METHOD.presentValueFromZSpread(BOND_FIXED_SECURITY_1, CURVES, zSpread);
    assertEquals("Fixed coupon bond security: present value from z-spread", pvZ, pvZ2, 1E-8);
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

  /**
   * Tests the z-spread computation from the clean price.
   */
  public void zSpreadFromCleanPrice() {
    final double zSpreadExpected = 0.0025; // 25bps
    final YieldCurveBundle shiftedBundle = new YieldCurveBundle();
    shiftedBundle.addAll(CURVES);
    final YieldAndDiscountCurve shiftedCredit = CURVES.getCurve(CREDIT_CURVE_NAME).withParallelShift(zSpreadExpected);
    shiftedBundle.replaceCurve(CREDIT_CURVE_NAME, shiftedCredit);
    final double cleanZSpread = METHOD.cleanPriceFromCurves(BOND_FIXED_SECURITY_1, shiftedBundle);
    final double zSpread = METHOD.zSpreadFromCurvesAndClean(BOND_FIXED_SECURITY_1, CURVES, cleanZSpread);
    assertEquals("Fixed coupon bond security: present value from z-spread", zSpreadExpected, zSpread, 1E-8);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

  /**
   * Tests the z-spread sensitivity computation from the present value.
   */
  public void zSpreadSensitivityFromCleanPrice() {
    final double zSpread = 0.0025; // 25bps
    final YieldCurveBundle shiftedBundle = new YieldCurveBundle();
    shiftedBundle.addAll(CURVES);
    final YieldAndDiscountCurve shiftedCredit = CURVES.getCurve(CREDIT_CURVE_NAME).withParallelShift(zSpread);
    shiftedBundle.replaceCurve(CREDIT_CURVE_NAME, shiftedCredit);
    final double cleanZSpread = METHOD.cleanPriceFromCurves(BOND_FIXED_SECURITY_1, shiftedBundle);
    final double zsComputed = METHOD.presentValueZSpreadSensitivityFromCurvesAndClean(BOND_FIXED_SECURITY_1, CURVES, cleanZSpread);
    final double zsExpected = METHOD.presentValueZSpreadSensitivity(BOND_FIXED_SECURITY_1, CURVES, zSpread);
    assertEquals("Fixed coupon bond security: z-spread sensitivity", zsExpected, zsComputed, 1E-6);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

  // @export "annuityDerivatives"
  public static void annuityDerivativeDemo(final PrintStream out) {
    final double[] paymentTimes = {t };
    final boolean isPayer = false;
    final YieldCurveBundle bundle = getBundle(y);
    final AnnuityCouponFixed annuity = new AnnuityCouponFixed(ccy, paymentTimes, r, yieldCurveName, isPayer);
    final double presentValue = annuity.accept(presentValueCalculator, bundle);
    out.format("Present value of 1-period annuity: %f%n", presentValue);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

  static PresentValueCalculator presentValueCalculator = PresentValueCalculator.getInstance();
  static YieldCurve yieldCurve = YieldCurve.from(new ConstantDoublesCurve(y));
  static ParRateCalculator parRateCalculator = ParRateCalculator.getInstance();

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

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

  public static void interestRateDerivativeDemo(final PrintStream out) {
    final Cash loan = new Cash(ccy, 0.0, t, notional, r, t, yieldCurveName);

    // @export "interestRateDerivatives-presentValue"
    final YieldCurveBundle bundle = getBundle(y);

    for (double i = 1.0; i < 3.0; i += 1) {
      out.format("Yield curve interest rate at %f: %f%n", i, yieldCurve.getInterestRate(i));
      out.format("Yield curve discount factor at %f: %f%n", i, yieldCurve.getDiscountFactor(i));
    }
View Full Code Here

Examples of com.opengamma.analytics.financial.interestrate.YieldCurveBundle

  // @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);

    out.println(bundle.getAllNames());

    assert bundle.containsName("Constant 2% Yield Curve");
    assert bundle.getCurve("Constant 2% Yield Curve").equals(yieldCurve);
  }
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.