Skip to content

feat(freshness-monitor): template-aware trading-day-axis resolution for historical probe#341

Merged
cipher813 merged 2 commits into
mainfrom
feat/historical-probe-trading-day-axis
May 28, 2026
Merged

feat(freshness-monitor): template-aware trading-day-axis resolution for historical probe#341
cipher813 merged 2 commits into
mainfrom
feat/historical-probe-trading-day-axis

Conversation

@cipher813
Copy link
Copy Markdown
Owner

Summary

Closes the calendar-vs-trading-day mismatch surfaced by PR #339's historical probe. Producer artifacts mostly write to {trading_day} keys (Fri for sat_sf, prev weekday for weekday_sf, today for eod_sf) per the system-wide now_dual() convention, but the registry had multiple entries templated with {date} — so the probe was looking at the wrong S3 keys.

Restructure

  • _iter_sf_firing_dates: returns the SF cron's calendar firing dates (no change from prior behavior at this layer)
  • _resolve_axis_dates: NEW. Translates firing dates to the date-axis the template uses:
    • {date} → calendar firing date
    • {trading_day} + saturday_sf/weekday_sf → previous_trading_day(firing_date) (NYSE-holiday-aware via alpha_engine_lib.trading_calendar)
    • {trading_day} + eod_sf → firing date itself (EOD writes today's close)
  • _iter_historical_cycle_dates: now takes optional template arg; backward-compat for template-less calls

Live smoke results (post-deploy + companion registry flip)

Artifact Before ({date}) After ({trading_day})
research_signals 9/12 gaps 5/12 gaps (4 cycles recovered)
research_consolidated_morning 12/12 gaps 9/12 gaps
scanner_candidates_json 12/12 gaps 12/12 gaps (Scanner Lambda hasn't fired yet — first emission Sat 5/30)

The remaining gaps are real producer-side absences (not template mismatch).

Test plan

  • 6 new unit tests cover saturday_sf / weekday_sf / eod_sf trading_day resolution + NYSE-holiday-skip + backward-compat
  • Full suite: 27 passed (21 prior + 6 new)
  • Live invoke verified the 4-cycle history recovery for research_signals

Composes with

🤖 Generated with Claude Code

cipher813 and others added 2 commits May 28, 2026 08:57
…or historical probe

Closes the calendar-vs-trading-day mismatch surfaced by PR #339's
historical probe — research_signals was registered as
signals/{date}/signals.json + cadence=saturday_sf but the producer
writes to Friday trading-day keys (signals/2026-05-22/, /05-15/,
/05-08/...). The pre-fix probe correctly reported the Saturday keys
absent — but the operator-facing display showed 9/12 gaps when the
true gap rate was lower; the registry just wasn't asking the right
question.

Restructure:

- _iter_sf_firing_dates: returns the SF cron's calendar firing dates
  (last N Saturdays for saturday_sf, last N Mon-Fri for weekday_sf /
  eod_sf). No change from prior calendar-naive behavior at this layer.
- _resolve_axis_dates: NEW. Translates firing dates to the date-axis
  the template actually uses. {date} → calendar firing date; {trading_day}
  → previous_trading_day(firing_date) for saturday_sf/weekday_sf, or
  firing_date itself for eod_sf (EOD writes today's close).
  alpha_engine_lib.trading_calendar.previous_trading_day IS NYSE-
  holiday-aware, so Memorial-Day-style holidays resolve correctly.
- _iter_historical_cycle_dates: now takes optional template arg and
  composes the two helpers. Backward-compat: callers omitting template
  get calendar-axis (pre-PR behavior).
- _handle_historical: passes spec.s3_key_template to the resolver.

6 new unit tests cover the trading_day-axis path for all three
cadences + NYSE-holiday skip via the lib + backward-compat for the
template-less call signature. Full suite: 27 passed (21 prior + 6
new).

Live smoke (post-deploy + historical invoke after companion
alpha-engine-config registry flip):
  research_signals — 12/12 gaps (under {date}) → 5/12 gaps (under
  {trading_day}). 4 cycles correctly recovered.

Composes with alpha-engine-config registry PR (this branch's
sibling): flips research_signals, research_consolidated_morning,
scanner_candidates_json from {date} → {trading_day}. 4 backtest_*
entries documented + held at {date} pending producer-side audit
(backtester writes to ad-hoc current-date-of-write, neither {date}
nor {trading_day}).

Per the system's now_dual() convention codified in
alpha-engine-docs/private/DATE_CONVENTIONS.md — trading_day =
last_closed_trading_day(now); this PR brings the registry +
historical probe into compliance with that convention.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cipher813 cipher813 merged commit ae5d848 into main May 28, 2026
1 check passed
@cipher813 cipher813 deleted the feat/historical-probe-trading-day-axis branch May 28, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant