Package org.jquantlib.time.calendars

Examples of org.jquantlib.time.calendars.Target$Impl


        final int settlementDays = 3;
        final int length = 5;
        final double redemption = 100.0;
        final double conversionRatio = redemption/underlying;

        final Calendar calendar = new Target();
        //adjust today to the next business day...
        final Date today = calendar.adjust(Date.todaysDate());
        QL.info("Today's date is adjusted by the default business day convention is: " + today.shortDate());
        // set the evaluation date to the adjusted today's date
        new Settings().setEvaluationDate(today);
        QL.info("Set the global evaluation date to the adjusted today's date: " + today.shortDate());

        //Set up settlement, exercise and issue dates
        final Date settlementDate = calendar.advance(today, settlementDays, TimeUnit.Days);
        QL.info("SettlementDate is: " + settlementDate.shortDate());
        QL.info("Check that we haven't messed up with references --> today's date is still: " + today.shortDate());
        final Date exerciseDate = calendar.advance(settlementDate, length, TimeUnit.Years);
        QL.info("Excercise date is: " + exerciseDate.shortDate());
        final Date issueDate = calendar.advance(exerciseDate, -length, TimeUnit.Years);
        QL.info("Issue date is: " + issueDate.shortDate());

        //Fix business day convention and compounding?? frequency
        final BusinessDayConvention convention = BusinessDayConvention.ModifiedFollowing;
        final Frequency frequency = Frequency.Annual;
View Full Code Here


    public DailyTenorEuribor(final int settlementDays, final Handle<YieldTermStructure> h) {
        super("Euribor",
                new Period(1,TimeUnit.Days),
                settlementDays, // settlement days
                new EURCurrency(),
                new Target(),
                euriborConvention(new Period(1,TimeUnit.Days)),
                euriborEOM(new Period(1,TimeUnit.Days)),
                new Actual360(),
                h);
      }
View Full Code Here

    public DailyTenorEuribor365(final int settlementDays, final Handle<YieldTermStructure> h) {
        super("Euribor",
                new Period(1,TimeUnit.Days),
                settlementDays, // settlement days
                new EURCurrency(),
                new Target(),
                euriborConvention(new Period(1,TimeUnit.Days)),
                euriborEOM(new Period(1,TimeUnit.Days)),
                new Actual365Fixed(),
                h);
      }
View Full Code Here

        else throw new IllegalArgumentException("Invalid option type");

        Exercise europeanExercise = new EuropeanExercise(maturityDate);
        Payoff payoff = new PlainVanillaPayoff(type, strike);

        final Calendar calendar = new Target();
        Handle<Quote> underlyingH = new Handle<Quote>(new SimpleQuote(underlying));
        Handle<YieldTermStructure> flatDividendTS = new Handle<YieldTermStructure>(new FlatForward(settlementDate, dividendYield, dayCounter));
        Handle<YieldTermStructure> flatTermStructure = new Handle<YieldTermStructure>(new FlatForward(settlementDate, riskFreeRate, dayCounter));
        Handle<BlackVolTermStructure> flatVolTS = new Handle<BlackVolTermStructure>(new BlackConstantVol(settlementDate, calendar, volatility, dayCounter));
View Full Code Here

    //public IndexHistoryCleaner cleaner;

   
    public CommonVars() {
      // data
      calendar = new Target();
      settlementDays = 2;
     
      today = calendar.adjust(Date.todaysDate());
      new Settings().setEvaluationDate(today);
     
View Full Code Here

    @Test
    public void testEndOfMonth() {
        QL.info("Testing end-of-month calculation...");

        final Calendar c = new Target(); // any calendar would be OK

        Date eom;
        final Date counter = Date.minDate();
        final Date last = Date.maxDate().sub(new Period(2, TimeUnit.Months));

        while (counter.le(last)) {
            eom = c.endOfMonth(counter);
            // check that eom is eom
            if (!c.isEndOfMonth(eom)) {
                Assert.fail(String.format("%s %s %s is not the last business day in %s according to %s",
                        eom.weekday(), eom.dayOfMonth(), eom.month(), eom.year(), c.name() ));
            }
            // check that eom is in the same month as counter
            if (eom.month()!=counter.month()) {
                Assert.fail(String.format("%s is not the same month as %s", eom, counter ));
            }
View Full Code Here

    @Test
    public void testJointCalendars() {

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


    public TermStructuresTest() {
        QL.info("::::: "+this.getClass().getSimpleName()+" :::::");

        this.calendar = new Target();
        this.settlementDays = 2;
        this.termStructure = null;
        this.dummyTermStructure = null;

        //FIXME: remove comments when PiecewiseYieldCurve becomes available
View Full Code Here

    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>(YieldTermStructure.class);
        //
View Full Code Here

    }


    @Test
    public void testSchedule() {
        final Calendar calendar = new Target();
        final Period maturity = new Period(30, TimeUnit.Years);
        final Date maturityDate = startDate.add(maturity);
        final Period accPeriodTenor = new Period(6, TimeUnit.Months);
        final BusinessDayConvention modFollow = BusinessDayConvention.ModifiedFollowing;
        final DateGeneration.Rule dateRule = DateGeneration.Rule.Backward;

        final Schedule firstConstrSchedule = new Schedule(
                startDate, maturityDate, accPeriodTenor,
                calendar, modFollow, modFollow,
                dateRule, false, null, null);

        final List<Date> dates = new ArrayList<Date>();
        dates.add(startDate);
        dates.add(calendar.advance(startDate, new Period(10, TimeUnit.Weeks),modFollow));

        final Schedule secondConstrSchedule = new Schedule(dates, calendar, modFollow);

        testDateAfter(firstConstrSchedule);
        testDateAfter(secondConstrSchedule);
View Full Code Here

TOP

Related Classes of org.jquantlib.time.calendars.Target$Impl

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.