backtrader icon indicating copy to clipboard operation
backtrader copied to clipboard

Price used for limit order execution can be incorrectly outside of the high/low range

Open vladisld opened this issue 4 years ago • 1 comments

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 avatar Jul 10 '20 23:07 vladisld

@vladisld Thanks for looking after that!

neilsmurphy avatar Jul 11 '20 12:07 neilsmurphy