feat(risk): freeze TQQQ ETF-only research mandate - #302
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d687678322
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| and weight | ||
| > loss_budget * drawdown_scalar / stop_distance + 1e-9 |
There was a problem hiding this comment.
Enforce the budget against completed-session equity
For this mandate, loss_budget_equity_reference is fixed to completed_session_equity, but this comparison uses a weight derived from portfolio_snapshot.total_equity (including when a target_value is normalized) and the gate never receives the completed-session equity value. When current equity differs from the completed-session reference, the one-percent budget is therefore applied to the wrong base; for example, with completed-session equity of $100k and current equity of $120k, a $24k BOXX target becomes weight 0.20 and passes this check while its modeled 5% loss is $1,200, or 1.2% of the mandated reference. Bind the completed-session equity into the evidence and compare the modeled dollar loss against that value.
Useful? React with 👍 / 👎.
| tqqq_active = any(symbol == "TQQQ" for symbol, _ in active_positions) | ||
| if tqqq_active and risk_control_state.get("stop_intent_ready") is not True: | ||
| errors.add("stop_intent_not_ready") |
There was a problem hiding this comment.
Check stop readiness against current TQQQ holdings
This derives tqqq_active only from the proposed decision, not from the portfolio snapshot. If the account currently holds TQQQ but the new decision targets cash (or otherwise omits TQQQ), the gate accepts stop_intent_ready=False and missing fill identities even though the position remains exposed until the exit fills; a snapshot with current TQQQ exposure and an empty decision can consequently receive APPROVE. Determine active TQQQ exposure from the current portfolio state, or require the stop evidence until the holding is confirmed flat.
Useful? React with 👍 / 👎.
Scope
tqqq_etf_only_research_v1as an exactRESEARCH_ONLYETF-only mandateSafety boundaries
Evidence
190b7577e3d4cd826f053e4b899c13e1271910979 passed, 43 subtests passed(later expanded coverage)932 passed, 1 skipped, 26 warnings, 131 subtests passedruff check ., compile, package, diff, scope, and secret gates passedBound freeze SHA-256:
4e8896cdd16eefff7631ce8c491cdba283e3dca19770735fd7a7f0b53fd498ceContainment SHA-256:
4aeacd014221cfc8be6541f4d083463c4e6b4f12df48d50d07157d30f2db84dc