Package org.jquantlib.instruments.bonds

Examples of org.jquantlib.instruments.bonds.ConvertibleFloatingRateBond


    final int fixingDays = 2;
    final Array gearings = new Array(1).fill(1.0);
    final Array spreadsArr = new Array(0);
    final double[] spreads = { 0 };

    final ConvertibleFloatingRateBond euFloating = new ConvertibleFloatingRateBond(
        euExercise, vars.conversionRatio, vars.no_dividends,
        vars.no_callability, vars.creditSpread, vars.issueDate,
        vars.settlementDays, index, fixingDays, spreads,
        vars.dayCounter, schedule, vars.redemption);
    euFloating.setPricingEngine(engine);

    final ConvertibleFloatingRateBond amFloating = new ConvertibleFloatingRateBond(
        amExercise, vars.conversionRatio, vars.no_dividends,
        vars.no_callability, vars.creditSpread, vars.issueDate,
        vars.settlementDays, index, fixingDays, spreads,
        vars.dayCounter, schedule, vars.redemption);
    amFloating.setPricingEngine(engine);

    final IborCouponPricer pricer = new BlackIborCouponPricer(
        new Handle<OptionletVolatilityStructure>());

    final Schedule floatSchedule = new Schedule(vars.issueDate,
        vars.maturityDate, new Period(vars.frequency), vars.calendar,
        BusinessDayConvention.Following,
        BusinessDayConvention.Following, DateGeneration.Rule.Backward,
        false);

    final FloatingRateBond floating = new FloatingRateBond(vars.settlementDays,
        vars.faceAmount, floatSchedule, index, vars.dayCounter,
        BusinessDayConvention.Following, fixingDays, gearings,
        spreadsArr, new Array(0), new Array(0), false, vars.redemption,
        vars.issueDate);

    floating.setPricingEngine(bondEngine);
    PricerSetter.setCouponPricer(floating.cashflows(), pricer);

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

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

    error = Math.abs(amFloating.NPV() - floating.settlementValue());
    if (error > tolerance) {
      fail("failed to reproduce floating-rate bond price:"
          + "\n    calculated: " + amFloating.NPV()
          + "\n    expected:   " + floating.settlementValue()
          + "\n    error:      " + error);
    }
  }
View Full Code Here

TOP

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

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.