Class BusinessCalendar

java.lang.Object
com.quantfinlib.rates.BusinessCalendar

public final class BusinessCalendar extends Object
Business-day calendar: weekends plus a holiday set, with the standard roll conventions, settlement-lag arithmetic, and coupon schedule generation.

Why this is a finance class and not a util: cash cannot move on a day the payment system is closed, so every real-world date in a trade — the settlement date (spot = trade + 2 business days in most FX pairs, T+1 US equities), each coupon date, an option expiry — must land on a business day, and WHICH way a weekend date rolls changes the accrual period and therefore the payment (DayCount then converts the rolled dates to a year fraction). MODIFIED_FOLLOWING — roll forward unless that crosses month-end, then backward — is the near-universal swap convention precisely because plain FOLLOWING would occasionally push a month's payment into the next month and break month-bucketed accounting. A holiday missing from the set silently shifts settlement by a day: the classic source of small unexplained cash breaks between two systems that disagree about, say, Whit Monday.

  • Method Details

    • weekendsOnly

      public static BusinessCalendar weekendsOnly()
    • withHolidays

      public static BusinessCalendar withHolidays(Set<LocalDate> holidays)
    • withHolidays

      public static BusinessCalendar withHolidays(LocalDate... holidays)
    • union

      public BusinessCalendar union(BusinessCalendar other)
      The joint calendar of two trading centers: a day is a business day only when it is one in BOTH (holiday sets union). This is the FX settlement rule — one calendar object, so every roll convention and schedule helper works unchanged on the pair, instead of each caller re-implementing dual-calendar walks.
    • isBusinessDay

      public boolean isBusinessDay(LocalDate date)
    • roll

      public LocalDate roll(LocalDate date, BusinessCalendar.Roll convention)
      Applies the roll convention to a date.
    • addBusinessDays

      public LocalDate addBusinessDays(LocalDate date, int n)
      Adds n >= 0 business days — e.g. T+2 settlement from a trade date.
    • subtractBusinessDays

      public LocalDate subtractBusinessDays(LocalDate date, int n)
      Walks back n >= 0 business days — e.g. a fixing lag before settlement.
    • schedule

      public List<LocalDate> schedule(LocalDate effectiveDate, LocalDate maturity, int paymentsPerYear, BusinessCalendar.Roll convention)
      Coupon payment schedule: unadjusted dates generated backward from maturity every 12/paymentsPerYear months, then rolled. Returns the adjusted payment dates strictly after effectiveDate, ascending (last = adjusted maturity).
    • unadjustedSchedule

      public static List<LocalDate> unadjustedSchedule(LocalDate effectiveDate, LocalDate maturity, int paymentsPerYear)
      The unadjusted (theoretical) coupon dates strictly after effectiveDate.