Complete the bounded paper-learning loop - #7
Draft
Jerrycyborg wants to merge 2 commits into
Draft
Conversation
Jerrycyborg
pushed a commit
that referenced
this pull request
Sep 3, 2026
The trading worker suppresses a BUY when ADX is below 20 or unmeasurable and when volume does not exceed its 20-bar average. The backtest modelled neither, so every result described a strictly more permissive strategy than the one that trades — and whether those gates earn the entries they remove had never been tested. They were applied on faith. BacktestRequest gains regime_gate and volume_gate, both defaulting to off so existing results stay comparable, applied at engine._compute_signals — the single choke point where the rule's output becomes the traded series, which mirrors live's "gates sit in front of the rule". run_edge_study now runs each cost case twice and reports the difference, judging its verdict on the gated stress case because that is the configuration that actually trades. indicator_series gains adx_series: the live gate reads one scalar ADX from the whole window it holds, so reproducing it per bar is an expanding window, and recomputing the scalar at every bar is quadratic across trials and folds. This runs the Wilder recursion forward once, including the branch where fewer DX values than the period are averaged rather than smoothed. entry_gates is a deliberate second copy of live's filters and says so. ADR-006 puts the one true definition in a shared library; that extraction is blocked behind PR #7, which is itself refactoring the live gate, so touching worker.py now would only create a conflict. test_entry_gates.py is what makes the duplicate safe in the meantime: it pins adx_series to compute_adx at every prefix length and asserts the gate decides bar-for-bar what live decides, including the boundaries that are easy to get wrong — an unmeasurable regime refused rather than passed on the 25.0 sentinel, and volume equality failing. Verified by breaking: relaxing the volume comparison to >=, dropping the measurability check, and corrupting the ADX seed branch each fail a test. Suite: 1008 passed, 7 skipped offline; ruff clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019shd9XwPXFFf1NqVMVoiAB
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.
Outcome
Completes the bounded paper-learning milestone while preserving a hard separation from real-money authority.
What changed
Safety boundary
This PR does not enable live mode, auto-promote a strategy, auto-adopt a challenger, deploy services, or grant the learner broker/lifecycle transition authority.
Verification
ruff check .pytest -qwith a disposable local-only internal key: 904 passed, 140 skippedgit diff --checkThe skipped tests require PostgreSQL and are intentionally exercised by repository CI.
Known blockers before real money
These are explicit follow-up gates, not hidden behind this PR.