[GAP-050]: quantity-aware risk contract complete

- IRiskManager.cs: add quantity-aware ValidateOrder contract

- AdvancedRiskManager.cs: delegate Tier 1 through sized BasicRiskManager overload and preserve 3-arg behavior

- NT8StrategyBase.cs: remove BasicRiskManager type-check workaround and call sized interface method

- NT8OrderAdapter.cs: size before risk validation and pass actual contracts

- tests: add AdvancedRiskManager, NT8OrderAdapter, and NT8StrategyBase coverage

Build: clean | Tests: 566 passing; Core 476 passing | Dual-deployed: no - skipped by prompt
This commit is contained in:
2026-08-25 16:39:56 -04:00
parent a673475738
commit a99ce1d0e7
10 changed files with 388 additions and 15 deletions

View File

@@ -99,6 +99,24 @@ namespace NT8.Integration.Tests
Assert.AreEqual(16, history[0].TargetTicks);
}
[TestMethod]
public void ExecuteIntent_ValidatesRiskWithSizedContracts()
{
// Arrange
var adapter = new NT8OrderAdapter(new FakeBridge());
var risk = new TestRiskManager(true);
var sizer = new TestPositionSizer(4);
adapter.Initialize(risk, sizer);
// Act
adapter.ExecuteIntent(CreateIntent(), CreateContext(), CreateConfig());
// Assert
Assert.AreEqual(4, risk.LastCandidateContracts);
Assert.AreEqual(0, risk.ThreeArgumentValidateCalls);
Assert.AreEqual(1, risk.FourArgumentValidateCalls);
}
[TestMethod]
public void GetExecutionHistory_ReturnsCopy_NotMutableInternalReference()
{
@@ -193,13 +211,27 @@ namespace NT8.Integration.Tests
{
private readonly bool _allow;
public int LastCandidateContracts { get; private set; }
public int ThreeArgumentValidateCalls { get; private set; }
public int FourArgumentValidateCalls { get; private set; }
public TestRiskManager(bool allow)
{
_allow = allow;
LastCandidateContracts = -1;
}
public RiskDecision ValidateOrder(StrategyIntent intent, StrategyContext context, RiskConfig config)
{
ThreeArgumentValidateCalls++;
return ValidateOrder(intent, context, config, 1);
}
public RiskDecision ValidateOrder(StrategyIntent intent, StrategyContext context, RiskConfig config, int candidateContracts)
{
FourArgumentValidateCalls++;
LastCandidateContracts = candidateContracts;
return new RiskDecision(
_allow,
_allow ? null : "Rejected by test risk manager",