Package org.drip.analytics.daycount
Class Convention
java.lang.Object
org.drip.analytics.daycount.Convention
public class Convention
extends java.lang.Object
Convention contains flags that indicate where the holidays are loaded from, as well as the holiday
types and load rules. It exports the following date related functionality:
- Add business days according to the specified calendar
- The Year Fraction between any 2 days given the day count type and the holiday calendar
- Adjust/roll to the next working day according to the adjustment rule
- Holiday Functions; is the given day a holiday/business day, the number and the set of holidays/business days between 2 days.
- Calendars and Day counts; Available set of day count conventions and calendars, and the weekend days corresponding to a given calendar.
- Module = Product Core Module
- Library = Fixed Income Analytics
- Project = Date, Cash Flow, and Cash Flow Period Measure Generation Utilities
- Package = Day Count Year Fraction Utilities
- Author:
- Lakshmi Krishnamurthy
-
Field Summary
Fields Modifier and Type Field Description static int
DATE_ROLL_ACTUAL
Date Roll Actualstatic int
DATE_ROLL_FOLLOWING
Date Roll Followingstatic int
DATE_ROLL_MODIFIED_FOLLOWING
Date Roll Modified Followingstatic int
DATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLY
Date Roll Modified Following Bi-monthlystatic int
DATE_ROLL_MODIFIED_PREVIOUS
Date Roll Modified Previousstatic int
DATE_ROLL_PREVIOUS
Date Roll Previousstatic int
WEEKDAY_HOLS
Week Day Holidaystatic int
WEEKEND_HOLS
Week End Holiday -
Constructor Summary
Constructors Constructor Description Convention()
-
Method Summary
Modifier and Type Method Description static int
AddBusinessDays(int iDate, int iNumDays, java.lang.String strCalendar)
Add the specified Number of Business Days and Adjust According to the Calendar Setstatic int
Adjust(int iDate, java.lang.String strCalendar, int iAdjustMode)
Adjust the given Date in Accordance with the Adjustment Mode and the Calendar Setstatic java.lang.String
AvailableDC()
Get all available DRIP day count conventionsstatic int
BusinessDays(int iStartDate, int iEndDate, java.lang.String strCalendar)
Calculate the Number of Business Days between the Start and the End Datesstatic int
DaysAccrued(int iStartDate, int iEndDate, java.lang.String strDayCount, boolean bApplyEOMAdj, ActActDCParams actactParams, java.lang.String strCalendar)
Calculate the Days Accrued between 2 given Dates for the given Day Count Convention and the other Parametersstatic java.util.Set<java.lang.String>
HolidayLocations()
Retrieve the set of holiday locationsstatic int
Holidays(int iStartDate, int iEndDate, java.lang.String strCalendar)
Calculate the Number of Holidays between the Start and the End Datesstatic java.util.List<java.lang.Integer>
HolidaySet(int iStartDate, int iEndDate, java.lang.String strCalendar)
Calculate the Set of Holidays between the Start and the End Datesstatic boolean
Init(java.lang.String strCalendarSetLoc)
Initialize the day count basis object from the calendar setstatic boolean
IsHoliday(int iDate, java.lang.String strCalendar)
Indicates whether the given Date is a Holiday in the specified Location(s)static boolean
IsHoliday(int iDate, java.lang.String strCalendar, int iHolType)
Indicate whether the given Date is a Holiday in the specified Location(s)static int
RollDate(int iDate, int iRollMode, java.lang.String strCalendarSet, int iNumDaysToRoll)
Roll the given Date in accordance with the Roll Mode and the Calendar Setstatic int[]
WeekendDays(java.lang.String strCalendarSet)
Get the week end days for the given holiday calendar setstatic double
YearFraction(int iStartDate, int iEndDate, java.lang.String strDayCount, boolean bApplyEOMAdj, ActActDCParams actactParams, java.lang.String strCalendar)
Calculate the Accrual Fraction in Years between 2 given Dates for the given Day Count Convention and the other ParametersMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
DATE_ROLL_ACTUAL
public static final int DATE_ROLL_ACTUALDate Roll Actual- See Also:
- Constant Field Values
-
DATE_ROLL_FOLLOWING
public static final int DATE_ROLL_FOLLOWINGDate Roll Following- See Also:
- Constant Field Values
-
DATE_ROLL_MODIFIED_FOLLOWING
public static final int DATE_ROLL_MODIFIED_FOLLOWINGDate Roll Modified Following- See Also:
- Constant Field Values
-
DATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLY
public static final int DATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLYDate Roll Modified Following Bi-monthly- See Also:
- Constant Field Values
-
DATE_ROLL_PREVIOUS
public static final int DATE_ROLL_PREVIOUSDate Roll Previous- See Also:
- Constant Field Values
-
DATE_ROLL_MODIFIED_PREVIOUS
public static final int DATE_ROLL_MODIFIED_PREVIOUSDate Roll Modified Previous- See Also:
- Constant Field Values
-
WEEKDAY_HOLS
public static final int WEEKDAY_HOLSWeek Day Holiday- See Also:
- Constant Field Values
-
WEEKEND_HOLS
public static final int WEEKEND_HOLSWeek End Holiday- See Also:
- Constant Field Values
-
-
Constructor Details
-
Convention
public Convention()
-
-
Method Details
-
Init
public static final boolean Init(java.lang.String strCalendarSetLoc)Initialize the day count basis object from the calendar set- Parameters:
strCalendarSetLoc
- The calendar set- Returns:
- Success (true) Failure (false)
-
HolidayLocations
public static final java.util.Set<java.lang.String> HolidayLocations()Retrieve the set of holiday locations- Returns:
- Set of holiday locations
-
WeekendDays
public static final int[] WeekendDays(java.lang.String strCalendarSet)Get the week end days for the given holiday calendar set- Parameters:
strCalendarSet
- Holiday calendar set- Returns:
- Array of days indicating the week day union
-
AvailableDC
public static final java.lang.String AvailableDC()Get all available DRIP day count conventions- Returns:
- Available DRIP day count conventions
-
YearFraction
public static final double YearFraction(int iStartDate, int iEndDate, java.lang.String strDayCount, boolean bApplyEOMAdj, ActActDCParams actactParams, java.lang.String strCalendar) throws java.lang.ExceptionCalculate the Accrual Fraction in Years between 2 given Dates for the given Day Count Convention and the other Parameters- Parameters:
iStartDate
- Start DateiEndDate
- End DatestrDayCount
- Day Count ConventionbApplyEOMAdj
- Apply End-of-Month Adjustment (TRUE)actactParams
- ActActParamsstrCalendar
- Holiday Calendar- Returns:
- Accrual Fraction in Years
- Throws:
java.lang.Exception
- Thrown if the Accrual Fraction cannot be calculated
-
DaysAccrued
public static final int DaysAccrued(int iStartDate, int iEndDate, java.lang.String strDayCount, boolean bApplyEOMAdj, ActActDCParams actactParams, java.lang.String strCalendar) throws java.lang.ExceptionCalculate the Days Accrued between 2 given Dates for the given Day Count Convention and the other Parameters- Parameters:
iStartDate
- Start DateiEndDate
- End DatestrDayCount
- Day Count ConventionbApplyEOMAdj
- Apply End-of-Month Adjustment (TRUE)actactParams
- ActActParamsstrCalendar
- Holiday Calendar- Returns:
- Number of Days Accrued
- Throws:
java.lang.Exception
- Thrown if the Accrual Days cannot be calculated
-
RollDate
public static final int RollDate(int iDate, int iRollMode, java.lang.String strCalendarSet, int iNumDaysToRoll) throws java.lang.ExceptionRoll the given Date in accordance with the Roll Mode and the Calendar Set- Parameters:
iDate
- Date to be RollediRollMode
- Roll Mode (one of DR_ACT, DR_FOLL, DR_MOD_FOLL, DR_PREV, or DR_MOD_PREV)strCalendarSet
- Calendar Set to calculate the Holidays byiNumDaysToRoll
- The Number of Days to Roll- Returns:
- The Rolled Date
- Throws:
java.lang.Exception
- Thrown if the date cannot be rolled
-
IsHoliday
public static final boolean IsHoliday(int iDate, java.lang.String strCalendar, int iHolType)Indicate whether the given Date is a Holiday in the specified Location(s)- Parameters:
iDate
- DatestrCalendar
- Location Calendar SetiHolType
- WEEKDAY_HOLS or WEEKEND_HOLS- Returns:
- TRUE - it is a Holiday
-
IsHoliday
public static final boolean IsHoliday(int iDate, java.lang.String strCalendar)Indicates whether the given Date is a Holiday in the specified Location(s)- Parameters:
iDate
- DatestrCalendar
- Location Calendar Set- Returns:
- TRUE - it is a Holiday
-
BusinessDays
public static final int BusinessDays(int iStartDate, int iEndDate, java.lang.String strCalendar) throws java.lang.ExceptionCalculate the Number of Business Days between the Start and the End Dates- Parameters:
iStartDate
- Start DateiEndDate
- End DatestrCalendar
- Holiday Calendar Set- Returns:
- The Number of Business Days
- Throws:
java.lang.Exception
- Thrown if it cannot be evaluated
-
HolidaySet
public static final java.util.List<java.lang.Integer> HolidaySet(int iStartDate, int iEndDate, java.lang.String strCalendar)Calculate the Set of Holidays between the Start and the End Dates- Parameters:
iStartDate
- Start DateiEndDate
- End DatestrCalendar
- Holiday Calendar Set- Returns:
- The Set of Holidays
-
Holidays
public static final int Holidays(int iStartDate, int iEndDate, java.lang.String strCalendar)Calculate the Number of Holidays between the Start and the End Dates- Parameters:
iStartDate
- Start DateiEndDate
- End DatestrCalendar
- Holiday Calendar Set- Returns:
- The Number of Holidays
-
Adjust
public static final int Adjust(int iDate, java.lang.String strCalendar, int iAdjustMode)Adjust the given Date in Accordance with the Adjustment Mode and the Calendar Set- Parameters:
iDate
- Date to be AdjustedstrCalendar
- Calendar Set to calculate the Holidays byiAdjustMode
- Adjustment Mode (one of DR_ACT, DR_FOLL, DR_MOD_FOLL, DR_PREV, or DR_MOD_PREV- Returns:
- The Adjusted Date
-
AddBusinessDays
public static final int AddBusinessDays(int iDate, int iNumDays, java.lang.String strCalendar)Add the specified Number of Business Days and Adjust According to the Calendar Set- Parameters:
iDate
- Date to be AdjustediNumDays
- Number of Days to AddstrCalendar
- Calendar Set to calculate the Holidays by- Returns:
- The Adjusted Date
-