Skip to content

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_sessions

A 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 hand
calendar_update 17:00 New York, Monday to Friday
calendar_repair 02:00 New York, only while a calendar issue is open

Classes

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) -> Any

Once 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]) -> None

Every weekday closed or shortened.

write_sessions

write_sessions(cfg: RunConfig, fetch_calendar: dict[str, Any]) -> None

Every 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).