Files
nt8-sdk/docs/archive/phase-specs/PHASE_A_READY_FOR_KILOCODE.md
mo c9041df36a Sprint 3: Production Hardening — 9 tasks completed
## Summary
Implemented 9 production-hardening tasks across risk, execution, calendar, and governance.
All changes verified: build clean (0 errors), 492 tests passing (404 core + 78 integration + 10 perf).

## Core Changes

### Risk & Portfolio (3 tasks)
- **GAP-019** Portfolio Heat Tier 3.5: Added MaxHeatPct (default 3%) to AdvancedRiskConfig;
  ValidatePortfolioHeat() computes TotalOpenRisk + NewTradeRisk / Equity * 100; rejects when exceeded.
- **GAP-003** RiskPerTrade <= MaxTradeRisk Assertion: RiskPerTrade property in RiskConfig; throws
  ArgumentException at ValidateOrder() if RiskPerTrade > MaxTradeRisk; 3 unit tests.
- **GAP-005** GetRiskStatus() Live Config: _currentDailyLossLimit field updated from config.DailyLossLimit
  on each ValidateOrder(); GetRiskStatus() returns actual value; 3 unit tests.

### Execution & Position Management (3 tasks)
- **TASK-06a** Runner Mode Architecture: RunnerMode enum (Auto/Mode1DualLeg/Mode2RunnerOnly/
  Mode3ScalerOnly/Disabled); ResolveRunnerMode() logic; 4-mode SubmitOrderToNT8() behavior.
- **TASK-06b** ATR Dynamic Stop: EnableDynamicStop, AtrPeriod, AtrMultiplier, MinStopTicks, MaxStopTicks;
  computes dynStop = clamp(round(ATR/TickSize * Mult), Min, Max); overrides intent.StopTicks.
- **GAP-006** Position-Close Re-arm: OnPositionUpdate() sends clear_trade_taken when flat;
  EnableBarBasedRearm parameter gates legacy bar-driven re-arm (default false for live).

### Strategy Intelligence (2 tasks)
- **GAP-004** orbRangeTicks Fix: DailyBarContext.OrbRangeTicks field; computed from actual ORB
  high/low / TickSize; passed to Factor 7 (ORBvsATR).
- **GAP-010** Short-Side Regime Filter: EnableShortTrendFilter param; vetoes shorts when
  AVWAP slope > 0 (bullish); configurable, default true.

### Calendar & Trailing (2 tasks)
- **GAP-008** CME Holiday Awareness: NEW CmeHolidayCalendar.cs with 9 observed holidays +
  Good Friday (Easter calc); EnableCMEHolidayGuard skips ORB window on holidays.
- **GAP-009** ATR Trailing Real ATR: EnableATRTrailing, ATRTrailingPeriod (14), ATRTrailingMultiplier (2.0),
  ATRTrailingMinTicks (8), ATRTrailingMaxTicks (60); computes trailTicks from ATR(Close,Period)[0].

## Governance
- SPRINT_BOARD.md, current_status.md, decisions.md (DEC-20260711-01 through -09), NEXT_PROMPT.md updated
- All 9 tasks moved ACTIVE -> COMPLETED; GAP-011 (Gitea CI) now ACTIVE

## Verification
- verify-build.bat: 0 errors, 0 warnings
- Tests: 492 passing (404 core + 78 integration + 10 performance)

## Files
- Modified: 13 source, 3 test, 9 governance
- Deleted: 28 obsolete spec/docs
- Added: 1 new module (NT8.Core.Calendar), governance files
- Dual-deployed to NT8 Custom\Strategies\

## Rollback
Tag: sprint3-production-hardening-complete
To revert: git reset --hard sprint3-production-hardening-complete
2026-07-13 08:38:25 -04:00

5.8 KiB

NT8 Integration - Phase A Ready for Kilocode

Date: February 17, 2026
Status: ✅ Specifications Complete, Ready for Handoff
Agent: Kilocode (Code Mode)
Estimated Time: 4-5 hours


📋 What's Ready

I've created detailed specification documents for Kilocode to execute Phase A autonomously:

Primary Specification

File: C:\dev\nt8-sdk\PHASE_A_SPECIFICATION.md

Contents:

  1. Task 1: NT8 Data Adapter Unit Tests (2 hours)

    • 27 comprehensive unit tests for NT8DataConverter
    • Covers all conversion methods (Bar, Account, Position, Session, Context)
    • 95% code coverage target

  2. Task 2: NT8ExecutionAdapter Implementation (2-3 hours)

    • Complete adapter for order submission to NT8
    • Thread-safe order tracking
    • NT8 callback processing (order updates, executions)
    • 15 comprehensive unit tests
    • 90% code coverage target

Total Deliverables: 42 new tests + 1 new adapter class


🎯 Phase A Objectives

What Phase A Accomplishes

Foundation for NT8 Integration:

  • ✅ Validates existing data conversion logic with comprehensive tests
  • ✅ Creates order execution adapter that bridges SDK ↔ NT8
  • ✅ Establishes thread-safe order state tracking
  • ✅ Handles NT8 callbacks (OnOrderUpdate, OnExecutionUpdate)
  • ✅ Maps NT8 order states to SDK OrderState enum

