Package org.jquantlib.time.calendars

Examples of org.jquantlib.time.calendars.NullCalendar


            }
        }


        // calendar needed for endOfMonth adjustment
        final Calendar nullCalendar = new NullCalendar();
        int periods = 1;
        Date seed, exitDate;
        switch (rule_) {

          case Zero:
            tenor_ = new Period(0, TimeUnit.Days);
            dates_.add(effectiveDate);
            dates_.add(terminationDate);
            isRegular_.add(new Boolean(true));
            break;

          case Backward:

            dates_.add(terminationDate);

            seed = terminationDate.clone();
            if ( nextToLastDate != null && !nextToLastDate.isNull() ) {
                dates_.add(0, nextToLastDate);
                final Date temp = nullCalendar.advance(seed, tenor_.mul(periods).negative(), convention, endOfMonth);
                if (temp.ne(nextToLastDate)) {
                    isRegular_.add(0, new Boolean(false));
                } else {
                    isRegular_.add(0, new Boolean(true));
                }
                seed = nextToLastDate.clone();
            }

            exitDate = effectiveDate.clone();
            if ( firstDate != null && !firstDate.isNull() ) {
                exitDate = firstDate.clone();
            }

            while (true) {
                final Date temp = nullCalendar.advance(seed, tenor_.mul(periods).negative(), convention, endOfMonth);
                if (temp .lt(exitDate)) {
                    break;
                } else {
                    dates_.add(0, temp);
                    isRegular_.add(0, new Boolean(true));
                    ++periods;
                }
            }

            if (endOfMonth && calendar.isEndOfMonth(seed)) {
                convention = BusinessDayConvention.Preceding;
            }

            if (calendar.adjust(dates_.get(0),convention).ne(
                calendar.adjust(effectiveDate, convention))) {
                dates_.add(0, effectiveDate);
                isRegular_.add(0, new Boolean(false));
            }
            break;

          case Twentieth:
          case TwentiethIMM:
          case ThirdWednesday:
            QL.require(!endOfMonth,
                       "endOfMonth convention incompatible with " + rule_ +
                       " date generation rule"); // TODO: message
          // fall through
          case Forward:

            dates_.add(effectiveDate);

            seed = effectiveDate.clone();

            if (firstDate != null && !firstDate.isNull() ) {
                dates_.add(firstDate);
                final Date temp = nullCalendar.advance(seed, tenor_.mul(periods), convention, endOfMonth);
                if (temp.ne(firstDate) ) {
                    isRegular_.add(new Boolean(false));
                } else {
                    isRegular_.add(new Boolean(true));
                }
                seed = firstDate.clone();
            } else if (rule_ == DateGeneration.Rule.Twentieth ||
                       rule_ == DateGeneration.Rule.TwentiethIMM) {
                final Date next20th = nextTwentieth(effectiveDate, rule_);
                if (next20th.ne(effectiveDate)) {
                    dates_.add(next20th);
                    isRegular_.add(new Boolean(false));
                    seed = next20th.clone();
                }
            }

            exitDate = terminationDate.clone();
            if ( nextToLastDate != null && !nextToLastDate.isNull() ) {
                exitDate = nextToLastDate.clone();
            }

            while (true) {
                final Date temp = nullCalendar.advance(seed, tenor_.mul(periods), convention, endOfMonth);
                if ( temp.gt(exitDate) ) {
                    break;
                } else {
                    dates_.add(temp);
                    isRegular_.add(new Boolean(true));
View Full Code Here


    @Override
    /** Inflation indices do not have fixing calendars.  An inflation index value is valid for every day (including
     *  weekends) of a calendar period.  I.e. it uses the NullCalendar as its fixing calendar.
     **/
    public Calendar fixingCalendar() {
        return new NullCalendar();
    }
View Full Code Here

            //bootstrap the yield/vol curves
            final DayCounter dayCounter = new Actual365Fixed();
            final Handle<Quote> h1 = new Handle<Quote>(riskFreeRate.currentLink());
            final Handle<Quote> h2 = new Handle<Quote>(volatility.currentLink());
            final Handle<YieldTermStructure> flatRate = new Handle<YieldTermStructure>(new FlatForward(0, new NullCalendar(), h1, dayCounter));
            final Handle<BlackConstantVol> flatVol = new Handle<BlackConstantVol>(new BlackConstantVol(0, new NullCalendar(), h2, dayCounter));

            //instantiate the option
            final Exercise exercise = new EuropeanExercise(maturity);
            final Payoff payoff = new PlainVanillaPayoff(type, strike);
View Full Code Here

          final Period lag,
        final Frequency frequency,
        final @Rate double baseRate,
        final Handle<YieldTermStructure> yTS) {

      this(referenceDate, lag, frequency, baseRate, yTS, new NullCalendar() ,new Actual365Fixed());
    }
View Full Code Here

    public CapVolatilityStructure(final DayCounter dc) {
        super(dc == null ? new Actual365Fixed() : dc);
    }

    public CapVolatilityStructure(final Date referenceDate, final Calendar cal, final DayCounter dc) {
        super(referenceDate, cal == null ? new NullCalendar() : cal, dc == null ? new Actual365Fixed() : dc);
    }
View Full Code Here

    public CapVolatilityStructure(final Date referenceDate, final Calendar cal, final DayCounter dc) {
        super(referenceDate, cal == null ? new NullCalendar() : cal, dc == null ? new Actual365Fixed() : dc);
    }

    public CapVolatilityStructure(final int settlementDays, final Calendar cal, final DayCounter dc) {
        super(settlementDays, cal == null ? new NullCalendar() : cal, dc == null ? new Actual365Fixed() : dc);
    }
View Full Code Here

    static public YieldTermStructure flatRate(final Date today, final/* @Rate */double forward, final DayCounter dc) {
        return flatRate(today, new SimpleQuote(forward), dc);
    }

    static public YieldTermStructure flatRate(final Quote forward, final DayCounter dc) {
        return new FlatForward(0, new NullCalendar(), new Handle<Quote>(forward), dc);
    }
View Full Code Here

    static public YieldTermStructure flatRate(final/* @Rate */double forward, final DayCounter dc) {
        return flatRate(new SimpleQuote(forward), dc);
    }

    static public BlackVolTermStructure flatVol(final Date today, final Quote vol, final DayCounter dc) {
        return new BlackConstantVol(today, new NullCalendar(), new Handle<Quote>(vol), dc);
    }
View Full Code Here

    static public BlackVolTermStructure flatVol(final Date today, final/* @Volatility */double vol, final DayCounter dc) {
        return flatVol(today, new SimpleQuote(vol), dc);
    }

    static public BlackVolTermStructure flatVol(final Quote vol, final DayCounter dc) {
        return new BlackConstantVol(0, new NullCalendar(), new Handle<Quote>(vol), dc);
    }
View Full Code Here

        QL.info("::::: " + this.getClass().getSimpleName() + " :::::");
    }

    @Test
    public void testAdvance() {
        final NullCalendar nullCalendar = new NullCalendar();
        final Date d = new Date(11, Month.October, 2009);
        final Date dCopy = d.clone();
        assertEquals(dCopy, d);
        final Date advancedDate = nullCalendar.advance(d, new Period(3, TimeUnit.Months));
        assertEquals(dCopy, d);
        assertFalse(advancedDate.equals(d));
    }
View Full Code Here

TOP

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

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.