Package org.jquantlib.instruments

Examples of org.jquantlib.instruments.VanillaSwap$ResultsImpl


        // check swaps
        final IborIndex euribor6m = new Euribor6M(curveHandle);
        for (int i=0; i<vars.swaps; i++) {
            final Period tenor = new Period(swapData[i].n, swapData[i].units);

            final VanillaSwap swap = new MakeVanillaSwap(tenor, euribor6m, 0.0)
                .withEffectiveDate(vars.settlement)
                .withFixedLegDayCount(vars.fixedLegDayCounter)
                .withFixedLegTenor(new Period(vars.fixedLegFrequency))
                .withFixedLegConvention(vars.fixedLegConvention)
                .withFixedLegTerminationDateConvention(vars.fixedLegConvention)
                .value();

            /*@Rate*/ final double expectedRate  = swapData[i].rate/100;
            /*@Rate*/ final double estimatedRate = swap.fairRate();
            /*@Spread*/ final double error = Math.abs(expectedRate-estimatedRate);
            if (error > tolerance) {
              throw new RuntimeException(
              String.format("%d %s %s %f %s %f %s %f %s %f",
                      swapData[i].n, " year(s) swap:\n",
View Full Code Here


      final IborIndex index = new Euribor6M(curveHandle);
      for (int i=0; i<vars.swaps; i++) {
          final Period tenor = new Period(swapData[i].n, swapData[i].units);

          final VanillaSwap swap = new MakeVanillaSwap(tenor, index, 0.0)
              .withEffectiveDate(vars.settlement)
              .withFixedLegDayCount(vars.fixedLegDayCounter)
              .withFixedLegTenor(new Period(vars.fixedLegFrequency))
              .withFixedLegConvention(vars.fixedLegConvention)
              .withFixedLegTerminationDateConvention(vars.fixedLegConvention)
                  .value();

          /*@Rate*/ final double expectedRate  = swapData[i].rate/100;
          /*@Rate*/ final double estimatedRate = swap.fairRate();
          /*@Real*/ final double tolerance = 1.0e-9;
          if (Math.abs(expectedRate-estimatedRate) > tolerance) {
            throw new RuntimeException(
                String.format("%s %d %s %s %f %s %s %f",
                  "before LIBOR fixing:\n",
                          swapData[i].n, " year(s) swap:\n",
                          "    estimated rate: ", estimatedRate, "\n",
                          "    expected rate:  ", expectedRate));
          }
      }

      final Flag f = new Flag();
      vars.termStructure.addObserver(f);
      f.lower();

      index.addFixing(vars.today, 0.0425);

      if (!f.isUp())
          throw new RuntimeException("Observer was not notified of rate fixing");

      for (int i=0; i<vars.swaps; i++) {
          final Period tenor = new Period(swapData[i].n, swapData[i].units);

          final VanillaSwap swap = new MakeVanillaSwap(tenor, index, 0.0)
              .withEffectiveDate(vars.settlement)
              .withFixedLegDayCount(vars.fixedLegDayCounter)
              .withFixedLegTenor(new Period(vars.fixedLegFrequency))
              .withFixedLegConvention(vars.fixedLegConvention)
              .withFixedLegTerminationDateConvention(vars.fixedLegConvention)
                  .value();

          /*@Rate*/ final double expectedRate  = swapData[i].rate/100;
          /*@Rate*/ final double estimatedRate = swap.fairRate();
          /*@Real*/ final double tolerance = 1.0e-9;
          if (Math.abs(expectedRate-estimatedRate) > tolerance) {
            throw new RuntimeException(
                String.format("%s %d %s %s %f %s %s %f",
                          "after LIBOR fixing:\n",
View Full Code Here

      // check swaps
      final IborIndex jpylibor6m = new JPYLibor(new Period(6, TimeUnit.Months), curveHandle);
      for (int i=0; i<vars.swaps; i++) {
          final Period tenor = new Period(swapData[i].n, swapData[i].units);

          final VanillaSwap swap = new MakeVanillaSwap(tenor, jpylibor6m, 0.0)
              .withEffectiveDate(vars.settlement)
              .withFixedLegDayCount(vars.fixedLegDayCounter)
              .withFixedLegTenor(new Period(vars.fixedLegFrequency))
              .withFixedLegConvention(vars.fixedLegConvention)
              .withFixedLegTerminationDateConvention(vars.fixedLegConvention)
              .withFixedLegCalendar(vars.calendar)
              .withFloatingLegCalendar(vars.calendar)
                  .value();

          /*@Rate*/ final double expectedRate  = swapData[i].rate/100;
          /*@Rate*/ final double estimatedRate = swap.fairRate();
          /*@Spread*/ final double error = Math.abs(expectedRate-estimatedRate);
          /*@Real*/ final double tolerance = 1.0e-9;

         
          if (error > tolerance) {
View Full Code Here

TOP

Related Classes of org.jquantlib.instruments.VanillaSwap$ResultsImpl

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.