001/* 002 * ObjectLab, http://www.objectlab.co.uk/open is sponsoring the ObjectLab Kit. 003 * 004 * Based in London, we are world leaders in the design and development 005 * of bespoke applications for the securities financing markets. 006 * 007 * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a> 008 * ___ _ _ _ _ _ 009 * / _ \| |__ (_) ___ ___| |_| | __ _| |__ 010 * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \ 011 * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) | 012 * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/ 013 * |__/ 014 * 015 * www.ObjectLab.co.uk 016 * 017 * $Id$ 018 * 019 * Copyright 2006 the original author or authors. 020 * 021 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 022 * use this file except in compliance with the License. You may obtain a copy of 023 * the License at 024 * 025 * http://www.apache.org/licenses/LICENSE-2.0 026 * 027 * Unless required by applicable law or agreed to in writing, software 028 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 029 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 030 * License for the specific language governing permissions and limitations under 031 * the License. 032 */ 033package net.objectlab.kit.datecalc.common; 034 035import java.util.List; 036 037/** 038 * The IMMDates are defined as the 3rd Wednesday of March, June, September and 039 * December. 040 * 041 * @author Benoit Xhenseval 042 * @param <E> 043 * a representation of a date, typically JDK: Date, Calendar; 044 * Joda:LocalDate, YearMonthDay 045 * 046 */ 047public interface IMMDateCalculator<E> { 048 /** 049 * Checks if a given date is an official IMM Date (3rd Wednesdays of 050 * March/June/Sept/Dec. 051 * 052 * @param date 053 * @return true if that date is an IMM date. 054 */ 055 boolean isIMMDate(final E date); 056 057 /** 058 * Given a start date, it will return the next IMM Date, even if the start 059 * date is an IMM date (same as calling 060 * getNextIMMDate(IMMPeriod.QUARTERLY)). 061 * 062 * @param startDate 063 * @return the next IMMDate based on current business date. 064 */ 065 E getNextIMMDate(final E startDate); 066 067 /** 068 * Given a start date, it will return the next IMM Date based on the 069 * IMMPeriod, even if the start date is an IMM date. 070 * 071 * @param startDate 072 * @param period 073 * specify when the "next" IMM is, if quarterly then it is the 074 * conventional algorithm. 075 * @return the next IMMDate based on current date. 076 */ 077 E getNextIMMDate(final E startDate, final IMMPeriod period); 078 079 // ----------------------------------------------------------------------- 080 // 081 // ObjectLab, world leaders in the design and development of bespoke 082 // applications for the securities financing markets. 083 // www.ObjectLab.co.uk 084 // 085 // ----------------------------------------------------------------------- 086 087 /** 088 * Given a start date, it will return the previous IMM Date, even if the 089 * start date is an IMM date. 090 * 091 * @param startDate 092 * @return the previous IMMDate based on current date. 093 */ 094 E getPreviousIMMDate(final E startDate); 095 096 /** 097 * Given a start date, it will return the previous IMM Date based on the 098 * IMMPeriod, even if the start date is an IMM date. 099 * 100 * @param period 101 * specify when the "previous" IMM is, if quarterly then it is 102 * the conventional algorithm. 103 * @return the previous IMMDate based on current date. 104 */ 105 E getPreviousIMMDate(final E startDate, final IMMPeriod period); 106 107 /** 108 * Returns a list of IMM dates between 2 dates, it will exclude the start 109 * date if it is an IMM date but would include the end date if it is an IMM 110 * (same as as calling getIMMDates(start,end,IMMPeriod.QUARTERLY)). 111 * 112 * @param start 113 * start of the interval, excluded 114 * @param end 115 * end of the interval, may be included. 116 * @return list of IMM dates 117 */ 118 List<E> getIMMDates(final E start, final E end); 119 120 /** 121 * Returns a list of N IMM dates from a given date, it will exclude the start 122 * date if it is an IMM date 123 * (same as as calling getIMMDates(start,end,IMMPeriod.QUARTERLY)). 124 * 125 * @param start 126 * start of the interval, excluded 127 * @param numberOfDates 128 * number of IMM dates to return. 129 * @return list of IMM dates 130 * @since 1.4.0 131 */ 132 List<E> getNextIMMDates(final E start, final int numberOfDates); 133 134 /** 135 * Returns a list of IMM dates between 2 dates, it will exclude the start 136 * date if it is an IMM date but would include the end date if it is an IMM. 137 * 138 * @param start 139 * start of the interval, excluded 140 * @param end 141 * end of the interval, may be included. 142 * @param period 143 * specify when the "next" IMM is, if quarterly then it is the 144 * conventional algorithm. 145 * @return list of IMM dates 146 */ 147 List<E> getIMMDates(final E start, final E end, final IMMPeriod period); 148} 149 150/* 151 * ObjectLab, http://www.objectlab.co.uk/open is sponsoring the ObjectLab Kit. 152 * 153 * Based in London, we are world leaders in the design and development 154 * of bespoke applications for the securities financing markets. 155 * 156 * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a> 157 * ___ _ _ _ _ _ 158 * / _ \| |__ (_) ___ ___| |_| | __ _| |__ 159 * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \ 160 * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) | 161 * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/ 162 * |__/ 163 * 164 * www.ObjectLab.co.uk 165 */