Package org.jquantlib.time.calendars

Examples of org.jquantlib.time.calendars.UnitedStates$NyseImpl


        clock.startClock();

        System.out.println("//==========================================FlatForward termstructure===================");
        final SimpleQuote interestRateQuote = new SimpleQuote(0.3);
        final RelinkableHandle<Quote>  handleToInterestRateQuote = new RelinkableHandle<Quote>(interestRateQuote);
        final YieldTermStructure flatforward = new FlatForward(2,new UnitedStates(Market.NYSE),handleToInterestRateQuote,new Actual365Fixed(), Compounding.Continuous,Frequency.Daily);

        final Date today  = Date.todaysDate();
        final Date date10 = today.clone().addAssign(10);
        final Date date20 = today.clone().addAssign(20);
        final Date date30 = today.clone().addAssign(30);
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

      System.out.println("Testing joint calendars...");

        Calendar c1 = new Target(),
                 c2 = new UnitedKingdom(),
                 c3 = new UnitedStates(UnitedStates.Market.NYSE),
                 c4 = new Japan();

        Calendar c12h = new JointCalendar(c1,c2,JointCalendarRule.JoinHolidays),
                 c12b = new JointCalendar(c1,c2,JointCalendarRule.JoinBusinessDays),
                 c123h = new JointCalendar(c1,c2,c3,JointCalendarRule.JoinHolidays),
                 c123b = new JointCalendar(c1,c2,c3,JointCalendarRule.JoinBusinessDays),
                 c1234h = new JointCalendar(c1,c2,c3,c4,JointCalendarRule.JoinHolidays),
                 c1234b = new JointCalendar(c1,c2,c3,c4,JointCalendarRule.JoinBusinessDays);

        // test one year, starting today
        Date firstDate = Date.todaysDate(),
             endDate = firstDate.add(new Period(1, TimeUnit.Years));

        for (Date d = firstDate; d.lt(endDate); d.inc()) {

            boolean b1 = c1.isBusinessDay(d),
                 b2 = c2.isBusinessDay(d),
                 b3 = c3.isBusinessDay(d),
                 b4 = c4.isBusinessDay(d);

            if ((b1 && b2) != c12h.isBusinessDay(d))
              Assert.fail("At date " + d + ":\n"
                           + "    inconsistency between joint calendar "
View Full Code Here

      // 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.cleanPrice();
      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.cleanPrice();
      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.cleanPrice();
      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.cleanPrice();
      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

      // 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.ModifiedFollowing,
                    BusinessDayConvention.ModifiedFollowing,
                    DateGeneration.Rule.Backward, false);

      final FloatingRateBond bond1 = new FloatingRateBond(settlementDays, vars.faceAmount, sch,
View Full Code Here

TOP

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

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.