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.


Author:
Lakshmi Krishnamurthy
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int DATE_ROLL_ACTUAL
    Date Roll Actual
    static int DATE_ROLL_FOLLOWING
    Date Roll Following
    static int DATE_ROLL_MODIFIED_FOLLOWING
    Date Roll Modified Following
    static int DATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLY
    Date Roll Modified Following Bi-monthly
    static int DATE_ROLL_MODIFIED_PREVIOUS
    Date Roll Modified Previous
    static int DATE_ROLL_PREVIOUS
    Date Roll Previous
    static int WEEKDAY_HOLS
    Week Day Holiday
    static 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 Set
    static int Adjust​(int iDate, java.lang.String strCalendar, int iAdjustMode)
    Adjust the given Date in Accordance with the Adjustment Mode and the Calendar Set
    static java.lang.String AvailableDC()
    Get all available DRIP day count conventions
    static int BusinessDays​(int iStartDate, int iEndDate, java.lang.String strCalendar)
    Calculate the Number of Business Days between the Start and the End Dates
    static 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 Parameters
    static java.util.Set<java.lang.String> HolidayLocations()
    Retrieve the set of holiday locations
    static int Holidays​(int iStartDate, int iEndDate, java.lang.String strCalendar)
    Calculate the Number of Holidays between the Start and the End Dates
    static 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
    static boolean Init​(java.lang.String strCalendarSetLoc)
    Initialize the day count basis object from the calendar set
    static 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 Set
    static int[] WeekendDays​(java.lang.String strCalendarSet)
    Get the week end days for the given holiday calendar set
    static 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 Parameters

    Methods 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_ACTUAL
      Date Roll Actual
      See Also:
      Constant Field Values
    • DATE_ROLL_FOLLOWING

      public static final int DATE_ROLL_FOLLOWING
      Date Roll Following
      See Also:
      Constant Field Values
    • DATE_ROLL_MODIFIED_FOLLOWING

      public static final int DATE_ROLL_MODIFIED_FOLLOWING
      Date Roll Modified Following
      See Also:
      Constant Field Values
    • DATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLY

      public static final int DATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLY
      Date Roll Modified Following Bi-monthly
      See Also:
      Constant Field Values
    • DATE_ROLL_PREVIOUS

      public static final int DATE_ROLL_PREVIOUS
      Date Roll Previous
      See Also:
      Constant Field Values
    • DATE_ROLL_MODIFIED_PREVIOUS

      public static final int DATE_ROLL_MODIFIED_PREVIOUS
      Date Roll Modified Previous
      See Also:
      Constant Field Values
    • WEEKDAY_HOLS

      public static final int WEEKDAY_HOLS
      Week Day Holiday
      See Also:
      Constant Field Values
    • WEEKEND_HOLS

      public static final int WEEKEND_HOLS
      Week 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.Exception
      Calculate the Accrual Fraction in Years between 2 given Dates for the given Day Count Convention and the other Parameters
      Parameters:
      iStartDate - Start Date
      iEndDate - End Date
      strDayCount - Day Count Convention
      bApplyEOMAdj - Apply End-of-Month Adjustment (TRUE)
      actactParams - ActActParams
      strCalendar - 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.Exception
      Calculate the Days Accrued between 2 given Dates for the given Day Count Convention and the other Parameters
      Parameters:
      iStartDate - Start Date
      iEndDate - End Date
      strDayCount - Day Count Convention
      bApplyEOMAdj - Apply End-of-Month Adjustment (TRUE)
      actactParams - ActActParams
      strCalendar - 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.Exception
      Roll the given Date in accordance with the Roll Mode and the Calendar Set
      Parameters:
      iDate - Date to be Rolled
      iRollMode - Roll Mode (one of DR_ACT, DR_FOLL, DR_MOD_FOLL, DR_PREV, or DR_MOD_PREV)
      strCalendarSet - Calendar Set to calculate the Holidays by
      iNumDaysToRoll - 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 - Date
      strCalendar - Location Calendar Set
      iHolType - 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 - Date
      strCalendar - 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.Exception
      Calculate the Number of Business Days between the Start and the End Dates
      Parameters:
      iStartDate - Start Date
      iEndDate - End Date
      strCalendar - 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 Date
      iEndDate - End Date
      strCalendar - 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 Date
      iEndDate - End Date
      strCalendar - 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 Adjusted
      strCalendar - Calendar Set to calculate the Holidays by
      iAdjustMode - 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 Adjusted
      iNumDays - Number of Days to Add
      strCalendar - Calendar Set to calculate the Holidays by
      Returns:
      The Adjusted Date