Skip to content

Include actual exit fills in realized trade excursions - #205

Merged
stefan-jansen merged 2 commits into
mainfrom
fix/204-exit-excursions
Nov 27, 2026
Merged

stefan-jansen merged 2 commits into
mainfrom
fix/204-exit-excursions

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Closes #204.

A closed or partially closed trade now includes its executed exit price in its favorable and adverse excursion bounds. A reversal applies the exit to the position being closed. This preserves the existing open-position water marks used for stops and trailing orders.

The Engine regression exercises both directions, upward and downward gaps, partial closes, full closes and reversals with costs. All 12 combinations failed on main. The fix also strengthens the shared realized-trade invariant. The results guide describes the signed price-return basis.

Installed Python, Numba and Rust builds returned the same entry, exit, gross return, MAE and MFE for long and short round trips with slippage and commission. Native correctness evidence and generated comparison documentation accompany the source change. The change adds two comparisons per realized trade. The existing timing measurements retain their original source identity.

Prepared and tested with OpenAI Codex assistance.

@stefan-jansen
stefan-jansen merged commit 7c9b04f into main Nov 27, 2026
52 checks passed
@stefan-jansen
stefan-jansen deleted the fix/204-exit-excursions branch November 27, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closed trades can have a realized return outside their MFE/MAE

1 participant