fix(universe_returns): use NYSE trading-day arithmetic for forward windows#96
Merged
Conversation
…ndows Replace _add_business_days (Mon-Fri, no holiday awareness) with _add_trading_days using alpha_engine_lib.trading_calendar.next_trading_day. The pre-fix helper silently mis-labeled forward returns when the window crossed a NYSE holiday — e.g. eval_date=2026-04-02 + 5 BD returned 2026-04-09 (counting Good Friday as a BD), so return_5d was actually a 4-trading-day return. Now lands on 2026-04-10 as intended. Also enumerates trading days only via existing is_trading_day check, so holidays never become eval_dates either. 14 new tests in test_universe_returns_trading_day.py covering the helper + _trading_days_to_process eligibility filter. 223/223 full suite pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace local helper with lib import — same logic, single source of truth across the three repos that need trading-day arithmetic. Trim duplicate arithmetic tests (those are locked in alpha-engine-lib's test_trading_calendar.py now); keep data-specific eligibility-filter tests. Requires alpha-engine-lib >= 0.2.1 (alpha-engine-data is pinned @main, so auto-picks up after lib PR #8 merges). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
cipher813
added a commit
that referenced
this pull request
May 3, 2026
PR 4c's setup_eval_quality_alarm.sh used a SEARCH expression to reduce across (judged_agent_id, criterion, judge_model) combos at alarm-evaluation time. Caught at deploy: ValidationError: SEARCH is not supported on Metric Alarms. CloudWatch dashboards support SEARCH; alarms don't. Switched to a simple metric alarm against the new agent_quality_score_4w_mean_min floor metric that the rolling-mean Lambda emits (alpha-engine-research PR #96). --namespace AlphaEngine/Eval --metric-name agent_quality_score_4w_mean_min --statistic Minimum --period 86400 --evaluation-periods 1 --threshold 3.0 --comparison-operator LessThanThreshold Operator workflow unchanged: alarm fires → operator clicks dashboard quality-trend page to identify which combo triggered. The SEARCH design wouldn't have surfaced per-combo identity in the alarm body either. bash -n syntax-clean. Tests 433 still pass (no test logic affected). Deploy after merge: ./infrastructure/setup_eval_quality_alarm.sh (idempotent — overwrites the alarm in place). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
collectors/universe_returns.pynow importsadd_trading_daysfromalpha_engine_lib.trading_calendar(lib v0.2.1, PR fix: holiday check false positives on trading days #8) — single source of truth across data + executor + future consumers_add_business_days(calendar Mon-Fri, no holiday awareness) which silently mis-labeled forward returns crossing NYSE holidays (e.g.eval_date=2026-04-02 + 5 BDreturned 4/9, but the actual 5th trading day is 4/10 — Good Friday was wrongly counted)Sequencing
Requires alpha-engine-lib PR #8 merged first (adds
add_trading_daysetc.). alpha-engine-data is pinned@mainfor lib, so this picks up the new symbol on the next ae-trading boot-pull or localpip install -Uafter the lib merge.Changes
collectors/universe_returns.py: drop local_add_business_days, import lib'sadd_trading_days(aliased as_add_trading_daysto keep the 4 call sites unchanged)tests/test_universe_returns_trading_day.py: 6 tests covering data-specific eligibility filter (_trading_days_to_process). Arithmetic tests (Good Friday, Thanksgiving, etc.) live in lib'stest_trading_calendar.py— no duplication.Test plan
eval_date=2026-04-17cleanly🤖 Generated with Claude Code