Package org.jquantlib.daycounters

Examples of org.jquantlib.daycounters.ActualActual$ImplISMA


        final double faceAmount = 1000000.0;

        // with implicit settlement calculation:

      final Calendar bondCalendar = new NullCalendar();
      final DayCounter bondDayCount = new ActualActual(ActualActual.Convention.ISMA);
      final int settlementDays = 1;

    final Handle<YieldTermStructure> discountCurve = new Handle<YieldTermStructure>(Utilities.flatRate(today, 0.03, new Actual360()));

      // actual market values from the evaluation date

      final Frequency freq = Frequency.Semiannual;
      final Schedule sch1 = new Schedule(new Date(31, Month.October, 2004),
                    new Date(31, Month.October, 2006), new Period(freq), bondCalendar,
                    BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, DateGeneration.Rule.Backward, false);

      final FixedRateBond bond1 = new FixedRateBond(settlementDays, faceAmount, sch1,
                          new double[] {0.025},
                          bondDayCount, BusinessDayConvention.ModifiedFollowing,
                          100.0, new Date(1, Month.November, 2004));

    final PricingEngine bondEngine = new DiscountingBondEngine(discountCurve);

      bond1.setPricingEngine(bondEngine);

      final double marketPrice1 = 99.203125;
      final double marketYield1 = 0.02925;

      final Schedule sch2 = new Schedule(new Date(15, Month.November, 2004),
          new Date(15, Month.November, 2009), new Period(freq), bondCalendar,
          BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, DateGeneration.Rule.Backward, false);

      final FixedRateBond bond2 = new FixedRateBond(settlementDays, faceAmount, sch2,
                          new double [] {0.035},
                          bondDayCount, BusinessDayConvention.ModifiedFollowing,
                          100.0, new Date(15, Month.November, 2004));

      bond2.setPricingEngine(bondEngine);

      final double marketPrice2 = 99.6875;
      final double marketYield2 = 0.03569;

      // calculated values

      final double cachedPrice1a = 99.204505, cachedPrice2a = 99.687192;
      final double cachedPrice1b = 98.943393, cachedPrice2b = 101.986794;
      final double cachedYield1a = 0.029257,  cachedYield2a = 0.035689;
      final double cachedYield1b = 0.029045,  cachedYield2b = 0.035375;
      final double cachedYield1c = 0.030423,  cachedYield2c = 0.030432;

      // check
      final double tolerance = 1.0e-6;
      double price, yield;

      price = bond1.cleanPrice(marketYield1,
                               bondDayCount, Compounding.Compounded, freq);
      if (Math.abs(price-cachedPrice1a) > tolerance) {
        fail("failed to reproduce cached price:"
                     + "\n    calculated: " + price
                     + "\n    expected:   " + cachedPrice1a
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (price-cachedPrice1a));
      }

      price = bond1.getCleanPrice();
      if (Math.abs(price-cachedPrice1b) > tolerance) {
        fail("failed to reproduce cached price:"
                     + "\n    calculated: " + price
                     + "\n    expected:   " + cachedPrice1b
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (price-cachedPrice1b));
      }

      yield = bond1.yield(marketPrice1, bondDayCount, Compounding.Compounded, freq);
      if (Math.abs(yield-cachedYield1a) > tolerance) {
        fail("failed to reproduce cached compounded yield:"
                     + "\n    calculated: " + yield
                     + "\n    expected:   " + cachedYield1a
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (yield-cachedYield1a));
      }

      yield = bond1.yield(marketPrice1, bondDayCount, Compounding.Continuous, freq);
      if (Math.abs(yield-cachedYield1b) > tolerance) {
        fail("failed to reproduce cached continuous yield:"
                     + "\n    calculated: " + yield
                     + "\n    expected:   " + cachedYield1b
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (yield-cachedYield1b));
      }

      yield = bond1.yield(bondDayCount, Compounding.Continuous, freq);
      if (Math.abs(yield-cachedYield1c) > tolerance) {
        fail("failed to reproduce cached continuous yield:"
                     + "\n    calculated: " + yield
                     + "\n    expected:   " + cachedYield1c
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (yield-cachedYield1c));
      }


      price = bond2.cleanPrice(marketYield2, bondDayCount, Compounding.Compounded, freq);
      if (Math.abs(price-cachedPrice2a) > tolerance) {
        fail("failed to reproduce cached price:"
                     + "\n    calculated: " + price
                     + "\n    expected:   " + cachedPrice2a
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (price-cachedPrice2a));
      }

      price = bond2.getCleanPrice();
      if (Math.abs(price-cachedPrice2b) > tolerance) {
        fail("failed to reproduce cached price:"
                     + "\n    calculated: " + price
                     + "\n    expected:   " + cachedPrice2b
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (price-cachedPrice2b));
      }

      yield = bond2.yield(marketPrice2, bondDayCount, Compounding.Compounded, freq);
      if (Math.abs(yield-cachedYield2a) > tolerance) {
        fail("failed to reproduce cached compounded yield:"
                     + "\n    calculated: " + yield
                     + "\n    expected:   " + cachedYield2a
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (yield-cachedYield2a));
      }

      yield = bond2.yield(marketPrice2, bondDayCount, Compounding.Continuous, freq);
      if (Math.abs(yield-cachedYield2b) > tolerance) {
        fail("failed to reproduce cached continuous yield:"
                     + "\n    calculated: " + yield
                     + "\n    expected:   " + cachedYield2b
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (yield-cachedYield2b));
      }

      yield = bond2.yield(bondDayCount, Compounding.Continuous, freq);
      if (Math.abs(yield-cachedYield2c) > tolerance) {
        fail("failed to reproduce cached continuous yield:"
                     + "\n    calculated: " + yield
                     + "\n    expected:   " + cachedYield2c
                     + "\n    tolerance:  " + tolerance
                     + "\n    error:      " + (yield-cachedYield2c));
      }

      // with explicit settlement date:

      final Schedule sch3 = new Schedule(new Date(30,Month.November,2004),
                    new Date(30,Month.November,2006), new Period(freq),
                    new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                    BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, DateGeneration.Rule.Backward, false);

      final FixedRateBond bond3 = new FixedRateBond(settlementDays, faceAmount, sch3,
                          new double[] {0.02875},
                          new ActualActual(ActualActual.Convention.ISMA),
                          BusinessDayConvention.ModifiedFollowing,
                          100.0, new Date(30,Month.November,2004));

      bond3.setPricingEngine(bondEngine);
