Entering a Short Position
Entering a short position means you are going short on an asset. This is useful if you want to enter a position at once, for example when you want to enter a position when a certain condition is met.
Often, you want to enter a short position when you think the price will go down.
Currently, only market orders are supported. More order types will be added in the future.
Method
tm.enter_short_position_market(quantity, comment="", tags={})
When you enter a short position, all open long positions will be closed.
Inputs
Parameter | Argument type | Description | Default Value |
---|---|---|---|
quantity | float | Quantity to short | - |
comment | Optional[str] | Comment to add to the order | "" |
tags | Optional[Dict[str, str]] | Tags to add to the order | {} |
stop_loss_percent | Optional[float] | Stop loss percentage | None |
take_profit_percent | Optional[float] | Take profit percentage | None |
Outputs
Order that was created to enter the position.
Example usage
import tradomate as tm
@tm.strategy()def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# ... Your strategy code here
# Enter a short position order = tm.enter_short_position_market( quantity=1, comment="Entering short position", tags={"reason": "Signal"}, stop_loss_percent=5, take_profit_percent=10 )
# ... Your strategy code here