Skip to content

Get position quantity

The get_position_quantity function returns the quantity of the currently held position. This is useful if you want to check if you are currently holding a position before placing a new order.

Method

tm.get_position_quantity()

Inputs

None

Outputs

Quantity of the currently held position.

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# ... Your strategy code here
# Get position quantity
position_quantity = tm.get_position_quantity()
# Print the position quantity
tm.log(f"Position quantity: {position_quantity}")