Package org.jquantlib.time

Examples of org.jquantlib.time.Date


                expected = e;
            }
        }

        final Entry[] entries = {
                new Entry( new Date(28, 5, 2009), new Date(28, 5, 2009) ),
                new Entry( new Date(29, 5, 2009), new Date(29, 5, 2009) ),
                new Entry( new Date(30, 5, 2009), new Date(29, 5, 2009) ),
                new Entry( new Date(31, 5, 2009), new Date(29, 5, 2009) ),
                new Entry( new Date( 1, 6, 2009), new Date( 1, 6, 2009) ),
                new Entry( new Date( 2, 6, 2009), new Date( 2, 6, 2009) ),
                new Entry( new Date( 3, 6, 2009), new Date( 3, 6, 2009) ),
                // ---
                new Entry( new Date(23, 1, 1973), new Date(23, 1, 1973) ),
                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


                expected = e;
            }
        }

        final Entry[] entries = {
                new Entry( new Date(28, 5, 2009), new Date(28, 5, 2009) ),
                new Entry( new Date(29, 5, 2009), new Date(29, 5, 2009) ),
                new Entry( new Date(30, 5, 2009), new Date(29, 5, 2009) ),
                new Entry( new Date(31, 5, 2009), new Date(29, 5, 2009) ),
                new Entry( new Date( 1, 6, 2009), new Date( 1, 6, 2009) ),
                new Entry( new Date( 2, 6, 2009), new Date( 2, 6, 2009) ),
                new Entry( new Date( 3, 6, 2009), new Date( 3, 6, 2009) ),
                // ---
                new Entry( new Date(23, 1, 1973), new Date(23, 1, 1973) ),
                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

    }

    public void calculate () {

        final int nInsts = instruments.length;
        final Date dates[] = ts.dates();
        /*@Time*/ final double times[] = ts.times();
        double data[] = ts.data();

        // ensure rate helpers are sorted
        Arrays.sort(instruments, new BootstrapHelperSorter());

        // check that there is no instruments with the same maturity
        for (int i=1; i<nInsts; ++i) {
            final Date m1 = instruments[i-1].latestDate();
            final Date m2 = instruments[i].latestDate();
            QL.require(m1 != m2, "two instruments have the same maturity");
        }

        // check that there is no instruments with invalid quote
        for (int i=0; i<nInsts; ++i) {
View Full Code Here

        final YieldTermStructure localTermStructure = new FlatForward(settlementDays, new NullCalendar(), 0.03, new Actual360());

        final int days[] = { 10, 30, 60, 120, 360, 720 };
        /*@DiscountFactor*/ final double[] expected = new /*@DiscountFactor*/ double[days.length];

        final Date today = new Settings().evaluationDate();

        for (int i=0; i<days.length; i++) {
            final Date anotherDay = today.add(days[i]);
            expected[i] = localTermStructure.discount(anotherDay);
        }

        final Date nextMonth = today.add(30);
        new Settings().setEvaluationDate(nextMonth);
        /*@DiscountFactor*/ final double[] calculated = new /*@DiscountFactor*/ double[days.length];

        for (int i=0; i<days.length; i++) {
            final Date anotherDay = nextMonth.add(days[i]);
            calculated[i] = localTermStructure.discount(anotherDay);
        }

        for (int i=0; i<days.length; i++) {
            if (!Closeness.isClose(expected[i],calculated[i])) {
View Full Code Here

     */
    @Test
    public void testImpliedObs() {
        QL.info("Testing observability of implied term structure...");

        final Date today = new Settings().evaluationDate();
        final Date newToday = today.add(Period.ONE_YEAR_FORWARD.mul(3));
        final Date newSettlement = new Target().advance(newToday, settlementDays, TimeUnit.Days);

        //FIXME:: Fix RelinkableHandle. The initialization of "h" should be:
        //
        //        final RelinkableHandle<YieldTermStructure> h = new RelinkableHandle<YieldTermStructure>() { /* anonymous */ };
        //
View Full Code Here

            throw new LibraryException("unknown compounding convention"); // QA:[RG]::verified // TODO: message
        }
    }

    public final double compoundFactor(final Date d1, final Date d2) {
      return compoundFactor(d1, d2, new Date(), new Date());
    }
View Full Code Here

     * @param d2 is the end date
     *
     * @category discount/compound factor calculations
     */
    public final/* @DiscountFactor */double discountFactor(final Date d1, final Date d2) {
        return discountFactor(d1, d2, new Date());
    }
View Full Code Here

     * @param refStart
     *
     * @category discount/compound factor calculations
     */
    public final/* @DiscountFactor */double discountFactor(final Date d1, final Date d2, final Date refStart) {
        return discountFactor(d1, d2, refStart, new Date());
    }
View Full Code Here

    // Fixing Date and Value Date will be two London business days
    // after the Fixing Date, or if that day is not both a London
    // business day and a business day in the principal financial centre
    // of the currency concerned, the next following day which is a
    // business day in both centres shall be the Value Date.
    final Date d = fixingCalendar().advance(fixingDate, fixingDays(), TimeUnit.Days);
    return jointCalendar_.adjust(d);
  }
View Full Code Here


    public void calculate () {

        final int n = instruments.length;
        Date dates[] = ts.dates();
        /*@Time*/ double times[] = ts.times();
        double data[] = ts.data();

        // ensure rate helpers are sorted
        Arrays.sort(instruments, new BootstrapHelperSorter());

        // check that there is no instruments with the same maturity
        for (int i=1; i<n; ++i) {
            final Date m1 = instruments[i-1].latestDate();
            final Date m2 = instruments[i].latestDate();
            QL.require(m1 != m2, "two instruments have the same maturity");
        }

        // check that there is no instruments with invalid quote
        for (int i=0; i<n; ++i) {
View Full Code Here

TOP

Related Classes of org.jquantlib.time.Date

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.