Skip to content

Entering a Long Position

Entering a long position means you are going long 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 long position when you think the price will go up.

Method

tm.enter_long_position_market(quantity, comment="", tags={})

Inputs

ParameterArgument typeDescriptionDefault Value
quantityfloatQuantity to buy-
commentOptional[str]Comment to add to the order""
tagsOptional[Dict[str, str]]Tags to add to the order{}
stop_loss_percentOptional[float]Stop loss percentageNone
take_profit_percentOptional[float]Take profit percentageNone

Outputs

Order that was created to enter the position.

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# ... Your strategy code here
# Enter a long position
order = tm.enter_long_position_market(
quantity=1,
comment="Entering long position",
tags={"reason": "Signal"},
stop_loss_percent=5,
take_profit_percent=10
)
# ... Your strategy code here