fix: holiday check false positives on trading days#8
Merged
Conversation
…it codes Root cause: trading_calendar.py used sys.exit(1) for holidays, but SSM reports "Failed" for ANY non-zero exit (holidays, crashes, missing files). The Step Function treated all non-Success SSM status as holidays, causing false skips on normal trading days when the script failed for infrastructure reasons. Three fixes: 1. Script always exits 0, prints TRADING_DAY or MARKET_CLOSED marker 2. Step Function checks StandardOutputContent for markers, not SSM status 3. Added TradingDayCheckFailed state — infrastructure errors proceed as trading day (with alert) instead of silently skipping the pipeline 4. Added InProgress/Pending polling loop (was missing — immediate default to holiday skip if SSM hadn't finished yet) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cipher813
added a commit
that referenced
this pull request
Apr 25, 2026
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
Apr 25, 2026
…ndows (#96) * fix(universe_returns): use NYSE trading-day arithmetic for forward windows 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> * universe_returns: import _add_trading_days from alpha-engine-lib v0.2.1 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> --------- 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
trading_calendar.pyusedsys.exit(1)for holidays, but SSM reportsFailedfor any non-zero exit — crashes, missing files, venv issues all looked like holidays to the Step FunctionTRADING DAY/MARKET_CLOSED). Step Function checksStandardOutputContentinstead of SSM statusTradingDayCheckFailedstate: infrastructure errors send an alert but proceed as trading day (fail-open) instead of silently skippingInProgress/Pendingpolling loop — was missing, so unfinished SSM commands defaulted to holiday skipTest plan
deploy_step_function_daily.shgit pullon EC2 micro instance🤖 Generated with Claude Code