## 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
151 lines
4.4 KiB
Markdown
151 lines
4.4 KiB
Markdown
# NT8 Strategy Dropdown Complete Fix
|
|
|
|
**For:** Kilocode AI Agent
|
|
**Priority:** URGENT
|
|
**Mode:** Code Mode
|
|
**Estimated Time:** 15-20 minutes
|
|
**Files to Edit:** 2 files
|
|
|
|
---
|
|
|
|
## 🎯 Objective
|
|
|
|
Fix two issues preventing SimpleORBNT8 from appearing in NT8 strategy dropdown:
|
|
1. NT8StrategyBase (abstract) incorrectly appears in dropdown
|
|
2. SimpleORBNT8 has runtime error preventing it from loading
|
|
|
|
---
|
|
|
|
## 🔧 Fix 1: NT8StrategyBase.cs - Remove Name from abstract class
|
|
|
|
### File
|
|
`src/NT8.Adapters/Strategies/NT8StrategyBase.cs`
|
|
|
|
### Problem
|
|
Abstract base class sets `Name = "NT8 SDK Strategy Base"` which makes it
|
|
appear in the strategy dropdown. Abstract strategies should NOT have a Name.
|
|
|
|
### Change: Remove or comment out Name assignment
|
|
|
|
**Find (around line 97):**
|
|
```csharp
|
|
protected override void OnStateChange()
|
|
{
|
|
if (State == State.SetDefaults)
|
|
{
|
|
Description = "SDK-integrated strategy base";
|
|
Name = "NT8 SDK Strategy Base";
|
|
Calculate = Calculate.OnBarClose;
|
|
```
|
|
|
|
**Replace with:**
|
|
```csharp
|
|
protected override void OnStateChange()
|
|
{
|
|
if (State == State.SetDefaults)
|
|
{
|
|
Description = "SDK-integrated strategy base";
|
|
// Name intentionally not set - this is an abstract base class
|
|
Calculate = Calculate.OnBarClose;
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 Fix 2: SimpleORBNT8.cs - Guard Instrument null access
|
|
|
|
### File
|
|
`src/NT8.Adapters/Strategies/SimpleORBNT8.cs`
|
|
|
|
### Problem
|
|
`ConfigureStrategyParameters()` accesses `Instrument.MasterInstrument` which is
|
|
null when NT8 loads the strategy for the dropdown list, causing a runtime
|
|
exception that removes it from available strategies.
|
|
|
|
### Change: Add null guard
|
|
|
|
**Find:**
|
|
```csharp
|
|
protected override void ConfigureStrategyParameters()
|
|
{
|
|
_strategyConfig.RiskSettings.DailyLossLimit = DailyLossLimit;
|
|
_strategyConfig.RiskSettings.MaxTradeRisk = MaxTradeRisk;
|
|
_strategyConfig.RiskSettings.MaxOpenPositions = MaxOpenPositions;
|
|
|
|
var pointValue = Instrument.MasterInstrument.PointValue;
|
|
var tickSize = Instrument.MasterInstrument.TickSize;
|
|
var dollarRisk = StopTicks * tickSize * pointValue;
|
|
|
|
if (dollarRisk > _strategyConfig.RiskSettings.MaxTradeRisk)
|
|
_strategyConfig.RiskSettings.MaxTradeRisk = dollarRisk;
|
|
|
|
_strategyConfig.SizingSettings.RiskPerTrade = RiskPerTrade;
|
|
```
|
|
|
|
**Replace with:**
|
|
```csharp
|
|
protected override void ConfigureStrategyParameters()
|
|
{
|
|
_strategyConfig.RiskSettings.DailyLossLimit = DailyLossLimit;
|
|
_strategyConfig.RiskSettings.MaxTradeRisk = MaxTradeRisk;
|
|
_strategyConfig.RiskSettings.MaxOpenPositions = MaxOpenPositions;
|
|
|
|
// Guard: Instrument is null during strategy list loading
|
|
if (Instrument != null && Instrument.MasterInstrument != null)
|
|
{
|
|
var pointValue = Instrument.MasterInstrument.PointValue;
|
|
var tickSize = Instrument.MasterInstrument.TickSize;
|
|
var dollarRisk = StopTicks * tickSize * pointValue;
|
|
|
|
if (dollarRisk > _strategyConfig.RiskSettings.MaxTradeRisk)
|
|
_strategyConfig.RiskSettings.MaxTradeRisk = dollarRisk;
|
|
}
|
|
|
|
_strategyConfig.SizingSettings.RiskPerTrade = RiskPerTrade;
|
|
```
|
|
|
|
---
|
|
|
|
## ✅ Verification
|
|
|
|
```bash
|
|
# Build must succeed
|
|
dotnet build src\NT8.Adapters\NT8.Adapters.csproj --configuration Release
|
|
|
|
# Redeploy
|
|
.\deployment\Deploy-To-NT8.ps1
|
|
```
|
|
|
|
**In NT8 after recompile:**
|
|
- [ ] "NT8 SDK Strategy Base" NO LONGER appears in dropdown
|
|
- [ ] "Simple ORB NT8" DOES appear in dropdown
|
|
- [ ] "Minimal Test" still appears (if compiled)
|
|
|
|
---
|
|
|
|
## 🚨 Constraints
|
|
|
|
- Two surgical edits only
|
|
- C# 5.0 syntax
|
|
- Do NOT change other logic
|
|
- All tests must pass
|
|
|
|
---
|
|
|
|
## 📋 Git Commit
|
|
|
|
```bash
|
|
git add src/NT8.Adapters/Strategies/NT8StrategyBase.cs
|
|
git add src/NT8.Adapters/Strategies/SimpleORBNT8.cs
|
|
git commit -m "fix: Make abstract base invisible, guard Instrument access
|
|
|
|
- Remove Name from NT8StrategyBase (abstract shouldn't appear in dropdown)
|
|
- Add null guard for Instrument access in ConfigureStrategyParameters
|
|
- Prevents runtime error when NT8 loads strategy list
|
|
|
|
Fixes: SimpleORBNT8 now appears in strategy dropdown"
|
|
```
|
|
|
|
---
|
|
|
|
**READY FOR KILOCODE - CODE MODE** ✅
|