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
This commit is contained in:
@@ -1,390 +1,538 @@
|
||||
# NT8 SDK — Kilocode Runbook
|
||||
## Production Hardening: 5 Tasks, ~4 Hours Total
|
||||
# NT8-SDK Kilocode Runbook — Sprint 3
|
||||
**Updated:** 2026-05-04 | Contains: all Sprint 3 task prompts in execution order.
|
||||
**How to use:** Current task prompt is always staged in `NEXT_PROMPT.md`. Find the next task here by ID.
|
||||
|
||||
This runbook tells you exactly what to say to Kilocode for each task, in which order, and how to verify before moving on.
|
||||
> **Pre-flight (do once before starting Sprint 3):**
|
||||
> 1. `Ctrl+Shift+B` → expect `✅ All checks passed!`
|
||||
> 2. `dotnet test tests/NT8.Core.Tests/NT8.Core.Tests.csproj --verbosity minimal` → 240+ passing
|
||||
> If either fails — fix the baseline first. Do not start until both are clean.
|
||||
|
||||
---
|
||||
|
||||
## Pre-Flight Checklist (Do This Once Before Starting)
|
||||
## TASK-06a — Runner Mode Architecture
|
||||
|
||||
**1. Open VS Code in the right folder**
|
||||
```
|
||||
File → Open Folder → C:\dev\nt8-sdk
|
||||
```
|
||||
**Why:** The current `useRunner = Qty >= 2` check is architecturally wrong. It couples position management to capital sizing and means the runner NEVER fires at responsible ATR-based stops. Runner should be a position management MODE, not a quantity gate.
|
||||
|
||||
**2. Verify Kilocode rules are loaded**
|
||||
- Click the ⚖️ (law) icon in the Kilocode panel bottom-right
|
||||
- You should see these 5 rules listed and enabled:
|
||||
- `csharp_50_syntax.md`
|
||||
- `coding_patterns.md`
|
||||
- `file_boundaries.md`
|
||||
- `verification_requirements.md`
|
||||
- `project_context.md`
|
||||
- If not showing: `Ctrl+Shift+P` → "Kilocode: Reload Rules"
|
||||
|
||||
**3. Confirm baseline build passes**
|
||||
```
|
||||
Ctrl+Shift+B
|
||||
```
|
||||
Expected output: ✅ All checks passed! (zero errors, zero warnings)
|
||||
|
||||
**4. Confirm baseline tests pass**
|
||||
```
|
||||
Ctrl+Shift+P → Run Task → test-all
|
||||
```
|
||||
Expected: 240+ tests passed, 0 failed
|
||||
|
||||
If either fails — **do not start** — fix the baseline first.
|
||||
**Spec reference:** NT8_SDK_Master_Document_v6_Final.docx — Section 6.1
|
||||
|
||||
---
|
||||
|
||||
## Task Order
|
||||
|
||||
```
|
||||
TASK-01 Kill Switch + Verbose Logging [CRITICAL, ~45 min] no deps
|
||||
TASK-02 Wire Circuit Breaker [CRITICAL, ~45 min] after TASK-01
|
||||
TASK-03 Fix TrailingStop Math [HIGH, ~60 min] no deps
|
||||
TASK-04 BasicLogger Level Filter [HIGH, ~20 min] no deps
|
||||
TASK-05 Session Holiday Awareness [MEDIUM, ~30 min] no deps
|
||||
```
|
||||
Read docs/00-governance/active_work.md and .kilocode/rules/project_context.md before starting.
|
||||
|
||||
Tasks 03, 04, 05 can run in parallel with or after 01/02 — they touch different files.
|
||||
Implement TASK-06a: Runner Mode Architecture redesign in NT8StrategyBase.
|
||||
|
||||
WHAT TO BUILD:
|
||||
1. Add a RunnerMode enum to the appropriate models file in src/NT8.Core/Common/ or src/NT8.Core/Risk/:
|
||||
public enum RunnerMode { Auto, Mode1DualLeg, Mode2RunnerOnly, Mode3ScalerOnly, Disabled }
|
||||
C# 5.0: no expression-bodied members, no $"" string interpolation, no ?. operator.
|
||||
|
||||
2. In NT8StrategyBase.cs (src/NT8.Adapters/Strategies/NT8StrategyBase.cs):
|
||||
a. Add [NinjaScriptProperty] public RunnerMode RunnerActivationMode with default = RunnerMode.Auto
|
||||
b. Add private method: private RunnerMode ResolveRunnerMode(RunnerMode configured, int qty)
|
||||
Logic:
|
||||
if (configured == RunnerMode.Disabled) return RunnerMode.Disabled;
|
||||
if (configured == RunnerMode.Mode1DualLeg) return RunnerMode.Mode1DualLeg;
|
||||
if (configured == RunnerMode.Mode2RunnerOnly) return RunnerMode.Mode2RunnerOnly;
|
||||
if (configured == RunnerMode.Mode3ScalerOnly) return RunnerMode.Mode3ScalerOnly;
|
||||
// Auto: resolve based on qty
|
||||
if (qty >= 2) return RunnerMode.Mode1DualLeg;
|
||||
return RunnerMode.Mode2RunnerOnly;
|
||||
c. In SubmitOrderToNT8() (or wherever entry/stop/target logic lives), REPLACE:
|
||||
bool useRunner = EnableRunner && request.Quantity >= 2;
|
||||
WITH:
|
||||
RunnerMode resolvedMode = ResolveRunnerMode(RunnerActivationMode, request.Quantity);
|
||||
d. Implement mode behaviour:
|
||||
- Mode1DualLeg: scalerQty = request.Quantity - 1, runnerQty = 1
|
||||
SetStopLoss(scalerSignal), SetProfitTarget(scalerSignal, TargetTicks), EnterLong(scalerQty, scalerSignal)
|
||||
SetTrailStop(runnerSignal, CalculationMode.Ticks, RunnerTrailTicks, false), EnterLong(1, runnerSignal)
|
||||
- Mode2RunnerOnly: full qty gets trail stop only, no fixed target
|
||||
SetTrailStop(runnerSignal, CalculationMode.Ticks, RunnerTrailTicks, false), EnterLong(qty, runnerSignal)
|
||||
- Mode3ScalerOnly: full qty gets fixed target, no runner
|
||||
SetStopLoss(scalerSignal), SetProfitTarget(scalerSignal, TargetTicks), EnterLong(qty, scalerSignal)
|
||||
- Disabled: original single-leg behaviour, no runner
|
||||
e. Log the resolved mode: Print(string.Format("[SDK] Runner mode resolved: {0} (Qty={1})", resolvedMode, request.Quantity));
|
||||
|
||||
3. DUAL-DEPLOY: copy the updated NT8StrategyBase.cs to:
|
||||
C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\NT8StrategyBase.cs
|
||||
|
||||
CONSTRAINTS:
|
||||
- C# 5.0 only: string.Format() not $"", explicit null checks not ?., full block syntax not =>
|
||||
- Do NOT change constructor, InitializeSdkComponents(), or any risk/sizing logic
|
||||
- Do NOT modify any test files unless adding new tests for RunnerMode
|
||||
- SetStopLoss/SetProfitTarget MUST be called before EnterLong/EnterShort on every branch
|
||||
|
||||
VERIFICATION:
|
||||
- .\verify-build.bat must show ✅ All checks passed!
|
||||
- dotnet test must pass with 0 failures
|
||||
- Tell me exactly what lines you changed and in which files
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md completely (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## TASK-01 — Kill Switch + Verbose Logging
|
||||
## TASK-06b — ATR Dynamic Stop
|
||||
|
||||
**File being modified:** `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`
|
||||
**Spec file:** `TASK-01-kill-switch.md`
|
||||
**Why:** Fixed 8-tick stop on NQ ignores market volatility. ATR=20 ticks means 8 ticks gets stopped out by normal noise before the move develops. Dynamic stop sizes the stop to actual market conditions.
|
||||
|
||||
### Kilocode Prompt
|
||||
|
||||
Paste this into Kilocode chat verbatim:
|
||||
|
||||
```
|
||||
Please implement TASK-01 from TASK-01-kill-switch.md
|
||||
|
||||
Summary of what you need to do:
|
||||
1. Add two NinjaScript properties to NT8StrategyBase: EnableKillSwitch (bool) and EnableVerboseLogging (bool)
|
||||
2. Add private field: _killSwitchTriggered
|
||||
3. Set defaults in OnStateChange → State.SetDefaults
|
||||
4. Add kill switch check as the VERY FIRST thing in OnBarUpdate() — before all other guards
|
||||
5. Wrap Print calls inside ProcessStrategyIntent() with `if (EnableVerboseLogging)`
|
||||
|
||||
Important constraints:
|
||||
- C# 5.0 only — use string.Format(), not $""
|
||||
- Do NOT use ?. null conditional operator
|
||||
- Do NOT change constructor, InitializeSdkComponents(), or SubmitOrderToNT8()
|
||||
- After every file change, run verify-build.bat mentally (I will run it to verify)
|
||||
|
||||
When done, tell me exactly what lines you added/changed and confirm the acceptance criteria from the task file are met.
|
||||
```
|
||||
|
||||
### After Kilocode Responds
|
||||
|
||||
1. **Review the diff** — confirm:
|
||||
- `EnableKillSwitch` and `EnableVerboseLogging` are `[NinjaScriptProperty]` decorated
|
||||
- Kill switch check is the FIRST thing in `OnBarUpdate()` before `_sdkInitialized` check
|
||||
- No `$""` string interpolation introduced
|
||||
- No other files were modified
|
||||
|
||||
2. **Run verify-build:**
|
||||
```
|
||||
Ctrl+Shift+B
|
||||
```
|
||||
✅ Must pass before proceeding
|
||||
|
||||
3. **If verify-build fails:** Paste the error output back to Kilocode:
|
||||
```
|
||||
verify-build.bat failed with these errors:
|
||||
[paste errors]
|
||||
Please fix them. Remember C# 5.0 only — no string interpolation, no ?. operator.
|
||||
```
|
||||
|
||||
4. **Run tests:**
|
||||
```
|
||||
Ctrl+Shift+P → Run Task → test-all
|
||||
```
|
||||
✅ All 240+ tests must still pass
|
||||
**Spec reference:** NT8_SDK_Master_Document_v6_Final.docx — Section 6.2
|
||||
|
||||
---
|
||||
|
||||
## TASK-02 — Wire ExecutionCircuitBreaker
|
||||
|
||||
**File being modified:** `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`
|
||||
**Spec file:** `TASK-02-circuit-breaker.md`
|
||||
**Depends on:** TASK-01 must be complete
|
||||
|
||||
### Kilocode Prompt
|
||||
|
||||
```
|
||||
TASK-01 is complete. Now please implement TASK-02 from TASK-02-circuit-breaker.md
|
||||
Read docs/00-governance/active_work.md and SPRINT_BOARD.md before starting.
|
||||
|
||||
Summary:
|
||||
1. Add using statements: NT8.Core.Execution and Microsoft.Extensions.Logging.Abstractions
|
||||
2. Add private field: _circuitBreaker (type ExecutionCircuitBreaker)
|
||||
3. Instantiate in InitializeSdkComponents() after _positionSizer is created:
|
||||
_circuitBreaker = new ExecutionCircuitBreaker(NullLogger<ExecutionCircuitBreaker>.Instance, failureThreshold: 3, timeout: TimeSpan.FromSeconds(30));
|
||||
4. Add circuit breaker gate at the TOP of SubmitOrderToNT8() — if ShouldAllowOrder() returns false, Print a message and return
|
||||
5. After successful submission, call _circuitBreaker.OnSuccess()
|
||||
6. In the catch block, call _circuitBreaker.OnFailure()
|
||||
7. In OnOrderUpdate(), when orderState == OrderState.Rejected, call _circuitBreaker.RecordOrderRejection(reason)
|
||||
Implement TASK-06b: ATR-based dynamic stop in NT8StrategyBase and SimpleORBNT8.
|
||||
|
||||
Constraints:
|
||||
WHAT TO BUILD:
|
||||
1. In NT8StrategyBase.cs (src/NT8.Adapters/Strategies/NT8StrategyBase.cs):
|
||||
a. Add these [NinjaScriptProperty] parameters:
|
||||
- public bool EnableDynamicStop (default = false)
|
||||
- public int AtrPeriod (default = 14)
|
||||
- public double AtrMultiplier (default = 1.5)
|
||||
- public int MinStopTicks (default = 12)
|
||||
- public int MaxStopTicks (default = 50)
|
||||
b. In OnStateChange() → State.Configure: register ATR indicator series:
|
||||
AddDataSeries(Data.BarsPeriodType.Minute, 5); // only if not already present
|
||||
// ATR is accessed via ATR(Close, AtrPeriod)[0] in NinjaScript
|
||||
c. In SubmitOrderToNT8() or the intent processing method, BEFORE calling CalculateSize():
|
||||
if (EnableDynamicStop && CurrentBars[0] >= AtrPeriod)
|
||||
{
|
||||
double atrValue = ATR(Close, AtrPeriod)[0];
|
||||
int dynStop = (int)System.Math.Round(atrValue / TickSize * AtrMultiplier);
|
||||
dynStop = System.Math.Max(MinStopTicks, System.Math.Min(MaxStopTicks, dynStop));
|
||||
intent.StopTicks = dynStop;
|
||||
// Recalculate target if using fixed R:R ratio (TargetTicks = StopTicks * RRRatio)
|
||||
// Pass ATR to context for Factor 3 and TrailingStopManager:
|
||||
// context.CustomData["current_atr"] = atrValue / TickSize; // in ticks
|
||||
}
|
||||
d. Log: Print(string.Format("[SDK] Dynamic stop: ATR={0:F1}t x {1} = {2}t (${3})",
|
||||
atrValue/TickSize, AtrMultiplier, intent.StopTicks, intent.StopTicks * 5));
|
||||
|
||||
2. In SimpleORBNT8.cs (src/NT8.Adapters/Strategies/SimpleORBNT8.cs):
|
||||
- Verify EnableDynamicStop is exposed as a parameter (it inherits from NT8StrategyBase, so likely automatic)
|
||||
- If it needs to be explicitly exposed, add it to the NinjaScript parameter block
|
||||
|
||||
3. DUAL-DEPLOY both files to C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\
|
||||
|
||||
CONSTRAINTS:
|
||||
- C# 5.0 only
|
||||
- Do NOT modify ExecutionCircuitBreaker.cs — it is already correct
|
||||
- Do NOT modify any Core layer files
|
||||
- Do NOT modify any test files
|
||||
- Do NOT change RiskConfig, SizingConfig, or any test files
|
||||
- If ATR series is not available yet (CurrentBars[0] < AtrPeriod), skip dynamic stop and use intent.StopTicks as-is
|
||||
|
||||
When done, confirm all acceptance criteria from TASK-02-circuit-breaker.md are met.
|
||||
VERIFICATION:
|
||||
- .\verify-build.bat must show ✅ All checks passed!
|
||||
- dotnet test must pass with 0 failures
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md completely (all 6 steps).
|
||||
```
|
||||
|
||||
### Verification
|
||||
|
||||
1. **Check the diff:**
|
||||
- `_circuitBreaker` field exists
|
||||
- `SubmitOrderToNT8()` has the `ShouldAllowOrder()` gate at the top
|
||||
- `OnOrderUpdate()` calls `RecordOrderRejection()` on rejected state
|
||||
- `ExecutionCircuitBreaker.cs` was NOT touched
|
||||
|
||||
2. ```
|
||||
Ctrl+Shift+B
|
||||
```
|
||||
✅ Must pass
|
||||
|
||||
3. ```
|
||||
Ctrl+Shift+P → Run Task → test-all
|
||||
```
|
||||
✅ 240+ tests must pass
|
||||
|
||||
---
|
||||
|
||||
## TASK-03 — Fix TrailingStop Placeholder Math
|
||||
## GAP-019 — Portfolio Heat Tier 3.5
|
||||
|
||||
**File being modified:** `src/NT8.Core/Execution/TrailingStopManager.cs`
|
||||
**Spec file:** `TASK-03-trailing-stop.md`
|
||||
**No dependencies**
|
||||
**Why:** Without a heat limit, three open positions can each risk 2% of account simultaneously = 6% aggregate. Heat caps total open risk as a % of account balance. Reference: Section 3.2 of master doc.
|
||||
|
||||
### Kilocode Prompt
|
||||
---
|
||||
|
||||
```
|
||||
Please implement TASK-03 from TASK-03-trailing-stop.md
|
||||
Read docs/00-governance/active_work.md and SPRINT_BOARD.md before starting.
|
||||
|
||||
Summary:
|
||||
1. Open src/NT8.Core/Execution/TrailingStopManager.cs
|
||||
2. Find CalculateNewStopPrice() — it currently has broken/placeholder math
|
||||
3. Update the signature to add a TrailingStopConfig config parameter
|
||||
4. Replace the switch body with real calculations:
|
||||
- FixedTrailing: marketPrice ± (config.TrailingAmountTicks * 0.25m)
|
||||
- ATRTrailing: marketPrice ± (config.AtrMultiplier * estimatedAtr) where estimatedAtr = position.AverageFillPrice * 0.005m
|
||||
- Chandelier: same formula as ATRTrailing but default multiplier 3.0
|
||||
- Use position.Side to determine + vs - (Buy = subtract from price, Sell = add to price)
|
||||
5. Fix the ONE call site inside UpdateTrailingStop() to pass trailingStop.Config
|
||||
6. Create tests/NT8.Core.Tests/Execution/TrailingStopManagerFixedTests.cs with unit tests verifying:
|
||||
- Long FixedTrailing 8 ticks at price 5100 → stop = 5098.0
|
||||
- Short FixedTrailing 8 ticks at price 5100 → stop = 5102.0
|
||||
Implement GAP-019: Portfolio Heat — Tier 3.5 risk layer in AdvancedRiskManager.
|
||||
|
||||
Constraints:
|
||||
WHAT TO BUILD:
|
||||
1. In the appropriate RiskModels or RiskConfig class (src/NT8.Core/Risk/):
|
||||
- Add MaxHeatPct property (double, default = 3.0) to RiskConfig or AdvancedRiskConfig
|
||||
- Add AccountBalance property (double) to whatever context object is passed to risk validation
|
||||
|
||||
2. In AdvancedRiskManager.cs (src/NT8.Core/Risk/AdvancedRiskManager.cs):
|
||||
a. Add private method ValidatePortfolioHeat(OrderIntent intent, double accountBalance):
|
||||
- Calculate TotalOpenRisk = sum of (StopTicks * TickValue * Qty) across all open positions
|
||||
(use existing open position tracking, or accept it as a parameter)
|
||||
- Calculate NewTradeRisk = intent.StopTicks * tickValue * intendedQty
|
||||
- Calculate HeatPct = (TotalOpenRisk + NewTradeRisk) / accountBalance * 100.0
|
||||
- If HeatPct > MaxHeatPct: return RiskDecision.Reject with reason:
|
||||
string.Format("Portfolio heat {0:F1}% exceeds limit {1:F1}%", HeatPct, MaxHeatPct)
|
||||
- Otherwise: return RiskDecision.Approve
|
||||
b. Call ValidatePortfolioHeat() as the last check in ValidateOrder(), AFTER Tier 3 cross-exposure check
|
||||
c. Log the heat check: Print(string.Format("[SDK] Heat check: {0:F1}% of {1:F1}% limit", HeatPct, MaxHeatPct));
|
||||
|
||||
3. Add unit test in tests/NT8.Core.Tests/Risk/ verifying:
|
||||
- Heat limit exceeded → RiskDecision.Reject
|
||||
- Heat within limit → RiskDecision.Approve
|
||||
- AccountBalance = 0 edge case handled (return Approve or skip check)
|
||||
|
||||
CONSTRAINTS:
|
||||
- C# 5.0 only
|
||||
- Check the actual field names in TrailingStopConfig before using them — do not assume
|
||||
- Do NOT change the class structure, just the CalculateNewStopPrice() method and its call site
|
||||
- Do not change Tier 1, 2, or 3 logic — only ADD Tier 3.5 after them
|
||||
- TickValue for NQ = 5.0, for MNQ = 0.50 — use a constant or pass via config
|
||||
|
||||
When done, confirm acceptance criteria from TASK-03-trailing-stop.md are met.
|
||||
```
|
||||
VERIFICATION:
|
||||
- .\verify-build.bat ✅
|
||||
- dotnet test ✅ with new heat tests passing
|
||||
|
||||
### Verification
|
||||
|
||||
1. **Check the diff:**
|
||||
- `CalculateNewStopPrice` has new `config` parameter
|
||||
- `UpdateTrailingStop()` call site is updated
|
||||
- No other methods were changed
|
||||
- New test file exists
|
||||
|
||||
2. ```
|
||||
Ctrl+Shift+B
|
||||
```
|
||||
✅ Must pass
|
||||
|
||||
3. ```
|
||||
Ctrl+Shift+P → Run Task → test-core
|
||||
```
|
||||
✅ New tests + all existing tests must pass
|
||||
|
||||
---
|
||||
|
||||
## TASK-04 — BasicLogger Log Level Filter
|
||||
|
||||
**File being modified:** `src/NT8.Core/Logging/BasicLogger.cs`
|
||||
**Spec file:** `TASK-04-log-level.md`
|
||||
**No dependencies**
|
||||
|
||||
### Kilocode Prompt
|
||||
|
||||
```
|
||||
Please implement TASK-04 from TASK-04-log-level.md
|
||||
|
||||
Summary:
|
||||
1. First, check if a LogLevel enum already exists in the project (search for "enum LogLevel")
|
||||
2. If not, add LogLevel enum: Debug=0, Information=1, Warning=2, Error=3, Critical=4
|
||||
3. Add MinimumLevel property (type LogLevel, default Information) to BasicLogger
|
||||
4. Update the private WriteLog() helper to accept a LogLevel and return early if below MinimumLevel
|
||||
5. Update each public log method (LogDebug, LogInformation, etc.) to pass its level to WriteLog()
|
||||
|
||||
Constraints:
|
||||
- C# 5.0 only
|
||||
- Default must be Information (backward compatible — existing behavior unchanged at default)
|
||||
- Do NOT change the ILogger interface signature
|
||||
- Do NOT break any existing tests that depend on specific log output
|
||||
|
||||
When done, confirm acceptance criteria from TASK-04-log-level.md are met.
|
||||
```
|
||||
|
||||
### Verification
|
||||
|
||||
1. **Check the diff:**
|
||||
- `MinimumLevel` property is public
|
||||
- `WriteLog()` has early return when `level < MinimumLevel`
|
||||
- No interface changes
|
||||
|
||||
2. ```
|
||||
Ctrl+Shift+B
|
||||
```
|
||||
✅ Must pass
|
||||
|
||||
3. ```
|
||||
Ctrl+Shift+P → Run Task → test-all
|
||||
```
|
||||
✅ All tests must pass
|
||||
|
||||
---
|
||||
|
||||
## TASK-05 — Session Holiday Awareness
|
||||
|
||||
**File being modified:** `src/NT8.Core/MarketData/SessionManager.cs`
|
||||
**Spec file:** `TASK-05-session-holidays.md`
|
||||
**No dependencies**
|
||||
|
||||
### Kilocode Prompt
|
||||
|
||||
```
|
||||
Please implement TASK-05 from TASK-05-session-holidays.md
|
||||
|
||||
Summary:
|
||||
1. Add a static readonly HashSet<DateTime> _cmeHolidays field to SessionManager
|
||||
Include 2025 and 2026 CME US Futures holidays (New Year's, MLK Day, Presidents' Day, Good Friday, Memorial Day, Juneteenth, Independence Day, Labor Day, Thanksgiving, Christmas)
|
||||
2. Add private static bool IsCmeHoliday(DateTime utcTime) helper that converts to Eastern time and checks the set
|
||||
3. Update IsRegularTradingHours() to call IsCmeHoliday(time) first — return false if it is a holiday
|
||||
|
||||
Constraints:
|
||||
- C# 5.0 — use new HashSet<DateTime> { ... } initializer syntax (this works in C# 5)
|
||||
- Wrap the TimeZoneInfo.ConvertTimeFromUtc() call in try/catch — return false on exception
|
||||
- Do NOT change any other session detection logic
|
||||
|
||||
When done, confirm:
|
||||
- IsRegularTradingHours("ES", DateTime(2025, 12, 25, 14, 0, 0, Utc)) returns false
|
||||
- IsRegularTradingHours("ES", DateTime(2025, 12, 26, 14, 0, 0, Utc)) returns true
|
||||
- verify-build.bat passes
|
||||
```
|
||||
|
||||
### Verification
|
||||
|
||||
1. **Check the diff:**
|
||||
- `_cmeHolidays` contains dates for 2025 and 2026
|
||||
- `IsRegularTradingHours()` checks holiday before session time logic
|
||||
- No other session logic was changed
|
||||
|
||||
2. ```
|
||||
Ctrl+Shift+B
|
||||
```
|
||||
✅ Must pass
|
||||
|
||||
3. ```
|
||||
Ctrl+Shift+P → Run Task → test-all
|
||||
```
|
||||
✅ All tests must pass
|
||||
|
||||
---
|
||||
|
||||
## Final Verification — All 5 Tasks Complete
|
||||
|
||||
Run this sequence once all tasks are done:
|
||||
|
||||
**1. Full build:**
|
||||
```
|
||||
Ctrl+Shift+B
|
||||
```
|
||||
Expected: ✅ All checks passed!
|
||||
|
||||
**2. Full test suite:**
|
||||
```
|
||||
Ctrl+Shift+P → Run Task → test-all
|
||||
```
|
||||
Expected: 245+ tests passed (240 existing + new TrailingStop tests), 0 failed
|
||||
|
||||
**3. Git commit:**
|
||||
```
|
||||
git add -A
|
||||
git commit -m "Production hardening: kill switch, circuit breaker, trailing stops, log level, holiday calendar"
|
||||
git push
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md completely (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting Kilocode
|
||||
## GAP-003 — RiskPerTrade ≤ MaxTradeRisk Assertion
|
||||
|
||||
### If Kilocode introduces C# 6+ syntax
|
||||
|
||||
Paste this correction:
|
||||
```
|
||||
Build failed with C# syntax errors. You used C# 6+ features which are not allowed.
|
||||
This project targets C# 5.0 / .NET Framework 4.8.
|
||||
|
||||
Please fix:
|
||||
- Replace any $"..." with string.Format("...", ...)
|
||||
- Replace ?. with explicit null checks: if (x != null) x.Method()
|
||||
- Replace => on properties/methods with standard { get { return ...; } } syntax
|
||||
- Replace nameof() with string literals
|
||||
- Replace out var with two-step: declare variable, then call with out
|
||||
|
||||
Then re-run verify-build.bat to confirm.
|
||||
```
|
||||
|
||||
### If Kilocode modifies the wrong file
|
||||
---
|
||||
|
||||
```
|
||||
You modified [filename] which is in the "Do NOT Change" list.
|
||||
Please revert those changes and only modify the files listed in the task spec.
|
||||
The Core layer is complete and tested — changes there break 240+ tests.
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
### If tests fail after a task
|
||||
Implement GAP-003: Add startup assertion that RiskPerTrade <= MaxTradeRisk in BasicRiskManager.
|
||||
|
||||
```
|
||||
Tests failed after your changes. Please:
|
||||
1. Run: dotnet test NT8-SDK.sln --verbosity normal 2>&1 | head -50
|
||||
2. Show me the first failing test and its error message
|
||||
3. Fix only the failing tests without introducing new changes to passing test files
|
||||
```
|
||||
WHAT TO BUILD:
|
||||
In BasicRiskManager.cs (src/NT8.Core/Risk/BasicRiskManager.cs):
|
||||
1. In the constructor or Initialize() method, immediately after receiving RiskConfig:
|
||||
if (riskConfig.RiskPerTrade > riskConfig.MaxTradeRisk)
|
||||
{
|
||||
throw new System.ArgumentException(string.Format(
|
||||
"Invalid RiskConfig: RiskPerTrade ({0}) cannot exceed MaxTradeRisk ({1}). " +
|
||||
"Increase MaxTradeRisk or reduce RiskPerTrade.",
|
||||
riskConfig.RiskPerTrade, riskConfig.MaxTradeRisk));
|
||||
}
|
||||
|
||||
### If Kilocode is unsure about a field name or method signature
|
||||
2. Add unit test in tests/NT8.Core.Tests/Risk/ verifying:
|
||||
- RiskPerTrade > MaxTradeRisk throws ArgumentException
|
||||
- RiskPerTrade == MaxTradeRisk is accepted (no throw)
|
||||
- RiskPerTrade < MaxTradeRisk is accepted (no throw)
|
||||
|
||||
```
|
||||
Before assuming a field name, please read the actual file first:
|
||||
[specify file path]
|
||||
Confirm the exact field/method names before writing code.
|
||||
CONSTRAINTS: C# 5.0 only. Touch only BasicRiskManager.cs and its test file.
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Quick Reference — Files Being Modified
|
||||
## GAP-004 — orbRangeTicks Hardcoded 0.0 Fix
|
||||
|
||||
| Task | File | What Changes |
|
||||
|---|---|---|
|
||||
| 01 | `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` | +2 properties, +1 field, kill switch in OnBarUpdate |
|
||||
| 02 | `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` | +circuit breaker field, gate in SubmitOrderToNT8, wire in OnOrderUpdate |
|
||||
| 03 | `src/NT8.Core/Execution/TrailingStopManager.cs` | Fix CalculateNewStopPrice, update call site |
|
||||
| 03 | `tests/NT8.Core.Tests/Execution/TrailingStopManagerFixedTests.cs` | NEW — unit tests |
|
||||
| 04 | `src/NT8.Core/Logging/BasicLogger.cs` | +MinimumLevel property, level filter in WriteLog |
|
||||
| 05 | `src/NT8.Core/MarketData/SessionManager.cs` | +holiday set, holiday check in IsRegularTradingHours |
|
||||
---
|
||||
|
||||
**Nothing else should be modified. If Kilocode touches other files, ask it to revert them.**
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-004: Fix orbRangeTicks hardcoded 0.0 in DailyBarContext / SimpleORBStrategy.
|
||||
|
||||
WHAT TO BUILD:
|
||||
1. In SimpleORBStrategy.cs (src/NT8.Strategies/Examples/SimpleORBStrategy.cs):
|
||||
- Find where DailyBarContext is constructed and orbRangeTicks is set
|
||||
- Replace the hardcoded 0.0 with: (int)System.Math.Round((orbHigh - orbLow) / tickSize)
|
||||
- Ensure orbHigh, orbLow, and tickSize are available at that point in the code
|
||||
|
||||
2. In SimpleORBNT8.cs (src/NT8.Adapters/Strategies/SimpleORBNT8.cs):
|
||||
- Confirm tickSize (TickSize from NT8) is being passed to SimpleORBStrategy or available in context
|
||||
- If not wired: pass TickSize as a parameter when constructing StrategyContext or DailyBarContext
|
||||
|
||||
3. DUAL-DEPLOY SimpleORBNT8.cs to NT8 Custom\Strategies\
|
||||
|
||||
CONSTRAINTS: C# 5.0. Touch only these two files plus any unit tests.
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-005 — GetRiskStatus() Returns Live Config Value
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-005: GetRiskStatus() must return the actual registered DailyLossLimit from injected RiskConfig.
|
||||
|
||||
WHAT TO BUILD:
|
||||
In BasicRiskManager.cs (src/NT8.Core/Risk/BasicRiskManager.cs):
|
||||
1. Find GetRiskStatus() method
|
||||
2. Replace any hardcoded limit value with the stored _riskConfig.DailyLossLimit (or equivalent field)
|
||||
3. Confirm all numeric fields in the returned status come from _riskConfig, not constants
|
||||
|
||||
Add or update unit test: inject a RiskConfig with a specific DailyLossLimit value, call GetRiskStatus(),
|
||||
assert the returned limit field equals the injected value.
|
||||
|
||||
CONSTRAINTS: C# 5.0. Touch only BasicRiskManager.cs and its test file.
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-006 — Position-Close-Driven _tradeTaken Re-arm
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md and docs/00-governance/decisions.md (DEC-20260429-01) before starting.
|
||||
|
||||
Implement GAP-006: Wire _tradeTaken re-arm to position-close callback in NT8StrategyBase.
|
||||
|
||||
CONTEXT: DEC-20260429-01 documented that _tradeTaken is currently re-armed on the next bar after
|
||||
a trade intent, not when the NT8 position actually closes. This is acceptable in SIM but must
|
||||
be fixed before live trading with MaxDailyTrades > 1.
|
||||
|
||||
WHAT TO BUILD:
|
||||
In NT8StrategyBase.cs (src/NT8.Adapters/Strategies/NT8StrategyBase.cs):
|
||||
1. Find or add an OnPositionUpdate override:
|
||||
protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, int quantity, Cbi.MarketPosition marketPosition)
|
||||
NOTE: Verify exact NT8 signature at https://developer.ninjatrader.com/docs/desktop before implementing.
|
||||
2. In OnPositionUpdate, when the position goes flat (MarketPosition.Flat or quantity == 0):
|
||||
_tradeTaken = false;
|
||||
if (EnableVerboseLogging) Print("[SDK] Position closed — _tradeTaken reset via OnPositionUpdate");
|
||||
3. Remove or gate the old bar-based re-arm logic (the increment/reset tied to bar counting)
|
||||
- Gate with a parameter: AddParameterBool EnableBarBasedRearm default=false
|
||||
- Or remove entirely if position-close re-arm is sufficient
|
||||
|
||||
4. Record the decision: append to docs/00-governance/decisions.md:
|
||||
DEC-20260504-01: _tradeTaken re-arm switched from bar-driven to position-close-driven (OnPositionUpdate).
|
||||
Bar-driven code removed. This is required for MaxDailyTrades > 1 in live trading.
|
||||
|
||||
5. DUAL-DEPLOY NT8StrategyBase.cs to NT8 Custom\Strategies\
|
||||
|
||||
CONSTRAINTS: C# 5.0. Verify OnPositionUpdate signature against NT8 docs before writing it.
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-010 — Short-Side Regime Filter Gate
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-010: Gate short-side signals behind a regime filter in SimpleORBStrategy.
|
||||
|
||||
WHAT TO BUILD:
|
||||
1. In SimpleORBStrategy.cs (src/NT8.Strategies/Examples/SimpleORBStrategy.cs):
|
||||
a. Add a parameter EnableShortSide (bool, default = false) to StrategyConfig or as a direct parameter
|
||||
b. In OnBar() or wherever short-side signals are generated:
|
||||
if (!EnableShortSide) { /* skip short signal, return null intent */ }
|
||||
c. If EnableShortSide is true, add regime check:
|
||||
if (regime.TrendDirection == TrendDirection.Bullish && riskMode == RiskMode.Normal)
|
||||
{ /* block short, log: "[SDK] Short blocked: bullish trend regime + normal risk mode" */ }
|
||||
|
||||
2. In SimpleORBNT8.cs (src/NT8.Adapters/Strategies/SimpleORBNT8.cs):
|
||||
a. Expose EnableShortSide as a [NinjaScriptProperty] (default = false)
|
||||
b. Pass to SimpleORBStrategy at construction
|
||||
|
||||
3. DUAL-DEPLOY SimpleORBNT8.cs to NT8 Custom\Strategies\
|
||||
|
||||
CONSTRAINTS: C# 5.0. Only touch SimpleORBStrategy.cs and SimpleORBNT8.cs (+ test file).
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅ including regime filter tests
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-008 — CME Holiday Awareness
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-008: Add static CME holiday HashSet to SessionManager.
|
||||
|
||||
WHAT TO BUILD:
|
||||
In SessionManager.cs (src/NT8.Core/MarketData/SessionManager.cs):
|
||||
1. Add a private static readonly HashSet<DateTime> _cmeHolidays containing these dates
|
||||
(use new DateTime(year, month, day) for each, no times):
|
||||
|
||||
2025: Jan 1, Jan 20, Feb 17, Apr 18, May 26, Jun 19, Jul 4, Sep 1, Nov 27, Dec 25
|
||||
2026: Jan 1, Jan 19, Feb 16, Apr 3, May 25, Jun 19, Jul 3, Sep 7, Nov 26, Dec 25
|
||||
|
||||
2. In IsRegularTradingHours() or the relevant session check method:
|
||||
DateTime today = new DateTime(time.Year, time.Month, time.Day);
|
||||
if (_cmeHolidays.Contains(today)) return false;
|
||||
|
||||
3. Add unit tests verifying:
|
||||
- Dec 25, 2025 returns false
|
||||
- Jan 1, 2026 returns false
|
||||
- A normal trading day (e.g., Jan 7, 2026) still returns true within RTH hours
|
||||
|
||||
CONSTRAINTS: C# 5.0. Touch only SessionManager.cs and its test file.
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-009 — ATRTrailing Real ATR Wiring
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-009: Replace ATR proxy in TrailingStopManager with real ATR from context.
|
||||
|
||||
WHAT TO BUILD:
|
||||
In TrailingStopManager.cs (src/NT8.Core/Execution/TrailingStopManager.cs):
|
||||
1. Find where estimatedAtr = avgFillPrice * 0.005m (or similar proxy) is calculated
|
||||
2. Replace with:
|
||||
double realAtr = 0.0;
|
||||
if (context != null && context.CustomData.ContainsKey("current_atr"))
|
||||
realAtr = (double)context.CustomData["current_atr"]; // value is in ticks
|
||||
double atrToUse = realAtr > 0.0 ? realAtr : avgFillPrice * 0.005 / tickValue; // fallback
|
||||
if (realAtr <= 0.0)
|
||||
logger.LogWarning("[SDK] TrailingStop: using ATR proxy — wire current_atr to context for accuracy");
|
||||
3. Apply same fix to Chandelier mode
|
||||
|
||||
CONSTRAINTS: C# 5.0. Touch only TrailingStopManager.cs and its test file.
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-011 — Gitea CI Pipeline
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-011: Create Gitea CI workflow that builds and tests on every push.
|
||||
|
||||
WHAT TO BUILD:
|
||||
Create .gitea/workflows/build.yml with this content (adapt as needed for the Gitea runner):
|
||||
|
||||
name: Build and Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, 'sprint-*']
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '4.8.x'
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore NT8-SDK.sln
|
||||
|
||||
- name: Build
|
||||
run: dotnet build NT8-SDK.sln --configuration Release --no-restore
|
||||
|
||||
- name: Test
|
||||
run: dotnet test tests/NT8.Core.Tests/NT8.Core.Tests.csproj --no-build --verbosity minimal
|
||||
|
||||
NOTE: If the Gitea runner uses a different OS tag or .NET version, adjust accordingly.
|
||||
Verify the workflow syntax is correct for the Gitea Actions runner version on git.thehussains.org.
|
||||
|
||||
VERIFICATION: Push a test commit and confirm the CI badge shows on the Gitea repo page.
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-022 — Scenario Tests
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-022: Write 8 scenario tests covering edge-case behaviors.
|
||||
|
||||
Reference: NT8_SDK_Master_Document_v6_Final.docx — Section 11.1
|
||||
|
||||
CREATE: tests/NT8.Core.Tests/Scenarios/ScenarioTests.cs
|
||||
|
||||
Write tests for these 8 scenarios:
|
||||
|
||||
1. HIGH_VOLATILITY_DAY: ATR ratio > 1.5 → Factor 3 (VolatilityRegime) scores 0.3 → grade likely F or D → no trade taken
|
||||
2. NEWS_DAY_REDUCED_SIZE: SessionManager flags high-impact event → if ReducedSizeOnNewsDay: MaxContracts halved
|
||||
3. LOW_LIQUIDITY: LiquidityMonitor spread exceeds threshold → Factor 5 (ExecutionQuality) drops to 0.4 → grade degrades
|
||||
4. PARTIAL_FILL: NT8 partial fill on scaler leg → OMS transitions to PARTIALLY_FILLED → no duplicate entry
|
||||
5. MID_TRADE_DISCONNECT: _connectionLost=true while position open → no new orders → position retained
|
||||
6. PRE_ENTRY_DISCONNECT: _connectionLost fires between signal approval and order submission → order not submitted
|
||||
7. DAILY_LOSS_HALT: DailyPnL hits DailyLossLimit → HALT fires → no new entries rest of session
|
||||
8. CIRCUIT_BREAKER_OPEN: 3 consecutive rejections → CB opens → ShouldAllowOrder() returns false
|
||||
|
||||
Each test should:
|
||||
- Set up the relevant state using mocks or test doubles
|
||||
- Trigger the scenario
|
||||
- Assert the expected system response (rejection, halt, no order, etc.)
|
||||
- Be independent (no shared state between tests)
|
||||
|
||||
CONSTRAINTS: C# 5.0. Only create new test file — do not modify existing source files.
|
||||
If a scenario requires a missing interface or mock, note it as a TODO comment.
|
||||
|
||||
VERIFICATION: .\verify-build.bat ✅ | dotnet test ✅ with all 8 new tests passing
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GAP-007 — Walk-Forward Test Documentation
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Read docs/00-governance/active_work.md before starting.
|
||||
|
||||
Implement GAP-007: Document the walk-forward test procedure and record the acceptance threshold.
|
||||
|
||||
WHAT TO BUILD:
|
||||
1. Update docs/02-runbooks/backtest_review_workflow.md with a new section:
|
||||
|
||||
## Walk-Forward Validation Procedure
|
||||
- In-sample period: Jan 1, 2024 – Sep 30, 2025 (use for parameter selection)
|
||||
- Walk-forward period: Oct 1, 2025 – Mar 31, 2026 (never seen during optimization)
|
||||
- Tool: NT8 Strategy Analyzer → Optimization tab → Walk Forward
|
||||
- Acceptance threshold: WF Profit Factor ≥ 60% of in-sample Profit Factor
|
||||
Example: In-sample PF = 3.0 → WF PF must be ≥ 1.8
|
||||
- If WF PF < 60% of in-sample: parameters are overfit — must re-evaluate
|
||||
- Parameters to test: MinTradeGrade, AtrMultiplier, RunnerTrailTicks, DailyLossLimit
|
||||
|
||||
2. Append to docs/00-governance/decisions.md:
|
||||
|
||||
### DEC-20260504-02
|
||||
- ID: DEC-20260504-02
|
||||
- Date: 2026-05-04
|
||||
- Status: accepted
|
||||
- Context: All backtests to date are in-sample (Jan–Mar 2026 optimization window).
|
||||
Going live on in-sample parameters without OOS validation is a model risk.
|
||||
- Decision: Walk-forward acceptance threshold set at WF PF ≥ 60% of in-sample PF.
|
||||
No live capital deployed until this threshold is met on the Oct 2025–Mar 2026 OOS period.
|
||||
- Consequences: Adds ~1 week to Sprint 3 timeline for running and documenting WF results.
|
||||
- Related Files: docs/02-runbooks/backtest_review_workflow.md
|
||||
|
||||
CONSTRAINTS: Documentation only — no source code changes.
|
||||
|
||||
VERIFICATION: Files exist and contain the above content.
|
||||
|
||||
WHEN DONE: Follow .kilocode/rules/self_learning_loop.md (all 6 steps).
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user