Close an existing position using a reduce-only order
POST/api/trade/position/close| 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 |
size to the exact quantity you want to reduce.POST /api/hyperliquid/:walletId/positions/close/:symbol
| Parameter | Type | Required | Description |
|---|---|---|---|
walletId | string | Yes | Wallet ID (UUID) |
symbol | string | Yes | Asset symbol (e.g., “BTC”) |
| Header | Value | Required |
|---|---|---|
x-wallet-id | Wallet ID (UUID) | Yes |
Content-Type | application/json | Yes |
| 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 |
POST /api/hyperliquid/:walletId/positions/close-all
| Parameter | Type | Required | Description |
|---|---|---|---|
walletId | string | Yes | Wallet ID (UUID) |
| Header | Value | Required |
|---|---|---|
x-wallet-id | Wallet ID (UUID) | Yes |
Content-Type | application/json | Yes |
POST /api/aster/perp/:walletId/close-position
| Parameter | Type | Required | Description |
|---|---|---|---|
walletId | string | Yes | Wallet ID (UUID) |
| 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 |
API key for authentication. Also requires X-API-SECRET, X-API-TIMESTAMP, and X-API-SIGNATURE headers for private endpoints.
Asset symbol being closed
LONG, SHORT Quantity to close
LIMIT, MARKET, STOP_MARKET, STOP_LIMIT Required when orderType is LIMIT
hyperliquid, aster, lighter, avantis