Pre-cleanup baseline snapshot
Some checks failed
Build and Test / build (push) Has been cancelled

This commit is contained in:
2026-04-05 16:50:18 -04:00
parent d856f3949d
commit 9a28a49292
12 changed files with 695 additions and 30 deletions

View File

@@ -1,9 +1,134 @@
# NT8 SDK Project - Comprehensive Recap & Handover
# NT8-SDK Project Context & Current State
**Version:** 3.0 | **Date:** 2026-03-27 | **Status:** Sprint 2 Active — SIM Validation
**Document Version:** 2.0
**Date:** February 16, 2026
**Current Phase:** Phase 5 Complete
**Project Completion:** ~85%
> This file supersedes the previous PROJECT_HANDOVER.md and is the live source of truth.
> See also: `SPRINT_BOARD.md`, `GAP_ANALYSIS_AND_ROADMAP.md`, `CODING_PATTERNS.md`, `KILOCODE_WORKFLOW.md`
> Full formatted handover: `NT8_SDK_Handover_Package.docx`
---
## 1. What This Is
NT8-SDK is an institutional-grade algorithmic futures trading system built on NinjaTrader 8. It is not a research prototype — it is production trading software where bugs equal real financial losses.
The system trades NQ (Nasdaq 100 E-mini futures) using a 30-minute Opening Range Breakout strategy (SimpleORB) with a 10-factor confluence scoring engine that grades each signal A+ through F before allowing execution. A scaler/runner dual-leg architecture captures quick targets on the scaler while the runner trails for extended moves.
**Division of labor:** Claude handles architecture, diagnosis, and Kilocode prompt design. Kilocode executes ALL code changes. Mo owns strategy direction and go/no-go decisions.
---
## 2. Technology Stack
| Layer | Technology | Constraint |
|---|---|---|
| Language | C# 5.0 | Hard — NinjaScript compiler limit |
| Framework | .NET Framework 4.8 | Hard — NT8 requirement |
| Platform | NinjaTrader 8 | Hard — execution environment |
| Local repo | `C:\dev\nt8-sdk` | Windows path |
| NT8 deploy | `C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\` | Must match source |
| Deploy script | `deployment\deploy-to-nt8.bat` | Creates timestamped backups |
| VCS | Gitea (self-hosted) | `https://git.thehussains.org/mo/nt8-sdk` |
| AI coding | Kilocode | Executes ALL code changes |
| Automation | n8n (self-hosted) | Deferred to Sprint 4 |
| ML inference | Ollama (local) | Deferred to Sprint 5 |
**Critical C# constraint:** No `$""`, no `?.`, no `=>`, no async/await. Use `string.Format()`, explicit null checks, full method bodies.
---
## 3. Architecture (Top to Bottom)
```
SimpleORBNT8.cs NT8 entry point — sets defaults, adds daily bar series, builds DailyBarContext
NT8StrategyBase.cs Abstract base — bar routing, session management, kill switch, breakeven, runner
SimpleORBStrategy.cs Core signal — ORB detection, 10-factor confluence, _tradeTaken session lock
NT8OrderAdapter.cs INT8ExecutionBridge — calls EnterLong/EnterShort/SetStopLoss
PortfolioRiskManager.cs Singleton — cross-strategy daily loss + contract cap
NinjaTrader 8 Execution, fills, order management
```
---
## 4. Current Production Parameters (SIM: SimSimple ORB)
| Parameter | Value | Notes |
|---|---|---|
| Instrument | NQ JUN26 | Primary instrument |
| Bar type | 13-Range bars | |
| BarsRequiredToTrade | 50 | Warm-up guard |
| DailyLossLimit | $1,000 | |
| MaxTradeRisk | $200 | |
| RiskPerTrade | $100 | 2 contracts at current NQ prices |
| MinContracts | 1 | |
| MaxContracts | 3 | |
| MaxOpenPositions | 2 | Scaler + runner |
| EntriesPerDirection | 2 | Scaler slot 1, runner slot 2 |
| MinTradeGrade | 5 (A) | 4 (B) for broad SIM testing |
| EnableShortTrades | False | Long-only until short backtest done |
| BreakevenTriggerTicks | 20 | Tuned from 12 |
| RunnerTrailTicks | 20 | Tuned from 12 |
| OpeningRangeMinutes | 30 | 9:3010:00 ET |
| StopTicks | 8 | $40 per contract NQ |
| TargetTicks | 16 (dynamic) | Scales with ORB/ATR ratio |
---
## 5. Two-Path Deployment Rule
Every code change MUST be applied to both:
1. `C:\dev\nt8-sdk\src\NT8.Adapters\Strategies\` (repo source)
2. `C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\` (NT8 runtime)
After deployment, NT8 must recompile: Tools → Edit NinjaScript → open `NT8StrategyBase.cs` → save.
---
## 6. Key Learnings (Hard-Won)
1. **`State.Historical` guard** — `if (State == State.Realtime && !_realtimeBarSeen) return;` in `ProcessStrategyIntent` allows backtest (Historical), blocks replay burst in live.
2. **`_realtimeBarSeen` flag** — reset to `false` in `State.Realtime`, set `true` on first bar. Skips catch-up bar on live load to prevent replay burst.
3. **`EntriesPerDirection = 2`** — required for scaler + runner. Setting to 1 silently blocks the runner with no error.
4. **`SetStopLoss`/`SetProfitTarget` before `EnterLong`/`EnterShort`** — calling after entry is silently ignored in backtest.
5. **`Calculate.OnBarClose` backtest** — trades appear to close in under 1 second in logs. NT8 simulation artifact, not a bug. Live trades hold 220 minutes.
6. **NR7 warm-up** — requires 7 daily bars. Warm-up messages (0/7 bars) are correct behavior.
7. **NT8 never auto-recompiles** — always force recompile after file changes via NinjaScript Editor.
8. **Dual-path deployment mandatory** — stale deployed files cause phantom bugs where code looks right but behaves wrong.
9. **`PortfolioRiskManager` is a singleton** — fully implemented, no changes required. Kill switch, daily loss, contract cap all working.
10. **Sizing formula**`floor(RiskPerTrade / (StopTicks × $5.00))`. NQ: `$100 / (8 × $5) = 2 contracts`. Always verify `RiskPerTrade <= MaxTradeRisk`.
---
## 7. Validated Backtest Results
| Date | Period | Trades | Win% | PF | Net | Config |
|---|---|---|---|---|---|---|
| 2026-03-27 | JanMar 2026 | 20 | 75% | **7.00** | $1,200 | 1 ct, trail=20 ✅ Best |
| 2026-03-27 | JanMar 2026 | 40 | 75% | 3.69 | $1,075 | 1 ct, trail=12 |
| 2026-03-27 | Mar 2025Mar 2026 | 148 | 51% | 3.15 | $71,303 | 9 cts (experimental) |
The 9-contract run used `RiskPerTrade=$500` — not a production configuration. Runner leg was also blocked (`EntriesPerDirection=1`) for that run. Re-run required after Sprint 2 fixes.
---
## 8. Immediate Next Actions Before Market Open
1. Run Strategy Analyzer (NQ JUN26, Jan 1 2026 → Mar 27 2026) and confirm `PNL_UPDATE Position=Short Qty=2` in session log — validates runner leg
2. Verify SIM account settings: `RiskPerTrade=$100`, `BreakevenTriggerTicks=20`, `RunnerTrailTicks=20`
3. Only re-enable BX68915-15 after runner validation passes — long-only, `MaxContracts=2`, `DailyLossLimit=$500`
---