backtrader
backtrader copied to clipboard
Price used for limit order execution can be incorrectly outside of the high/low range
On behalf of @run_out
Community discussion:
https://community.backtrader.com/topic/2542/bug-in-bbroker-_try_exec_limit
Issue in backtrader2 repository:
https://github.com/backtrader2/backtrader/issues/22
Description:
Price used for limit order execution can be incorrectly outside of the high/low range (less than low price in particular) even the bt slippage parameters prevents it. This can happen if the slippage, applied to the open price moves the execution price lower than the bar low price.
Change:
Fixed to use pmin instead of plimit in the sell side of _try_exec_limit. Test files created to check for valid entry for various levels of slippage.
@vladisld Thanks for looking after that!