Package org.jquantlib.instruments.bonds

Examples of org.jquantlib.instruments.bonds.ConvertibleZeroCouponBond


    // zero-coupon
    Schedule schedule = new MakeSchedule(vars.issueDate, vars.maturityDate,
        new Period(Frequency.Once), vars.calendar,
        BusinessDayConvention.Following).backwards().schedule();

    final ConvertibleZeroCouponBond euZero = new ConvertibleZeroCouponBond(
        euExercise, vars.conversionRatio, vars.no_dividends,
        vars.no_callability, vars.creditSpread, vars.issueDate,
        vars.settlementDays, vars.dayCounter, schedule, vars.redemption);
    euZero.setPricingEngine(engine);

    final ConvertibleZeroCouponBond amZero = new ConvertibleZeroCouponBond(
        amExercise, vars.conversionRatio, vars.no_dividends,
        vars.no_callability, vars.creditSpread, vars.issueDate,
        vars.settlementDays, vars.dayCounter, schedule, vars.redemption);
    amZero.setPricingEngine(engine);

    final ZeroCouponBond zero = new ZeroCouponBond(vars.settlementDays,
        vars.calendar, 100.0, vars.maturityDate,
        BusinessDayConvention.Following, vars.redemption,
        vars.issueDate);

    final PricingEngine bondEngine = new DiscountingBondEngine(discountCurve);
    zero.setPricingEngine(bondEngine);

    double tolerance = 1.0e-2 * (vars.faceAmount / 100.0);

    double error = Math.abs(euZero.NPV() - zero.settlementValue());
    if (error > tolerance) {
      fail("failed to reproduce zero-coupon bond price:"
          + "\n    calculated: " + euZero.NPV()
          + "\n    expected:   " + zero.settlementValue()
          + "\n    error:      " + error);
    }

    error = Math.abs(amZero.NPV() - zero.settlementValue());
    if (error > tolerance) {
      fail("failed to reproduce zero-coupon bond price:"
          + "\n    calculated: " + amZero.NPV()
          + "\n    expected:   " + zero.settlementValue()
          + "\n    error:      " + error);
    }

    // coupon
View Full Code Here


    final Schedule schedule = new MakeSchedule(vars.issueDate, vars.maturityDate,
        new Period(Frequency.Once), vars.calendar,
        BusinessDayConvention.Following).backwards().schedule();

    final ConvertibleZeroCouponBond euZero = new ConvertibleZeroCouponBond(
        euExercise, vars.conversionRatio, vars.no_dividends,
        vars.no_callability, vars.creditSpread, vars.issueDate,
        vars.settlementDays, vars.dayCounter, schedule, vars.redemption);
    euZero.setPricingEngine(engine);

    final VanillaOption euOption = new VanillaOption(payoff, euExercise);
    euOption.setPricingEngine(vanillaEngine);

    final double tolerance = 5.0e-2 * (vars.faceAmount / 100.0);

    final double expected = vars.faceAmount
        / 100.0
        * (vars.redemption
            * vars.riskFreeRate.currentLink().discount(
                vars.maturityDate) + vars.conversionRatio
            * euOption.NPV());
    final double error = Math.abs(euZero.NPV() - expected);
    if (error > tolerance) {
      fail("failed to reproduce plain-option price:"
          + "\n    calculated: " + euZero.NPV()
          + "\n    expected:   " + expected + "\n    error:      "
          + error);
    }
  }
View Full Code Here

TOP

Related Classes of org.jquantlib.instruments.bonds.ConvertibleZeroCouponBond

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.