Package org.jquantlib.time.calendars

Examples of org.jquantlib.time.calendars.UnitedStates


      // 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),
View Full Code Here


      final double tolerance = 1.0e-6;

      // plain

      final ZeroCouponBond bond1 = new ZeroCouponBond(settlementDays,
                           new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                           faceAmount,
                           new Date(30,Month.November,2008),
                           BusinessDayConvention.ModifiedFollowing,
                           100.0, new Date(30,Month.November,2004));

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

      final double cachedPrice1 = 88.551726;

      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));
      }

      final ZeroCouponBond bond2 = new ZeroCouponBond(settlementDays,
                           new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                           faceAmount,
                           new Date(30,Month.November,2007),
                           BusinessDayConvention.ModifiedFollowing,
                           100.0, new Date(30,Month.November,2004));

      bond2.setPricingEngine(bondEngine);

      final double cachedPrice2 = 91.278949;

      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));
      }

      final ZeroCouponBond bond3 = new ZeroCouponBond(settlementDays,
                           new UnitedStates(UnitedStates.Market.GOVERNMENTBOND),
                           faceAmount,
                           new Date(30,Month.November,2006),
                           BusinessDayConvention.ModifiedFollowing,
                           100.0, new Date(30,Month.November,2004));
View Full Code Here

      // plain

      final Schedule sch = new Schedule(new Date(30,Month.November,2004),
                   new Date(30,Month.November,2008), new Period(Frequency.Semiannual),
                   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,
View Full Code Here

                new Entry( new Date(24, 1, 1973), new Date(24, 1, 1973) ),
                new Entry( new Date(25, 1, 1973), new Date(26, 1, 1973) ),
                new Entry( new Date(26, 1, 1973), new Date(26, 1, 1973) ),
            };

        final Calendar unitedStatesCalendar = new UnitedStates(UnitedStates.Market.NYSE);
        for (final Entry entry : entries) {
            final Date result = unitedStatesCalendar.adjust(entry.date, BusinessDayConvention.ModifiedFollowing);
            System.out.println("adjusted is " + result.isoDate() + "  ::  expected is " + entry.expected.isoDate());
            assertEquals(result, entry.expected);
        }
    }
View Full Code Here

                new Entry( new Date(24, 1, 1973), new Date(24, 1, 1973) ),
                new Entry( new Date(25, 1, 1973), new Date(24, 1, 1973) ),
                new Entry( new Date(26, 1, 1973), new Date(26, 1, 1973) ),
            };

        final Calendar unitedStatesCalendar = new UnitedStates(UnitedStates.Market.NYSE);
        for (final Entry entry : entries) {
            final Date result = unitedStatesCalendar.adjust(entry.date, BusinessDayConvention.ModifiedPreceding);
            System.out.println("adjusted is " + result.isoDate() + "  ::  expected is " + entry.expected.isoDate());
            assertEquals(result, entry.expected);
        }
    }
View Full Code Here

        expectedHol.add(new Date(24, December, year));
         // Special closings for 2004 - Reagan's death and day after thanksgiving
        expectedHol.add(new Date(11, June, year));

        // Call the Holiday Check
        final Calendar nyse = new UnitedStates(UnitedStates.Market.NYSE);
        final CalendarUtil cbt = new CalendarUtil();
        cbt.checkHolidayList(expectedHol, nyse, year);
    }
View Full Code Here

        // Christmas, December 25th (moved to Monday if Sunday or Friday if Saturday)
        //expectedHol.add(new Date(25,DECEMBER,year));
        expectedHol.add(new Date(26, December, year));

        // Call the Holiday Check
        final Calendar nyse = new UnitedStates(UnitedStates.Market.NYSE);
        final CalendarUtil cbt = new CalendarUtil();
        cbt.checkHolidayList(expectedHol, nyse, year);
    }
View Full Code Here

        // Nov. 7 was an election day, but was not a holiday
        // Christmas, December 25th (moved to Monday if Sunday or Friday if Saturday)
        expectedHol.add(new Date(25, December, year));

        // Call the Holiday Check
        final Calendar nyse = new UnitedStates(UnitedStates.Market.NYSE);
        final CalendarUtil cbt = new CalendarUtil();
        cbt.checkHolidayList(expectedHol, nyse, year);
    }
View Full Code Here

        expectedHol.add(new Date(22, November, year));
        // Christmas, December 25th (moved to Monday if Sunday or Friday if Saturday)
        expectedHol.add(new Date(25, December, year));

        // Call the Holiday Check
        final Calendar nyse = new UnitedStates(UnitedStates.Market.NYSE);
        final CalendarUtil cbt = new CalendarUtil();
        cbt.checkHolidayList(expectedHol, nyse, year);
    }
View Full Code Here

        expectedHol.add(new Date(27, November, year));
        // Christmas, December 25th (moved to Monday if Sunday or Friday if Saturday)
        expectedHol.add(new Date(25, December, year));

        // Call the Holiday Check
        final Calendar nyse = new UnitedStates(UnitedStates.Market.NYSE);
        final CalendarUtil cbt = new CalendarUtil();
        cbt.checkHolidayList(expectedHol, nyse, year);
    }
View Full Code Here

TOP

Related Classes of org.jquantlib.time.calendars.UnitedStates

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.