Close Position
Trading
Close Position
Close an existing position using a reduce-only order
POST
Close Position
Close an existing position using a reduce-only order. The router mirrors the behaviour of the open endpoint—scanning all supported venues for the best exit price unless you force a specific exchange.
The response mirrors the Open Position endpoint, returning execution, routing, and position data so you can reconcile final fills.
Optional - Close specific side:
Features
- Reduce-only safety: Guarantees the API only decreases exposure
- Smart venue selection: Routes exits to the venue with the best available price
- Partial or full closes: Specify any size up to the total position
- Consistent payloads: Response structure matches the open position endpoint for easy reconciliation
Use Cases
- Automate take-profit or stop-loss workflows across multiple exchanges
- Build UI flows for one-click position unwinds
- Implement partial de-risking strategies using precise quantities
- Maintain audit trails with routing and execution metadata in a single response
Request
- Method:
POST - Endpoint:
/api/trade/position/close - Authentication: Required
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
symbol | string | ✅ | Asset symbol being closed |
direction | string | ✅ | Direction of the position you are closing (LONG or SHORT) |
size | string | ✅ | Quantity to close (must not exceed open position size) |
orderType | string | ❌ | MARKET by default; LIMIT supported when limitPrice is supplied |
limitPrice | string | ❌ | Required when orderType is LIMIT |
preferredExchange | string | ❌ | Force close on a specific venue |
credentials | object | ✅ | Exchange credentials required for execution |
Usage Tips
- Reduce-only semantics ensure the API never increases exposure while closing.
- Provide credentials only for venues you wish to use; missing credentials remove that venue from routing consideration.
- For partial closes, set
sizeto the exact quantity you want to reduce.
Hyperliquid - Close Single Position
Close a specific open position for a given symbol on Hyperliquid.Endpoint
POST /api/hyperliquid/:walletId/positions/close/:symbol
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
walletId | string | Yes | Wallet ID (UUID) |
symbol | string | Yes | Asset symbol (e.g., “BTC”) |
Headers
| Header | Value | Required |
|---|---|---|
x-wallet-id | Wallet ID (UUID) | Yes |
Content-Type | application/json | Yes |
Request Body
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | User’s wallet ID |
symbol | string | Yes | Trading pair (e.g., “BTC-PERP”) |
side | string | Yes | ”BUY” or “SELL” (opposite of position) |
type | string | Yes | ”MARKET” or “LIMIT” |
quantity | string | Yes | Quantity to close |
price | string | Yes | Price for the order |
reduceOnly | boolean | Yes | Must be true for closing positions |
Example Request
Success Response
Hyperliquid - Close All Positions
Close all open positions for the wallet on Hyperliquid.Endpoint
POST /api/hyperliquid/:walletId/positions/close-all
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
walletId | string | Yes | Wallet ID (UUID) |
Headers
| Header | Value | Required |
|---|---|---|
x-wallet-id | Wallet ID (UUID) | Yes |
Content-Type | application/json | Yes |
Request Body
Same schema as close-single-symbol.Example Request
Success Response
Aster - Close Position
Close positions on Aster exchange with a single API call.Endpoint
POST /api/aster/perp/:walletId/close-position
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
walletId | string | Yes | Wallet ID (UUID) |
Request Body
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Trading pair (e.g., “BTCUSDT”) |
positionSide | string | No | ”LONG” or “SHORT” (for hedge mode). Omit to close all positions for the symbol |
Example Request
Success Response
Avantis - Close Position (Client-Side Execution)
Avantis positions are closed client-side via on-chain transactions on the Base network. Like opening, closing is not routed through the Tide backend.Close by Pair and Trade Index
Close by Symbol and Direction
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
pairIndex | number | Yes | Pair index from PAIR_INDEX_MAP |
tradeIndex | number | Yes | On-chain trade index |
closeAmountUsdc | string | No | Partial close amount in USDC. Omit for full close |
Close by Symbol Parameters
| Field | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Asset symbol (e.g., “ETH”) |
direction | string | Yes | "LONG" or "SHORT" |
The close operation uses
initialPosToken (not positionSizeUSDC) for the collateral amount, read from TradingStorage.openTrades() on-chain.Authorizations
API key for authentication. Also requires X-API-SECRET, X-API-TIMESTAMP, and X-API-SIGNATURE headers for private endpoints.
Body
application/json
Asset symbol being closed
Available options:
LONG, SHORT Quantity to close
Available options:
LIMIT, MARKET, STOP_MARKET, STOP_LIMIT Required when orderType is LIMIT
Available options:
hyperliquid, aster, lighter, pacifica