zoukankan      html  css  js  c++  java
  • Backtrader中文笔记之Position(持仓情况)

    Position on an asset is usually checked from within a Strategy with:

    资产情况通常通过以下方式从策略内部进行检查:

    • position (a property) or getposition(data=None, broker=None)

      Which will return the position on datas[0] of the strategy in the default broker provided by cerebro

    • 它将返回策略的数据[0]在大脑提供的默认券商【经纪人】中的位置
    • 通过self.getposition内的参数就可以拿到指定数据【也就是后续指定股票】的持仓情况

    A position is simply the indication of:

    持仓位置仅表示:

    • An asset is being held with size

    • 持有股票的数量大小
    • The average price is price

    • 持仓的平均价格

    It serves as a status and can for example be used in deciding if an order has to be issued or not (example: long positions are only entered if no position is open)

    它作为一种状态,例如可用于决定是否必须发出订单(例如:只有在没有空头头寸时才输入多头头寸)

    Reference: Position

    class backtrader.position.Position(size=0, price=0.0)

    Keeps and updates the size and price of a position. The object has no relationship to any asset. It only keeps size and price.

    保持并更新仓位的大小和价格。对象与任何资产都没有关系。它只保留尺寸和价格。

    Member Attributes:

    成员属性:

    * size (int): current size of the position
    
    * price (float): current price of the position
    

    The Position instances can be tested using len(position) to see if size is not null

    可以使用len(Position)测试Position实例,看看size是否不为null

  • 相关阅读:
    65_磁盘文件的使用
    64_设备文件的使用
    63_json解析成map格式
    62_json文件解析成结构体格式
    61_map生成json的使用
    60_通过结构体生成json
    59_字符串的转换
    58_字符串的一些操作函数的使用
    57_recover的使用
    56_异常处理error,errors和painc的使用
  • 原文地址:https://www.cnblogs.com/sidianok/p/13690377.html
Copyright © 2011-2022 走看看