Why Phase A is Critical:

  • These adapters are used by Phase B (NT8StrategyBase)
  • Must be rock-solid before building strategy layer
  • Thread safety is essential for NT8's multi-threaded callbacks
  • Test coverage gives confidence in conversion logic

📦 Deliverables

Files Kilocode Will Create

  1. tests/NT8.Core.Tests/Adapters/NT8DataConverterTests.cs

    • 27 unit tests
    • Tests all conversion methods
    • Validates error handling
  2. src/NT8.Adapters/NinjaTrader/NT8ExecutionAdapter.cs

    • Order submission tracking
    • NT8 callback processing
    • Thread-safe state management
    • ~300-400 lines of code
  3. tests/NT8.Core.Tests/Adapters/NT8ExecutionAdapterTests.cs

    • 15 unit tests
    • Thread safety validation
    • Order lifecycle testing

✅ Success Criteria

Phase A is complete when:

  • All 42 new tests passing
  • All existing 240+ tests still passing
  • Zero build warnings
  • Code coverage: >95% DataConverter, >90% ExecutionAdapter
  • Thread safety verified
  • C# 5.0 compliant (no modern syntax)
  • Committed to Git with clear message

🔄 Next Steps (After Phase A)

Once Phase A is complete, we move to:

Phase B: NT8StrategyBase (4-5 hours)

  • Inherit from NinjaTrader.NinjaScript.Strategies.Strategy
  • Implement NT8 lifecycle (OnStateChange, OnBarUpdate, etc.)
  • Bridge NT8 events to SDK components
  • Create SimpleORBNT8 concrete strategy

Phase C: Deployment & Testing (3-4 hours)

  • Create deployment automation script
  • Deploy to NT8 and compile
  • Run integration tests in simulation
  • Validate risk controls

📝 Kilocode Instructions

How to Execute

Mode: Code Mode (detailed implementation from specification)

Command for Kilocode:

Implement Phase A per detailed specification in PHASE_A_SPECIFICATION.md

Requirements:
- Follow specification exactly
- C# 5.0 syntax only (no modern features)
- Thread-safe with lock protection
- Comprehensive XML documentation
- All tests must pass
- Zero build warnings

Deliverables:
1. NT8DataConverterTests.cs (27 tests)
2. NT8ExecutionAdapter.cs (implementation)
3. NT8ExecutionAdapterTests.cs (15 tests)

Success criteria:
- 42 tests passing
- 240+ existing tests still passing
- >90% coverage
- Committed to Git

Files Kilocode Needs

Specification:

  • C:\dev\nt8-sdk\PHASE_A_SPECIFICATION.md (detailed requirements)

Existing Code to Reference:

  • src/NT8.Adapters/NinjaTrader/NT8DataConverter.cs (code being tested)
  • src/NT8.Adapters/NinjaTrader/NT8DataAdapter.cs (wrapper around converter)
  • src/NT8.Core/OMS/OrderModels.cs (OrderRequest, OrderStatus, OrderState)
  • tests/NT8.Core.Tests/ (existing test patterns)

Build Tools:

  • verify-build.bat (build verification)
  • dotnet build (compilation)
  • dotnet test (test execution)

🚨 Key Constraints for Kilocode

  1. C# 5.0 Only

    • ❌ No async/await
    • ❌ No $"string interpolation"
    • ❌ No => expression bodies
    • ✅ Use string.Format()
    • ✅ Use traditional methods
  2. Thread Safety

    • ✅ All shared state protected with lock (_lock)
    • ✅ Lock scope minimized
    • ✅ No blocking operations inside locks
  3. Error Handling

    • ✅ Validate all inputs
    • ✅ Throw appropriate exceptions
    • ✅ Add error messages with context
  4. Documentation

    • ✅ XML comments on all public members
    • ✅ Clear parameter descriptions
    • ✅ Exception documentation
  5. Testing

    • ✅ Use xUnit + FluentAssertions
    • ✅ Follow AAA pattern (Arrange, Act, Assert)
    • ✅ Clear test names
    • ✅ Test both happy and error paths

📊 Estimated Timeline

Task 1: NT8 Data Adapter Tests → 2 hours
Task 2: NT8ExecutionAdapter Implementation → 2 hours
Task 3: NT8ExecutionAdapter Tests → 1 hour
Total: 4-5 hours


✅ Approval Checklist

Before handing to Kilocode, verify:

  • PHASE_A_SPECIFICATION.md is complete and detailed
  • All requirements are clear and testable
  • Success criteria are well-defined
  • Constraints are documented
  • Existing code references are provided
  • Git commit instructions are clear

🎯 Ready for Handoff

Status: ✅ READY

To proceed:

  1. Review PHASE_A_SPECIFICATION.md
  2. Approve specification
  3. Launch Kilocode in Code Mode
  4. Provide specification file path
  5. Monitor progress
  6. Verify deliverables against success criteria

All documentation is complete. Ready to hand off to Kilocode for autonomous execution. 🚀