> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ostium.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Closing a Trade

> Manual closes, automated TP/SL, liquidation, and what happens to your collateral on each path.

There are four ways a position closes on Ostium: manual full close, manual partial close, automated close via TP/SL, or liquidation.

***

## Manual Close

### Full Close

Click **Close** on any open position to exit entirely at the current bid (longs) or ask (shorts). Your collateral plus or minus PnL is returned to your wallet. The \$0.10 oracle fee charged at open is refunded on a successful full close.

### Partial Close

Close a portion of your position while keeping the rest open. Set the dollar amount or percentage in the close dialog. Each partial close incurs a \$0.10 oracle fee. The remaining position must still meet the pair's minimum trade size.

***

## Automated Close: TP and SL

Take-profit and stop-loss orders close your position automatically when the market reaches your specified level. Both are set and managed from the Positions panel (see [Managing Positions](/traders/trading/managing-positions)).

* **Take-Profit (TP):** Triggers when price moves in your favor. Executes as a limit close at your target price.
* **Stop-Loss (SL):** Triggers when mid-price crosses your level. Executes as a market close at the bid/ask.

Automated TP and SL executions do not charge an oracle fee. No cancellation fees apply.

***

## Liquidation

Liquidation is an automatic close triggered when your collateral falls below the liquidation threshold. There is no margin call. Keeper bots (Gelato Functions) execute liquidations onchain; the protocol pays the gas fee.

After liquidation, remaining collateral is retained by the protocol as part of settlement. You do not receive any remaining collateral. See [Vault Overview](/vault/overview) for how settlement flows reconcile onchain and offchain.

See [Liquidation](/traders/trading/liquidation) for thresholds, formulas, and how to avoid it.

***

## Collateral After Close

| Outcome          | What Happens                                                                                                    |
| ---------------- | --------------------------------------------------------------------------------------------------------------- |
| **Positive PnL** | Initial collateral + profits returned to your wallet.                                                           |
| **Negative PnL** | Initial collateral minus losses returned to your wallet. Losses retained by the protocol as part of settlement. |
| **Liquidation**  | All remaining collateral retained by the protocol as part of settlement. Nothing returned.                      |

***

## FAQ

<Accordion title="Is there a closing fee?">
  Profitable closes within the first 15 seconds of opening incur an early-close fee that decays linearly from 40 bps to 0. The fee is capped at the position's realized profit, so it cannot make a trade net-negative. Closes after 15 seconds, and losing or breakeven closes within 15 seconds, pay nothing to close. The oracle fee from opening is refunded on a successful full close. See [Early-Close Fee](/traders/reference/fees#early-close-fee) for the full mechanics and a worked example.
</Accordion>

<Accordion title="Can I close part of my position?">
  Yes — see **Partial Close** above. A \$0.10 oracle fee applies per partial close, and the remaining position must meet the pair's minimum trade size.
</Accordion>

<Accordion title="Do I get collateral back after liquidation?">
  No. Remaining collateral is retained by the protocol as part of settlement. Liquidation thresholds, formulas, and mechanics for avoiding liquidation (stop-losses, lower leverage, added collateral) are documented on the [Liquidation](/traders/trading/liquidation) page.
</Accordion>

***

<Note>
  **Building this programmatically?** The Builder SDK exposes [`closeTrade()`](/developer/reference/close-trade) for full and partial closes. See [Close a Trade](/developer/traders/close-a-trade).
</Note>

## What to Read Next

* **[Liquidation](/traders/trading/liquidation)** — Thresholds, formulas, and worked examples.
* **[Fees](/traders/reference/fees)** — All costs on Ostium in one page.
* **[Managing Positions](/traders/trading/managing-positions)** — Adjust TP/SL and collateral while open.
