zoukankan      html  css  js  c++  java
  • Backtrader中文笔记之Slippage(滑点)

    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 is 1%

      • 0.001 is 0.1%

    • slip_fixed (default: 0.0) Percentage in units (and positive) that should be used to slip prices up/down for buy/sell orders

      Note: 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 be Market 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 at high/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 if slip_match is False.

      This option controls that behavior.

      If True, then Limit orders will be matched by capping prices to the limit / high/low prices

      If 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 applied

      Please check the slip_open exception. Because Market 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 requested limit price

      • If the matching price is not the limit price, slippage is applied capping at high/low. In this case slip_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 for Market orders apply

    • StopLimit - once the order is triggered the same logic as for Limit orders apply

    This approach tries to offer the most realistic possible approach within the limits of the simulation and available data

  • 相关阅读:
    我不写博客的原因就是cnblogs不好用
    使用KeePass愉快的来管理你的密码
    Visual studio常用的code snippets
    日常工作小贴士
    win10下面visual studio, sublime ctrl+shift+f快捷键失效的原因
    Markdown常用语法对应
    常见的Message Queue应用场景
    二分查找(binary search)
    在ROS中使用花生壳的域名服务
    排序算法 选择排序(selection sort)
  • 原文地址:https://www.cnblogs.com/sidianok/p/13704208.html
Copyright © 2011-2022 走看看