backtesting cannot guarantee real market conditions. No matter how good the market simulation is, under real market conditions slippage can happen. That means:
回测系统不能保证真实的市场状况。无论市场模拟有多好,在真实的市场条件下,都可能出现下滑。这意味着:
- The requested price may not be matched.
- 请求的价格可能不匹配
The integrated backtesting broker supports slippage. The following parameters can be passed to the broker
完整的回测券商【经纪人】支持滑点。可以将以下参数传递给券商【经纪人】
-
slip_perc
(default:0.0
) Percentage in absolute termns (and positive) that should be used to slip prices up/down for buy/sell orders - slip_perc(默认值:0.0)绝对条件下的百分比(和正值,用于向上/向下滑动买入/卖出订单的价格
-
Note:
-
0.01
is1%
-
0.001
is0.1%
-
-
slip_fixed
(default:0.0
) Percentage in units (and positive) that should be used to slip prices up/down for buy/sell ordersNote: if
slip_perc
is non zero, it takes precendence over this. -
slip_open
(default:False
) whether to slip prices for order execution which would specifically used the opening price of the next bar. An example would beMarket
order which is executed with the next available tick, i.e: the opening price of the bar.This also applies to some of the other executions, because the logic tries to detect if the opening price would match the requested price/execution type when moving to a new bar.
-
slip_match
(default:True
)If
True
the broker will offer a match by capping slippage athigh/low
prices in case they would be exceeded.If
False
the broker will not match the order with the current prices and will try execution during the next iteration -
slip_limit
(default:True
)Limit
orders, given the exact match price requested, will be matched even ifslip_match
isFalse
.This option controls that behavior.
If
True
, thenLimit
orders will be matched by capping prices to thelimit
/high/low
pricesIf
False
and slippage exceeds the cap, then there will be no match -
slip_out
(default:False
)Provide slippage even if the price falls outside the
high
-low
range.
How it works
如何工作
In order to decide when to apply slippage the order execution type is taken into account:
-
Close
- No slippage is applied - 收盘-不支持引用滑点
-
This order is matched against the
close
price and this price is the last one of the day. Slippage cannot happen because the order can only happen with the last tick of the session and this is a unique price with no tolerance. - 此订单与收盘价相匹配,此价格为当天最后一个价格。滑点是不可能发生的,因为订单只能在交易的最后一刻发生,而且这是一个没有任何容差的独特价格。
-
Market
- Slippage is appliedPlease check the
slip_open
exception. BecauseMarket
orders will be matched against the opening price of the next bar. -
Limit
- Slippage is applied following this logic-
If the matching price would be the opening price, then slippage is applied according to the parameter
slip_open
. If applied, the price will never be worse than the requestedlimit
price -
If the matching price is not the
limit
price, slippage is applied capping athigh/low
. In this caseslip_mlimit
applies to decide if a match will be happening in case the caps are exceeded -
If the matching price is the
limit
price, then no slippage is applied
-
-
Stop
- once the order is triggered the same logic as forMarket
orders apply -
StopLimit
- once the order is triggered the same logic as forLimit
orders apply
This approach tries to offer the most realistic possible approach within the limits of the simulation and available data