data_updater_v2.jobs.calendar
calendar.py — NYSE’s trading calendar: market_sessions and market_holidays.
Every run builds the whole calendar (NYSE’s page, FMP’s holidays, mcal locally: one call each, seconds) and reconciles it into the two tables, written side by side:
fetch_calendar ─┬─ write_holidays market_holidays └─ write_sessions market_sessionsA source that could not be read writes nothing: the run opens a calendar issue on each table and skips, and the repair runs it again that night. A table written closes its issues.
calendar_build by handcalendar_update 17:00 New York, Monday to Fridaycalendar_repair 02:00 New York, only while a calendar issue is openClasses
Calendar
Bases: DataJob
The calendar jobs: one build, the two tables written from it. Carried state: the
base’s, with params this job’s CalendarParams.
calendar_repair_due
calendar_repair_due(context: Any) -> AnyOnce a night, 02:00-04:00 New York (two hours: the night the clocks go forward has no 02:00), only while a calendar issue is open.
fetch_calendar
fetch_calendar(cfg: RunConfig) -> dict[str, Any]The whole calendar built (writes nothing). A source unread: an issue opened on each table, and the step skips, so neither table is written.
write_holidays
write_holidays(cfg: RunConfig, fetch_calendar: dict[str, Any]) -> NoneEvery weekday closed or shortened.
write_sessions
write_sessions(cfg: RunConfig, fetch_calendar: dict[str, Any]) -> NoneEvery day traded, with its hours.
CalendarParams
Bases: JobParams
A calendar job’s row params: how far ahead to build, and how each table is written
(write_calendar’s).