Closing all Positions
Closing all positions is a simple way to close all open positions at once. This is useful if you want to close all positions at once, for example when you want to stop trading for the day.
Method
tm.close_all_positions(comment="", tags={})
Inputs
Parameter | Argument type | Description | Default Value |
---|---|---|---|
comment | Optional[str] | Comment to add to the orders | "" |
tags | Optional[Dict[str, str]] | Tags to add to the orders | {} |
Outputs
List of orders that were created to close all positions.
Example usage
import tradomate as tm
@tm.strategy()def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# ... Your strategy code here
# Close all positions orders = tm.close_all_positions(comment="Closing all positions", tags={"reason": "End of day"})
# ... Your strategy code here