3.9 KiB
Project Context — NT8 SDK (Production Hardening Phase)
You are working on the NT8 SDK — an institutional-grade algorithmic trading framework for NinjaTrader 8. This is production trading software. Bugs cause real financial losses.
What Is Already Built (Do Not Touch)
All core trading logic is complete and has 240+ passing tests:
| Layer | Status | Key Files |
|---|---|---|
| Risk (Tier 1-3) | ✅ Complete | src/NT8.Core/Risk/ |
| Position Sizing | ✅ Complete | src/NT8.Core/Sizing/ |
| OMS / Order Lifecycle | ✅ Complete | src/NT8.Core/OMS/ |
| Intelligence | ✅ Complete | src/NT8.Core/Intelligence/ |
| Analytics | ✅ Complete | src/NT8.Core/Analytics/ |
| Execution Utilities | ✅ Complete | src/NT8.Core/Execution/ |
| Market Data | ✅ Complete | src/NT8.Core/MarketData/ |
NT8 Order Execution is ALREADY WIRED.
NT8StrategyBase.SubmitOrderToNT8() calls EnterLong, EnterShort, SetStopLoss, and
SetProfitTarget directly. The execution path works end-to-end. Do not re-implement it.
What You Are Fixing (The Active Task List)
CRITICAL — NT8StrategyBase.cs
Gap 1 — No kill switch
NT8StrategyBase has no EnableKillSwitch NinjaScript parameter and no early-exit in OnBarUpdate().
A runaway strategy cannot be stopped without killing NinjaTrader.
Fix: Add EnableKillSwitch (bool NinjaScript property) and EnableVerboseLogging property.
Add kill switch check as the FIRST thing in OnBarUpdate().
→ See TASK-01-kill-switch.md
Gap 2 — ExecutionCircuitBreaker not wired
src/NT8.Core/Execution/ExecutionCircuitBreaker.cs is complete and tested.
It is never instantiated. Orders submit regardless of latency or rejection conditions.
Fix: Instantiate in InitializeSdkComponents(), gate orders in SubmitOrderToNT8(), wire rejections in OnOrderUpdate().
→ See TASK-02-circuit-breaker.md
HIGH — TrailingStopManager.cs
Gap 3 — Placeholder stop math returns zero
CalculateNewStopPrice() FixedTrailing branch: marketPrice - (x - x) = always zero movement.
ATRTrailing and Chandelier also have meaningless placeholder formulas.
Fix: Replace with real calculations using TrailingStopConfig.TrailingAmountTicks and AtrMultiplier.
→ See TASK-03-trailing-stop.md
HIGH — BasicLogger.cs
Gap 4 — No log-level filter
Every log statement writes to console unconditionally. Cannot suppress debug noise in production.
Fix: Add MinimumLevel property (defaults to Information). Suppress messages below threshold.
→ See TASK-04-log-level.md
MEDIUM — SessionManager.cs
Gap 5 — No holiday awareness
IsRegularTradingHours() checks session times only. Will attempt to trade on Christmas, Thanksgiving, etc.
Fix: Add static CME holiday set for 2025/2026. Return false on those dates.
→ See TASK-05-session-holidays.md
Architecture (Read Before Touching Anything)
SimpleORBStrategy.OnBar()
↓ returns StrategyIntent
NT8StrategyBase.OnBarUpdate()
↓ [TASK-01: kill switch check here, first]
↓ calls ProcessStrategyIntent()
↓ calls _riskManager.ValidateOrder()
↓ calls _positionSizer.CalculateSize()
↓ calls SubmitOrderToNT8()
↓ [TASK-02: circuit breaker gate here]
↓ calls EnterLong/EnterShort/SetStopLoss/SetProfitTarget (already works)
NT8 callbacks → OnOrderUpdate / OnExecutionUpdate
↓ [TASK-02: record rejections in circuit breaker here]
Technology Constraints
- C# 5.0 only — no
$"", no?., no=>on methods/properties, nonameof(), noout var - .NET Framework 4.8 — not .NET Core/5+/6+
- NinjaScript managed orders —
EnterLong,EnterShort,SetStopLoss,SetProfitTarget string.Format()everywhere, never string interpolation- All
Dictionary,HashSetaccess insidelock (_lock)blocks - XML doc comments on all public members
try/catchon all public methods withLogErrorin the catch