• Backtrader中文笔记之Trade(交易)


    Trade

    Definition of a trade:

    • A Trade is open when the a position in a instrument goes from 0 to a size X which may positive/negative for long/short positions)

    • 当工具中的A仓位从0变为大小X时,交易是开放的的状态,这可能是多头/空头因为持仓的正/负)
    • A Trade is closed when a position goes from X to 0.

    • 当仓位从X到0时,交易关闭

    The followig two actions:

    主要跟随着两个行为:

    • positive to negative

    • 正转负
    • negative to positive

    • 负转正

    Are actually seen as:

     实际上被视为:
    1. A trade has been closed (position went to 0 from X)

    2. 交易已结束(头寸从X变为0)
    3. A new trade has been open (position goes from 0 to Y)

    4. 一个新的交易已经打开(头寸从0变为Y)

    Trades are only informative and have no user callable methods.

    交易只是可取的信息,没有可调用的方法。

    Reference: Trade

    class backtrader.trade.Trade(data=None, tradeid=0, historyon=False, size=0, price=0.0, value=0.0, commission=0.0)

    Keeps track of the life of an trade: size, price, commission (and value?)

    跟踪交易的生命周期:规模、价格、佣金(和价值?)

    An trade starts at 0 can be increased and reduced and can be considered closed if it goes back to 0.

    一次交易从0可以增加或者减少,再回到0,可以被视为结束。

    The trade can be long (positive size) or short (negative size)

    交易可以是多头(多单),空头(空单)

    An trade is not meant to be reversed (no support in the logic for it)

    交易不是要逆转的(在逻辑上没有支持)

    Member Attributes:

    • ref: unique trade identifier

    • 唯一的交易标识符
    • status (int): one of Created, Open, Closed

    • 交易的状态0,1,2
    • tradeid: grouping tradeid passed to orders during creation The default in orders is 0

    • 分组在创建期间传递给订单的tradeid订单中的默认值为0
    • size (int): current size of the trade

    • 当前的交易数量,只有在Open的时候,能看到
    • price (float): current price of the trade

    • 交易对的开盘价,计算单笔利润的时候可以用到
    • value (float): current value of the trade

    • commission (float): current accumulated commission

    • pnl (float): current profit and loss of the trade (gross pnl)

    • pnl(浮动):交易当期损益(总pnl)
    • pnlcomm (float): current profit and loss of the trade minus commission (net pnl)

    • isclosed (bool): records if the last update closed (set size to null the trade

    • isclosed(bool):记录上次更新是否关闭(将size设置为空交易)所以关闭的时候,无法读取到size
    • isopen (bool): records if any update has opened the trade

    • isopen(bool):记录是否有任何更新打开交易,为isclosed的相反参数,表示没有交易对的情况
    • justopened (bool): if the trade was just opened

    • justopened(bool):如果交易刚刚开始
    • baropen (int): bar in which this trade was opened

    • baropen (int):这比交易开始的bar
    • dtopen (float): float coded datetime in which the trade was opened

      • Use method open_datetime to get a Python datetime.datetime or use the platform provided num2date method
    • barclose (int): bar in which this trade was closed

    • dtclose (float): float coded datetime in which the trade was closed

      • Use method close_datetime to get a Python datetime.datetime or use the platform provided num2date method
    • barlen (int): number of bars this trade was open

    • historyon (bool): whether history has to be recorded

    • history (list): holds a list updated with each “update” event containing the resulting status and parameters used in the update

      The first entry in the history is the Opening Event The last entry in the history is the Closing Event

  • 相关阅读:
    Smali语法
    css 实现垂直水平居中常用方法
    css border实现三角形
    vue-router学习笔记
    vuex状态管理
    es6 reduce的用法
    vue学习笔记
    chrome调式工具
    前端需要了解的http知识
    underscore.js and moment.js
  • 原文地址:https://www.cnblogs.com/sidianok/p/13703966.html
Copyright © 2020-2023  润新知