View Full Code Here


                   new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                   BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, DateGeneration.Rule.Backward, false);

      final FixedRateBond bond1 = new FixedRateBond(settlementDays, faceAmount, sch,
                          new double [] { 0.02875 },
                          new ActualActual(ActualActual.Convention.ISMA),
                          BusinessDayConvention.ModifiedFollowing,
                          100.0, new Date(30,Month.November,2004));

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

      final double cachedPrice1 = 99.298100;

      double price = bond1.getCleanPrice();
      if (Math.abs(price-cachedPrice1) > tolerance) {
          fail("failed to reproduce cached price:\n"
                     + "    calculated: " + price + "\n"
                     + "    expected:   " + cachedPrice1 + "\n"
                     + "    error:      " + (price-cachedPrice1));
      }

      // varying coupons

      final double [] couponRates = new double[] { 0.02875, 0.03, 0.03125, 0.0325 };

      final FixedRateBond bond2 = new FixedRateBond(settlementDays, faceAmount, sch,
                            couponRates,
                            new ActualActual(ActualActual.Convention.ISMA),
                            BusinessDayConvention.ModifiedFollowing,
                            100.0, new Date(30,Month.November,2004));

      bond2.setPricingEngine(bondEngine);

      final double cachedPrice2 = 100.334149;

      price = bond2.getCleanPrice();
      if (Math.abs(price-cachedPrice2) > tolerance) {
          fail("failed to reproduce cached price:\n"
                     + "    calculated: " + price + "\n"
                     + "    expected:   " + cachedPrice2 + "\n"
                     + "    error:      " + (price-cachedPrice2));
      }

      // stub date

      final Schedule sch3 = new Schedule(new Date(30,Month.November,2004),
                    new Date(30,Month.March,2009), new Period(Frequency.Semiannual),
                    new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                    BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
                    DateGeneration.Rule.Backward, false,
                    new Date(), new Date(30,Month.November,2008));

      final FixedRateBond bond3 = new FixedRateBond(settlementDays, faceAmount, sch3,
                            couponRates, new ActualActual(ActualActual.Convention.ISMA),
                            BusinessDayConvention.ModifiedFollowing,
                            100.0, new Date(30,Month.November,2004));

      bond3.setPricingEngine(bondEngine);
