Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Position

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

  • position (a property) orgetposition(data=None, broker=None)

    Which will return the position ondatas[0] of the strategy in thedefaultbroker provided by cerebro

A position is simply the indication of:

  • An asset is being held withsize

  • The average price isprice

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

Reference: Position

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

Keeps and updates the size and price of a position. The object has norelationship 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 sizeis not null


[8]ページ先頭

©2009-2025 Movatter.jp