ml4t-calendar-ops

Installation
SKILL.md

Calendar Operations

Using calendar days instead of trading days for a 20-day rolling window includes weekends and holidays, producing a window that covers 28 calendar days but only 20 observations - silently misaligning your features with your labels.

The Problem

Markets are closed on weekends and holidays. A "20-day momentum" signal should use 20 trading days (~4 weeks), not 20 calendar days (~2.8 weeks). When you mix calendar-day math with trading-day data, rolling windows span wrong periods, cross-market joins misalign (NYSE is closed on Presidents Day but LSE is open), and date arithmetic produces gaps your model interprets as missing data. These errors are invisible until you compare strategy behavior across markets or time zones.

The Pattern

WRONG

import polars as pl
from datetime import timedelta

# Calendar days for rolling window - includes weekends, holidays
df = df.with_columns(
    momentum=pl.col("close") / pl.col("close").shift(20) - 1  # shift(20) = 20 rows
)
# If data has gaps (holidays), shift(20) is NOT 20 trading days - it skips over them unevenly
Installs
19
Repository
ml4t/skills
GitHub Stars
39
First Seen
Sep 12, 2026