Position Management
Position types for changing the protective orders of an open position, or for replacing the position.
exchange and ticker are left out of some examples below to keep them short. Real signals must include both, and they must match the bot.
MOVE_STOP_LOSS
Replaces the open trade's stop-loss and take-profit orders with the prices in the signal. The position itself is not changed.
{
"strategy_key": "your_key",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "MOVE_STOP_LOSS",
"stop_loss_price": 50000,
"take_profit_price": 56000
}
MOVE_STOP_LOSS cancels the current stop-loss and take-profit orders, then places new ones from the signal's stop_loss_price and take_profit_price. A level you leave out is removed. To move only the stop, send the current take-profit price again.
Behavior:
- The orders are re-created for the quantity that is still open. Fills of the old stop-loss or take-profit are recorded first.
- If the new stop-loss cannot be placed, the position is closed: positions without a stop-loss are not allowed.
- If the entry order has not filled yet, the signal is retried until it has.
- If no open trade exists, the signal waits 5 seconds and checks once more before it gives up.
- Paper bots: there are no exchange-side stop or take-profit orders, so the signal has no effect.
- An open trade lets this signal pass checks that block new entries (the exit pass).
Move stop loss to break even
{
"strategy_key": "your_key",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "MOVE_STOP_LOSS",
"stop_loss_price": 50000,
"take_profit_price": 55000,
"reason": "Break even"
}
SET_ORDERS
Same as MOVE_STOP_LOSS, with a delay. It is converted to MOVE_STOP_LOSS and waits processing_delay seconds (3 seconds when none is given) before it is queued. This is useful when the alert fires right after an entry and the entry should be processed first.
{
"strategy_key": "your_key",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "SET_ORDERS",
"stop_loss_price": 49000,
"take_profit_price": 56000
}
CLOSE_LIMIT_ORDER
An alias for MOVE_STOP_LOSS. It is converted before execution.
CANCEL_ORDERS
Cancels the open trade's stop-loss and/or take-profit order without closing the position. Choose which with cancel_stop_loss and cancel_take_profit.
{
"strategy_key": "your_key",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "CANCEL_ORDERS",
"cancel_stop_loss": true,
"cancel_take_profit": true
}
An order id is cleared from the trade only after the exchange confirms the cancel. Without its stop-loss, the position is unprotected: use this only when you manage the exit yourself.
UPDATE_ORDER
Replaces the position. If the bot has an open trade, it is closed first; then a new position is opened in the direction of action (BUY = long, SELL = short), with the signal's entry, stop-loss and take-profit. If the old position cannot be closed, the new one is not opened.
{
"strategy_key": "your_key",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "UPDATE_ORDER",
"action": "BUY",
"leverage": 5,
"entry_price": 51000,
"stop_loss_price": 49500,
"take_profit_price": 56000
}
UPDATE_ORDER is not a stop moveOlder versions of this page described UPDATE_ORDER as a way to change the stop-loss and take-profit. It is not: it closes the position and opens a new one, with fees and a new entry price. To change the protective orders, use MOVE_STOP_LOSS.
When your plan check fails, or the bot is stopped while a trade is open, UPDATE_ORDER is reduced to its closing half: the trade is closed and nothing new is opened.
Next Steps
- Opening Positions - How to open positions
- Closing Positions - How to close positions
- Examples - Update order examples