Class CalendarAnomalies

java.lang.Object
com.quantfinlib.alpha.CalendarAnomalies

public final class CalendarAnomalies extends Object
Calendar anomaly profiles: day-of-week and turn-of-month seasonality with their t-statistics. Most published calendar anomalies (the weekend effect, the January effect) decayed after publication, and what separates a tradable seasonal from a data-mined one is a t-stat that survives out of sample. Treat |t| < 2 as decoration and re-test out of sample before believing anything (see AlphaValidation).

Significance. Daily returns cluster in volatility, so iid standard errors understate uncertainty. Both profiles report Newey-West (1987) HAC t-stats from a dummy regression on the full return series (lag from the Andrews 1991 AR(1) plug-in on the returns), with the iid t kept as naiveTStat. Testing five to seven days at once, the best of them clears |t| > 2 by chance far more often than 5% of the time, so the day-of-week profile also flags which days survive a Holm (1979, Scand. J. Statistics 6(2)) step-down correction at the 5% family-wise level, using normal two-sided p-values from the HAC t.

Turn-of-month windows use calendar days of month (last daysBeforeMonthEnd calendar days + first daysAfterMonthStart), not trading days; with daily equity data the difference is a day around holidays. Timestamps are interpreted in UTC. Static, deterministic, research lane.

  • Field Details

    • FAMILY_WISE_ALPHA

      public static final double FAMILY_WISE_ALPHA
      Family-wise error rate used for the Holm flags.
      See Also:
  • Method Details

    • dayOfWeek

      public static CalendarAnomalies.DayOfWeekProfile dayOfWeek(double[] returns, long[] epochMillis)
      Mean return by day of the week.
      Parameters:
      returns - per-period returns aligned with epochMillis
    • turnOfMonth

      public static CalendarAnomalies.TurnOfMonth turnOfMonth(double[] returns, long[] epochMillis, int daysBeforeMonthEnd, int daysAfterMonthStart)
      Turn-of-month effect: returns inside against outside the month-end window.
      Parameters:
      daysBeforeMonthEnd - calendar days at month end in the window, ≥ 0
      daysAfterMonthStart - calendar days at month start in the window, ≥ 0 (at least one of the two > 0)