Skip to main content

Partial close

A partial close sells (or buys back) part of an open position and leaves the rest open, with its stop-loss and take-profit.

Sending a partial close​

Send a CLOSE with a close_ratio between 0 and 1. A CLOSE with close_ratio below 1 is executed as CLOSE_PARTIAL; you can also send CLOSE_PARTIAL directly.

{
"strategy_key": "YOUR_STRATEGY_KEY",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "CLOSE",
"close_ratio": 0.5
}

As with every signal, exchange and ticker must match the bot.

How much is closed​

close_ratio is a fraction of the original filled size of the trade, not of what is left. The amount closed is capped at what is still open.

PositionSignalClosedLeft open
1.0 BTC filledclose_ratio: 0.50.5 BTC0.5 BTC
thenclose_ratio: 0.50.5 BTC0 (fully closed)
1.0 BTC filledclose_ratio: 0.3, then 0.30.3 + 0.3 BTC0.4 BTC

To close everything that is left, send a plain CLOSE (without close_ratio, or with close_ratio: 1).

  • A close_ratio of 1 is a full close.
  • A missing close_ratio, or 0, is also treated as a full close.
  • Do not send values above 1: they are not valid ratios, and CLOSE_PARTIAL rejects them.

What happens to the stop-loss and take-profit​

On a live bot, the open stop-loss and take-profit orders are cancelled for the partial close and then placed again for the remaining quantity, at the trade's stored prices. If they cannot be placed again, you are alerted that the remaining position is not protected. Check it on the exchange.

Paper bots have no exchange-side stop-loss or take-profit, so nothing needs to be re-placed.

PnL​

Each partial close is recorded on the trade with its quantity, price and PnL. The trade's total PnL, including every partial close, is added to the bot's allocated amount once, when the trade is fully closed.

Multi-symbol bots​

On a multi-symbol bot, a partial close acts on one coin: the one named in ticker. The other coins are not touched.

{
"strategy_key": "YOUR_MULTI_SYMBOL_BOT_KEY",
"exchange": "BINANCE",
"ticker": "ETHUSDT.P",
"position_side": "CLOSE",
"close_ratio": 0.25
}

A partial close for a ticker the bot has no position in is skipped.

Duplicates​

Each webhook delivery is a separate signal. If the same partial-close alert is delivered twice, two slices are closed. Configure TradingView alerts to fire once per bar close, and make sure your script does not send the same exit twice.