View Full Code Here

                                                                                                                                                                                        new Date(30,Month.January,2000), new Date(30,Month.June,2000),
                                                                                                                                                                                        0.41530054644)
        };

        for (int i=0; i<testCases.length-1; i++) {
            final ActualActual dayCounter =  new ActualActual(testCases[i].convention);
            final Date d1 = testCases[i].start;
            final Date d2 = testCases[i].end;
            final Date rd1 = testCases[i].refStart;
            final Date rd2 = testCases[i].refEnd;

            QL.info(testCases[i].toString());

            /*@Time*/ final double  calculated = dayCounter.yearFraction(d1, d2, rd1, rd2);

            if (abs(calculated-testCases[i].result) > 1.0e-10) {
                final String period = "period: " + d1 + " to " + d2;
                String refPeriod = "";
                if (testCases[i].convention == ActualActual.Convention.ISMA) {
                    refPeriod = "referencePeriod: " + rd1 + " to " + rd2;
                }
                fail(dayCounter.name() + ":\n"
                        + period + "\n"
                        + refPeriod + "\n"
                        + "    calculated: " + calculated + "\n"
                        + "    expected:   " + testCases[i].result);
            }
View Full Code Here

                            quoteHandle.get(i),
                            settlementDays,
                            100.0,
                            schedule,
                            new double[]{ couponRates[i] },
                            new ActualActual(ActualActual.Convention.Bond),
                            BusinessDayConvention.Unadjusted,
                            redemption,
                            issueDates[i]);

            bondsHelpers.add(bondHelper);
        }

        /*********************
         ** CURVE BUILDING **
         *********************/

        // Any DayCounter would be fine.
        // ActualActual::ISDA ensures that 30 years is 30.0
        final DayCounter termStructureDayCounter = new ActualActual(ActualActual.Convention.ISDA);

        final double tolerance = 1.0e-15;

        // A depo-bond curve
        final List<RateHelper> bondInstruments = new ArrayList<RateHelper>();

        // Adding the ZC bonds to the curve for the short end
        bondInstruments.add(zc3m);
        bondInstruments.add(zc6m);
        bondInstruments.add(zc1y);

        // Adding the Fixed rate bonds to the curve for the long end
        for (int i = 0; i < numberOfBonds; i++) {
            bondInstruments.add(bondsHelpers.get(i));
        }
        final RateHelper[] instruments1 = new RateHelper[bondInstruments.size()];
        bondInstruments.toArray(instruments1);
        final Handle[] jumps1 = new Handle[0];
        final Date[] jumpDates1 = new Date[0];
        final double tolerance1 = 1.0e-15;
        final LogLinear interpolator = null;
        final IterativeBootstrap bootstrap = null;
       
        final YieldTermStructure  bondDiscountingTermStructur =
                 new PiecewiseYieldCurve<Discount,LogLinear,IterativeBootstrap>(
                     Discount.class, LogLinear.class, IterativeBootstrap.class,
                     settlementDate,
                     instruments1,
                     termStructureDayCounter,
                     jumps1,
                     jumpDates1,
                     tolerance1,
                     interpolator,
                     bootstrap){/* anonymous */};

        // Building of the Libor forecasting curve
        // deposits
        final double d1wQuote = 0.043375;
        final double d1mQuote = 0.031875;
        final double d3mQuote = 0.0320375;
        final double d6mQuote = 0.03385;
        final double d9mQuote = 0.0338125;
        final double d1yQuote = 0.0335125;
        // swaps
        final double s2yQuote = 0.0295;
        final double s3yQuote = 0.0323;
        final double s5yQuote = 0.0359;
        final double s10yQuote = 0.0412;
        final double s15yQuote = 0.0433;

        /********************
         *** QUOTES ***
         ********************/

        // SimpleQuote stores a value which can be manually changed;
        // other Quote subclasses could read the value from a database
        // or some kind of data feed.

        // deposits
        final Quote d1wRate = (new SimpleQuote(d1wQuote));
        final Quote d1mRate = (new SimpleQuote(d1mQuote));
        final Quote d3mRate = (new SimpleQuote(d3mQuote));
        final Quote d6mRate = (new SimpleQuote(d6mQuote));
        final Quote d9mRate = (new SimpleQuote(d9mQuote));
        final Quote d1yRate = (new SimpleQuote(d1yQuote));
        // swaps
        final Quote s2yRate = (new SimpleQuote(s2yQuote));
        final Quote s3yRate = (new SimpleQuote(s3yQuote));
        final Quote s5yRate = (new SimpleQuote(s5yQuote));
        final Quote s10yRate = (new SimpleQuote(s10yQuote));
        final Quote s15yRate = (new SimpleQuote(s15yQuote));

        /*********************
         *** RATE HELPERS ***
         *********************/

        // RateHelpers are built from the above quotes together with
        // other instrument dependant infos. Quotes are passed in
        // relinkable handles which could be relinked to some other
        // data source later.

        // deposits
        final DayCounter depositDayCounter = new Actual360();

        final RateHelper d1w = new DepositRateHelper(
                  new Handle<Quote>(d1wRate),
                  new Period(1, TimeUnit.Weeks),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d1m = new DepositRateHelper(
                  new Handle<Quote>(d1mRate),
                  new Period(1, TimeUnit.Months),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d3m = new DepositRateHelper(
                  new Handle<Quote>(d3mRate),
                  new Period(3, TimeUnit.Months),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d6m = new DepositRateHelper(
                  new Handle<Quote>(d6mRate),
                  new Period(6, TimeUnit.Months),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d9m = new DepositRateHelper(
                new Handle<Quote>(d9mRate),
                new Period(9, TimeUnit.Months),
                fixingDays, calendar,
                BusinessDayConvention.ModifiedFollowing,
                true, depositDayCounter);
        final RateHelper d1y = new DepositRateHelper(
                new Handle<Quote>(d1yRate),
                new Period(1, TimeUnit.Years),
                fixingDays, calendar,
                BusinessDayConvention.ModifiedFollowing,
                true, depositDayCounter);

        // setup swaps
        final Frequency swFixedLegFrequency = Frequency.Annual;
        final BusinessDayConvention swFixedLegConvention = BusinessDayConvention.Unadjusted;
        final DayCounter swFixedLegDayCounter = new Thirty360(Convention.European);
        final IborIndex  swFloatingLegIndex = new Euribor6M(new Handle<YieldTermStructure>());

        // TODO and FIXME: not sure whether the class stuff works properly
        // final IborIndex swFloatingLegIndex = Euribor.getEuribor6M(new Handle<YieldTermStructure>(YieldTermStructure.class)); //FIXME::RG::Handle
//        final YieldTermStructure nullYieldTermStructure = new AbstractYieldTermStructure() {
//            @Override
//            protected double discountImpl(final double t) {
//                throw new UnsupportedOperationException();
//            }
//            @Override
//            public Date maxDate() {
//                throw new UnsupportedOperationException();
//            }
//        };
//        final IborIndex swFloatingLegIndex = new Euribor6M(new Handle<YieldTermStructure>(nullYieldTermStructure));


        final Period forwardStart = new Period(1, TimeUnit.Days);
       
        final RateHelper s2y = new SwapRateHelper(
              new Handle<Quote>(s2yRate),
              new Period(2, TimeUnit.Years),
              calendar,
              swFixedLegFrequency,
              swFixedLegConvention,
              swFixedLegDayCounter,
              swFloatingLegIndex,
              new Handle<Quote>(),
              forwardStart);
         final RateHelper s3y = new SwapRateHelper(
                 new Handle<Quote>(s3yRate),
                 new Period(3, TimeUnit.Years),
                 calendar,
                 swFixedLegFrequency,
                 swFixedLegConvention,
                 swFixedLegDayCounter,             
                 swFloatingLegIndex,
                 new Handle<Quote>(),
                 forwardStart);
        final RateHelper  s5y = new SwapRateHelper(
                new Handle<Quote>(s5yRate),
                new Period(5, TimeUnit.Years),
                calendar,
                swFixedLegFrequency,
                swFixedLegConvention,
                swFixedLegDayCounter,
                swFloatingLegIndex,
                new Handle<Quote>(),
                forwardStart);
        final RateHelper s10y = new SwapRateHelper(
                new Handle<Quote>(s10yRate),
                new Period(10, TimeUnit.Years),
                calendar,
                swFixedLegFrequency,
                swFixedLegConvention,
                swFixedLegDayCounter,
                swFloatingLegIndex,
                new Handle<Quote>(),
                forwardStart);
        final RateHelper  s15y = new SwapRateHelper(
                new Handle<Quote>(s15yRate),
                new Period(15, TimeUnit.Years),
                calendar,
                swFixedLegFrequency,
                swFixedLegConvention,
                swFixedLegDayCounter,
                swFloatingLegIndex,
                new Handle<Quote>(),
                forwardStart);

         /*********************
         ** CURVE BUILDING **
         *********************/
       
         // Any DayCounter would be fine.
         // ActualActual::ISDA ensures that 30 years is 30.0
       
         // A depo-swap curve
         final List<RateHelper> depoSwapInstruments = new ArrayList<RateHelper>();
         depoSwapInstruments.add(d1w);
         depoSwapInstruments.add(d1m);
         depoSwapInstruments.add(d3m);
         depoSwapInstruments.add(d6m);
         depoSwapInstruments.add(d9m);
         depoSwapInstruments.add(d1y);
         depoSwapInstruments.add(s2y);
         depoSwapInstruments.add(s3y);
         depoSwapInstruments.add(s5y);
         depoSwapInstruments.add(s10y);
         depoSwapInstruments.add(s15y);
        
         final RateHelper[] instruments = new RateHelper[depoSwapInstruments.size()];
         depoSwapInstruments.toArray(instruments);
         final Handle[] jumps= new Handle[0];//]<Quote>[]) new ArrayList<Handle<Quote>>().toArray();
         final Date[] jumpDates = new Date[0];// new ArrayList<Date>().toArray();
        
         final YieldTermStructure  depoSwapTermStructure =
             new PiecewiseYieldCurve<Discount,LogLinear,IterativeBootstrap>(
                 Discount.class, LogLinear.class, IterativeBootstrap.class,
                 settlementDate,
                 instruments,
                 termStructureDayCounter,
                 jumps,
                 jumpDates,
                 tolerance,
            interpolator,/*Hack*/
             bootstrap /*Hack*/){/* anonymous */};

         // Term structures that will be used for pricing:
         // the one used for discounting cash flows
         final RelinkableHandle<YieldTermStructure> discountingTermStructure = new RelinkableHandle<YieldTermStructure>();
         // the one used for forward rate forecasting
         final RelinkableHandle<YieldTermStructure> forecastingTermStructure = new RelinkableHandle<YieldTermStructure>();
       
         /*********************
         * BONDS TO BE PRICED *
         **********************/
       
         // Common data
         final double faceAmount = 100;
       
         // Pricing engine
        final PricingEngine  bondEngine = new DiscountingBondEngine(discountingTermStructure);
       
         // Zero coupon bond
         final ZeroCouponBond zeroCouponBond = new ZeroCouponBond(
                           settlementDays,
                           new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                           faceAmount,
                           new Date(15,Month.August,2013),
                           BusinessDayConvention.Following,
                           116.92,
                           new Date(15,Month.August,2003));
       
         zeroCouponBond.setPricingEngine(bondEngine);
       
         // Fixed 4.5% US Treasury Note
         final Schedule fixedBondSchedule = new Schedule(
                     new Date(15, Month.May, 2007),
                     new Date(15,Month.May,2017),
                     new Period(Frequency.Semiannual),
                     new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                     BusinessDayConvention.Unadjusted,
                     BusinessDayConvention.Unadjusted,
                     DateGeneration.Rule.Backward, false);
       
         final FixedRateBond fixedRateBond = new FixedRateBond(
                     settlementDays,
                     faceAmount,
                     fixedBondSchedule,
                     new double[]{0.045},
                     new ActualActual(ActualActual.Convention.Bond),
                     BusinessDayConvention.ModifiedFollowing,
                     100.0,
                     new Date(15, Month.May, 2007));
       
         fixedRateBond.setPricingEngine(bondEngine);
View Full Code Here

         **  CURVE BUILDING **
         *********************/

        // Any DayCounter would be fine.
        // ActualActual::ISDA ensures that 30 years is 30.0
        final DayCounter termStructureDayCounter = new ActualActual(Convention.ISDA);

        final double tolerance = 1.0e-15;

        //A FRA curve

View Full Code Here

   
    public BMAIndex() {
      this(new Handle<YieldTermStructure>());
    }
    public BMAIndex(final Handle<YieldTermStructure> h) {
        super("BMA", new Period(1,TimeUnit.Weeks), 1, new USDCurrency(), new UnitedStates(UnitedStates.Market.NYSE), new ActualActual(ActualActual.Convention.ISDA));

        this.termStructure = h;
        if (termStructure != null) {
          termStructure.addObserver(this);
        }
View Full Code Here

                2, // settlement days
                new JPYCurrency(),
                new Target(),
                new Period(6,TimeUnit.Months),
                BusinessDayConvention.ModifiedFollowing,
                new ActualActual(ActualActual.Convention.ISDA),
                new JPYLibor(new Period(6,TimeUnit.Months), h)
                   
                );
        }
View Full Code Here

                2, // settlement days
                new JPYCurrency(),
                new Target(),
                new Period(6,TimeUnit.Months),
                BusinessDayConvention.ModifiedFollowing,
                new ActualActual(ActualActual.Convention.ISDA),
                new JPYLibor(new Period(6,TimeUnit.Months), h)
                   
                );
        }
View Full Code Here

      settlement = calendar.advance(today,settlementDays,TimeUnit.Days);
      fixedLegConvention = BusinessDayConvention.Unadjusted;
      fixedLegFrequency = Frequency.Annual;
      fixedLegDayCounter = new org.jquantlib.daycounters.Thirty360();
      bondSettlementDays = 3;
      bondDayCounter = new ActualActual(Convention.Bond);
      bondConvention = BusinessDayConvention.Following;
      bondRedemption = 100.0;
      bmaFrequency = Frequency.Quarterly;
      bmaConvention = BusinessDayConvention.Following;
      bmaDayCounter = new ActualActual(Convention.Bond);

      deposits = depositData.length;
            fras = fraData.length;
            swaps = swapData.length;
            bonds = bondData.length;
View Full Code Here

                                                                                                                                                                                        new Date(30,Month.January,2000), new Date(30,Month.June,2000),
                                                                                                                                                                                        0.41530054644)
        };

        for (int i=0; i<testCases.length-1; i++) {
            final ActualActual dayCounter =  new ActualActual(testCases[i].convention);
            final Date d1 = testCases[i].start;
            final Date d2 = testCases[i].end;
            final Date rd1 = testCases[i].refStart;
            final Date rd2 = testCases[i].refEnd;

            QL.info(testCases[i].toString());

            /*@Time*/ final double  calculated = dayCounter.yearFraction(d1, d2, rd1, rd2);

            if (abs(calculated-testCases[i].result) > 1.0e-10) {
                final String period = "period: " + d1 + " to " + d2;
                String refPeriod = "";
                if (testCases[i].convention == ActualActual.Convention.ISMA) {
                    refPeriod = "referencePeriod: " + rd1 + " to " + rd2;
                }
                fail(dayCounter.name() + ":\n"
                        + period + "\n"
                        + refPeriod + "\n"
                        + "    calculated: " + calculated + "\n"
                        + "    expected:   " + testCases[i].result);
            }
View Full Code Here

TOP

Related Classes of org.jquantlib.daycounters.ActualActual$ImplISMA

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.