Skip to content

Phase 10 Session 4 — Kill switch implementation (19 tests passing)#12

Merged
shiviancodes merged 1 commit into
mainfrom
feature/phase10-session3a
May 21, 2026
Merged

Phase 10 Session 4 — Kill switch implementation (19 tests passing)#12
shiviancodes merged 1 commit into
mainfrom
feature/phase10-session3a

Conversation

@shiviancodes

Copy link
Copy Markdown
Owner

Summary

  • Implements all four kill switch functions in nexus/execution/compliance.py, replacing stubs that have returned True since Phase 7B Task 2
  • check_drawdown_breach: halts at −15% peak-to-trough NAV drawdown (hardcoded floor)
  • check_position_loss: halts at −25% single-name loss (hardcoded stop)
  • check_fsi_breach: halts at FSI > 2.0 (above 2022 tightening cycle ~1.8, below COVID peak ~5.0)
  • check_edgar_rate_limit: reads edgar:request_count_1s from Redis; key absent or Redis unreachable → safe default (True), halts at ≥ 8 req/s
  • check_kill_switches gains optional params (portfolio_nav_df, fsi_value, ticker, prices); fetches from DB internally when called with no args, preserving the existing
    no-arg call site in alpaca_client.py:103

… FSI, EDGAR rate limit

Replaces four True-returning stubs with real enforcement logic:
- check_drawdown_breach: halts at -15% peak-to-trough NAV drawdown
- check_position_loss: halts at -25% single-name loss
- check_fsi_breach: halts at FSI > 2.0 (severe systemic stress, above 2022 tightening cycle)
- check_edgar_rate_limit: halts at ≥8 req/s via Redis counter; safe-defaults to True on Redis failure
- check_kill_switches: new optional params (portfolio_nav_df, fsi_value, ticker, prices); fetches from DB
  internally when called with no args (preserving alpaca_client.py call site)

19 tests, all passing.
@shiviancodes shiviancodes merged commit 0c6b5ac into main May 21, 2026
1 check passed
@shiviancodes shiviancodes deleted the feature/phase10-session3a branch May 21, 2026 11:25
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