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.01is1% -
0.001is0.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_percis 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 beMarketorder 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
Truethe broker will offer a match by capping slippage athigh/lowprices in case they would be exceeded.If
Falsethe broker will not match the order with the current prices and will try execution during the next iteration -
slip_limit(default:True)Limitorders, given the exact match price requested, will be matched even ifslip_matchisFalse.This option controls that behavior.
If
True, thenLimitorders will be matched by capping prices to thelimit/high/lowpricesIf
Falseand slippage exceeds the cap, then there will be no match -
slip_out(default:False)Provide slippage even if the price falls outside the
high-lowrange.
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
closeprice 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_openexception. BecauseMarketorders 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 requestedlimitprice -
If the matching price is not the
limitprice, slippage is applied capping athigh/low. In this caseslip_mlimitapplies to decide if a match will be happening in case the caps are exceeded -
If the matching price is the
limitprice, then no slippage is applied
-
-
Stop- once the order is triggered the same logic as forMarketorders apply -
StopLimit- once the order is triggered the same logic as forLimitorders apply
This approach tries to offer the most realistic possible approach within the limits of the simulation and available data
