How shine0078/nt8bridgecleandiscovery works
Purpose and entry points
NT8BridgeClean is a safety-first, clean-room research and validation repository for a NinjaTrader 8 Keltner-breakout strategy. It combines deterministic offline research, native NT8 compatibility/Playback validation, and fail-closed release authorization; it explicitly rejects live trading today. Primary entry points are the Python CLI at nt8_research/__main__.py / nt8_research/cli.py, the release evaluator Scripts/evaluate_release.py, and manually operated NT8 strategy sources under Strategies/.
Offline research engine
The deterministic Python engine models completed-bar signals, next-open entries, costs, sizing, protection, session flattening, and risk breakers. It runs scenario matrices and produces reproducible metrics/artifacts rather than placing orders.
• nt8_research/engine.py
• nt8_research/scenarios.py
• nt8_research/models.py
Market-data ingestion, indicators, and performance calculations form the engine boundary: raw data is intentionally outside the tracked tree, while generated research outputs are committed for audit.
• nt8_research/data.py
• nt8_research/indicators.py
• nt8_research/metrics.py
• Results/research_results.json
Candidate locking and release policy
Candidate plans preregister strategy identity, parameters, validation windows, and permitted evidence. Release evaluation consumes only candidate-bound, hash-validated artifacts and fails closed on missing, stale, superseded, or inconsistent evidence. It is the sole authority for APPROVED/live authorization.
• Validation/resilient_candidate_plan.json
• nt8_research/release.py
• Scripts/evaluate_release.py
• NativeValidation/evidence_contract.json
The active candidate is distinct from the permanently burned predecessor lock:
• Validation/candidate_lock.json
• Results/release_evaluation.json
NinjaScript strategy layer
Three NinjaScript versions represent baseline, successor, and active resilient candidates. The resilient strategy is the operational focus: it defaults to Sim101/Playback101, blocks real-time accounts unless explicitly authorized, logs incidents/order states, persists loss locks, and protects against connection/position anomalies.
• Strategies/RobustKeltnerBreakout.cs
• Strategies/RobustKeltnerBreakoutResilient.cs
• Strategies/RobustKeltnerBreakoutSuccessor.cs
• Strategies/ConnectionStateGate.cs
This layer runs inside NinjaTrader 8.1.7.2, not the Python runtime. Source installation and native compilation are controlled compatibility boundaries.
Native NT8 automation and safety boundary
Python scripts automate evidence-oriented NT8 workflows: discover UI state, install exact candidate sources, configure Playback/Sim101, capture output, and compile. Native mutations are acknowledgment-gated, candidate-scoped, and restricted to simulated/Playback validation; discovery tooling is read-only.
• nt8_research/native_automation.py
• nt8_research/native_artifacts.py
• Scripts/install_resilient_candidate.py
• Scripts/run_nt8_shadow_compile.ps1
NT8 is an external Windows desktop runtime; its Control Center/UI automation and installed Custom project are treated as untrusted operational boundaries. Environment evidence is sanitized:
• Scripts/collect_nt8_environment.py
• Results/nt8_environment_evidence.json
Playback resilience validation
Operational validation exercises connection loss, partial fills, orphan-position reconciliation, and restart-persistent loss locks in NT8 Playback. Raw captures are preserved first; evidence builders derive reproducible summaries, including rejected or not-exercised outcomes rather than converting them to passes.
• Scripts/build_operational_evidence.py
• NativeValidation/evidence/playback/resilient_orphan_position_reconciliation/
• NativeValidation/evidence/playback/resilient_restart_restores_loss_lock/
• Results/resilient_orphan_position_reconciliation_evidence.json
Evidence custody and packaging
Evidence is SHA-256-bound across source, native compile captures, logs, exports, and derived results. Import packages and commission templates support controlled NT8 installation; broker-control evidence is deliberately private and must come from independent redacted exports.
• NativeValidation/package_manifest.json
• NativeValidation/evidence/resilient_native_compile/compile_capture.json
• Scripts/build_nt8_import_package.ps1
• Scripts/build_broker_evidence.py
Execution and CI
The project runs on Python with dependencies declared in pyproject.toml and requirements.txt; NinjaTrader-specific validation requires Windows and NT8. CI enforces repository-side safety/regression checks but cannot substitute for native, manually supervised validation.
• pyproject.toml
• .github/workflows/ci.yml
• docs/CI_VALIDATION.md
Main entry points: release.py Release evaluator · engine.py Backtest engine · build_operational_evidence.py Operational evidence builder · install_resilient_candidate.py Install and compile workflow
Components 20
Offline research
Deterministic Python analysis with committed audit outputs.
- Research CLI
nt8_research/cli.py - Backtest engine · Models completed-bar trading, protection, sessions, and breakers.
nt8_research/engine.py - Scenario matrix
nt8_research/scenarios.py - Market data and analytics · Raw market data remains outside the tracked repository.
nt8_research/data.py - Research results
Results/research_results.json
Release authorization
Candidate-bound, fail-closed release decision.
- Candidate plan · Defines identity, windows, parameters, and permitted evidence.
Validation/resilient_candidate_plan.json - Candidate lock · Active lock is distinct from the burned predecessor.
Validation/candidate_lock.json - Release evaluator · Sole authority for APPROVED and live authorization.
nt8_research/release.py - Release evaluation
Results/release_evaluation.json
Native NT8 validation
Windows/NT8 compatibility and Playback safety boundary.
- NinjaTrader 8 runtime · Untrusted Control Center/UI and installed Custom-project boundary.
- Resilient strategy · Defaults to Sim101/Playback101 and guards account, connection, position, and loss-lock state.
Strategies/RobustKeltnerBreakoutResilient.cs - Strategy lineage · Baseline and successor sources provide candidate lineage.
Strategies/RobustKeltnerBreakout.cs - Native automation · Candidate-scoped, acknowledgment-gated simulated/Playback workflows.
nt8_research/native_automation.py - Playback resilience tests · Exercises connection loss, fills, reconciliation, and persisted loss locks.
NativeValidation/evidence/playback/resilient_orphan_position_reconciliation/capture_manifest.json
Evidence custody
Hash-bound validation captures and derived evidence.
- Evidence contract
NativeValidation/evidence_contract.json - Operational evidence builder · Preserves rejected and not-exercised outcomes.
Scripts/build_operational_evidence.py - Native compile capture
NativeValidation/evidence/resilient_native_compile/compile_capture.json - Package manifest
NativeValidation/package_manifest.json
Automation and CI
Controlled installation, packaging, and repository checks.
- Install and compile workflow · Installs exact sources and runs shadow compilation.
Scripts/install_resilient_candidate.py - Repository CI · Safety and regression checks; not a substitute for native validation.
.github/workflows/ci.yml
Connections 23
- Research CLI → Backtest engine: runs
- Backtest engine → Scenario matrix: evaluates
- Backtest engine → Market data and analytics: uses
- Backtest engine → Research results: writes
- Candidate plan → Candidate lock: locks
- Candidate plan → Release evaluator: bounds
- Candidate lock → Release evaluator: validates
- Evidence contract → Release evaluator: governs accepted evidence
- Release evaluator → Release evaluation: emits
- Strategy lineage → Resilient strategy: candidate lineage
- Resilient strategy → NinjaTrader 8 runtime: runs in
- Native automation → NinjaTrader 8 runtime: automates UI
- Install and compile workflow → Resilient strategy: installs exact source
- Install and compile workflow → NinjaTrader 8 runtime: compiles in
- NinjaTrader 8 runtime → Playback resilience tests: produces raw captures
- Playback resilience tests → Operational evidence builder: supplies captures
- Operational evidence builder → Evidence contract: derives conforming evidence
- NinjaTrader 8 runtime → Native compile capture: records compilation
- Package manifest → Install and compile workflow: controls package contents
- Research results → Release evaluator: candidate evidence
- Native compile capture → Release evaluator: candidate evidence
- Operational evidence builder → Release evaluator: candidate evidence
- Repository CI → Release evaluator: checks repository safety