You can create trailing stop orders by making a request to POST /trade/v1/orders with field OrderType set to TrailingStopIfTraded. The additional required parameters TrailingStopDistanceToMarket and TrailingStopStep should contain absolute values, set according to your order's strategy. The field OrderPrice is still required to place the order. Even with the other fields present, it does influence the behavior of the order.
Note: The order is activated to step when the OrderPrice is greater than (buy) or less than (sell) (MarketPrice - TrailingStopDistanceToMarket).
To illustrate the possible behaviors, consider these 3 scenarios, when placing a sell order of type TrailingStopIfTraded:
-
OrderPrice < (MarketPrice - TrailingStopDistanceToMarket)
- The Order is placed with that order price, but immediately steps up to the:
- (MarketPrice - TrailingStopDistanceToMarket)
- The Order is placed with that order price, but immediately steps up to the:
-
OrderPrice is between (MarketPrice - TrailingStopDistanceToMarket) and Market Price
- The order is placed with that order price, and is activated for steps when:
- OrderPrice < (MarketPrice - TrailingStopDistanceToMarket)
- The order is placed with that order price, and is activated for steps when:
-
OrderPrice > MarketPrice
- The order is on wrong side of market and is rejected
When placing orders of this type, or of similar complexity, we strongly recommend utilizing our simulation environment to ensure a full understanding of these scenarios such that there is full code & test coverage.
More Resources