PINK: fix multi-leg exit residual — carry kernel leg-index into legacy position
Root cause (harness multi_leg, ~14-TRX residual): pink_direct rebuilds the legacy TradePosition from the kernel slot every step, but left exit_leg_index=0, so IntentEngine.next_exit_ratio() consumed ratio[0] (0.5) on EVERY leg and never advanced to the final leg's 1.0: leg1: 0.5×53 ≈ 26 closed -> 27 remain leg2: 0.5×27 ≈ 13 closed -> 14 RESIDUAL (kernel believes flat, exchange isn't) Fix: propagate the kernel slot's authoritative active_leg_index into the rebuilt legacy position's exit_leg_index, so the intent engine consumes the correct leg ratio. The final leg now closes the full remaining -> fully flattens. Verified: offline 18 green (no regression); live VST harness multi_leg now closes fully (XPASS) — residual gone, all 6 capital invariants hold. xfail mark removed; capital-accounting battery is now fully green (7/7) on testnet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -319,16 +319,7 @@ _TRADING_SCENARIOS = {
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", [
|
||||
"round_trip",
|
||||
pytest.param("multi_leg", marks=pytest.mark.xfail(
|
||||
reason="KNOWN capital/sizing finding: multi-leg partial reduce-only exits leave a "
|
||||
"lot-step rounding residual on the venue (kernel believes flat, exchange has a "
|
||||
"remainder). To be fixed in the capital/sizing-path rework.",
|
||||
strict=False)),
|
||||
"sequential",
|
||||
"exit_then_reentry",
|
||||
])
|
||||
@pytest.mark.parametrize("name", list(_TRADING_SCENARIOS))
|
||||
def test_pink_capital(name):
|
||||
ratios, scenario = _TRADING_SCENARIOS[name]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user