Execution of Limit Orders
-
Is there a way in backtrader such that limit orders only execute if price trades through the limit order price?
I'm running a backtest with tick data for ES futures, so I would only want a sell limit at 2700 to execute if the price goes a tick higher to 2700.25.
I believe the default behavior is to execute the limit order when price reaches 2700, which rarely happens in live trading.
Thanks in advance.
-
@toolkmit said in Execution of Limit Orders:
I believe the default behavior is to execute the limit order when price reaches 2700, which rarely happens in live trading.
backtrader is not about what
rarely
happens. It tries to model reality. Actually if you have aLimit
order to sell at2700
, you are NOT going to be matched at2700.25
because that would actually go AGAINST what you have specified as limit. Your broker would be breaching the contract it has with you not to executed your order at any price higher than2700
.You ar probably looking at these options:
- Adding slippage: Docs - Slippage
- Using
StopLimit
(i.e.: only having aLimit
order active if a trigger price has been reached).
You may also be looking for an order type which is not implemented in backtrader:
Limit If Touched
. When the price touches2700
you will be looking to have aLimit
order placed at2700.25