Skip to content

Fix #1335: Apply half-spread and commission symmetrically on open and close - #1407

Open
dwaddle wants to merge 1 commit into
kernc:masterfrom
dwaddle:fix-1335-spread-commission
Open

dwaddle wants to merge 1 commit into
kernc:masterfrom
dwaddle:fix-1335-spread-commission

Conversation

@dwaddle

@dwaddle dwaddle commented Sep 9, 2026

Copy link
Copy Markdown

Fixes #1335

### Enhancement description
This PR fixes the asymmetry where the full spread was applied to the buy price on trade open (and 0 on close), and where commissions were only subtracted after the

trade was closed.

Changes applied:
- `_adjusted_price` now applies half of the spread on trade open.
- `_close_trade` now applies the opposite half of the spread on the exit price.
- `trade._commissions` is immediately populated on trade open, ensuring `trade.pl` and `trade.pl_pct` reflect the correct Mark-to-Market value during the trade's

lifetime (which is crucial for trailing stop losses).

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.

Apply half-spread and commission on both open/close trade

1 participant