Apply half-spread and commission on both open/close trade
- Dominant language
- Python
- Stars
- 9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
### Enhancement description
Hi,
Full spread is currently applied to buy price on trade open and open+close commission only on trade close. This doesn't reflect real life and affects backtesting stop loss/trailing stop loss trigger level.
Also,, I'm using trade.pl_pct for trailing stop loss calculation and I have to subtract commission manually.
It also leads to bad optimization.
The situation should be :
- trade open: apply half-spread on buy price and also apply commission
- trade close: apply half-spread on sell price and also apply commission
Thanks a lot!
### Code sample
```python
```
### Additional info, images
_No response_
Contributor guide
Research direction
Start by locating the trade-open and trade-close price and commission calculations in the backtesting engine, then trace how they affect stop-loss, trailing-stop-loss, and trade.pl_pct values. Done means each side applies half-spread and commission, with backtests confirming the corrected trigger levels and optimization behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- fintech-quant
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100