Production hardening: kill switch, circuit breaker, trailing stops, log level, holiday calendar
Some checks failed
Build and Test / build (push) Has been cancelled
Some checks failed
Build and Test / build (push) Has been cancelled
This commit is contained in:
150
STRATEGY_DROPDOWN_COMPLETE_FIX.md
Normal file
150
STRATEGY_DROPDOWN_COMPLETE_FIX.md
Normal file
@@ -0,0 +1,150 @@
|
||||
# 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** ✅
|
||||
Reference in New Issue
Block a user