Position#
- class lumibot.entities.position.Position(strategy, asset, quantity, orders=None, hold=0, available=0, avg_fill_price=None)
Bases:
object
This is a Position object. It is used to keep track of the quantity of an asset owned in a strategy. Position objects are retreived from the broker using the get_positions() or get_position() methods.
- strategy
The strategy that owns this position.
- Type:
str
- asset
The asset that this position is for.
- Type:
Asset
- symbol
The symbol of the asset. e.g. AAPL for Apple stock.
- Type:
str
- quantity
The quantity of the asset owned.
- Type:
float
- orders
The orders that have been executed for this position.
- Type:
list of Order
- hold
The assets that are not free in the portfolio. (Crypto: only)
- Type:
float
- available
The assets that are free in the portfolio. (Crypto: only)
- Type:
float
- avg_fill_price
The average fill price of the position.
- Type:
float
- add_order(order: Order, quantity: Decimal = Decimal('0'))
- property available
- classmethod from_dict(data)
- get_selling_order(quote_asset=None)
Returns an order that can be used to sell this position.
- Parameters:
None –
- Returns:
order – An order that can be used to sell this position.
- Return type:
Order
- property hold
- property quantity
- to_dict()
Convert position to dictionary for serialization.
NOTE: We explicitly exclude internal Python fields and large data fields that can cause DynamoDB 400KB limit errors: - _bars: Historical bar data (can be 1.8MB+) - _raw: Raw broker response data (can be 22KB+) - _asset: Duplicate asset data (5KB+) - Any field starting with underscore (Python internals)
We ONLY return the essential fields needed for portfolio tracking.
- value_type(value)