Close trade
/perp/isolated/trade/closePrivateClose a running trade at the bid (long) or ask (short) price for its size. Its margin plus P&L, and the maintenance margin left after the closing fee, are credited to your balance. Returns the closed trade.
Permissions: futures:isolated:write
application/json- body
id*stringTrade ID
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidinstrument*stringInstrument of the market
"inverse_perp""quanto_perp"pair*stringPair of the market
OK
application/json- response
id*stringInternal trade ID
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidinstrument*stringInstrument of the market
"inverse_perp""quanto_perp"pair*stringPair of the market
type*stringlimit or market
"market""limit"side*stringTrade side
"buy""sell"openingFee*integerFee paid when opening the position
closingFee*integerFee paid when closing the position
maintenanceMargin*integerMinimum margin required to keep the position open
quantity*numberNumber of contracts in the trade
entryNotionalUsd*numberNotional value at entry (in USD)
exitNotionalUsd*numberNotional value at exit (in USD)
margin*integerCurrent margin for the position
leverage*numberLeverage multiplier applied to the position
price*numberPrice when the trade was filled (in USD)
liquidation*numberPrice at which the position will be liquidated (in USD)
stoploss*numberStop loss price level (0 if not set, in USD)
takeprofit*numberTake profit price level (0 if not set, in USD)
stoplossTrailingDistance*numberTrailing stop distance as a fraction of price (0 if not trailing)
exitPrice*numberPrice when exiting the position (in USD)
pl*integerProfit and loss for the closed position
createdAt*stringTimestamp when the trade was created
date-timefilledAt*stringTimestamp when the trade was filled in the market
date-timeclosedAt*stringTimestamp when the trade was closed
date-timeentryPrice*numberPrice when entering the position (in USD)
entryMargin*integerInitial margin when entering the position
entryBtcPrice*numberBitcoin price the sats amounts of the trade are valued at (in USD)
open*booleanWhether the trade is open (not yet filled)
running*booleanWhether the trade is running (filled but not closed)
canceled*booleanWhether the trade was canceled before being filled
closed*booleanWhether the trade is closed (position exited)
sumFundingFees*integerTotal funding fees accumulated for the position
sumQuantoAdjustmentFees*integerTotal quanto adjustment fees accumulated for the position
sumCashInPl*integerTotal amount cashed in from PL over the trade lifetime
sumCashInMargin*integerTotal amount cashed in from margin over the trade lifetime
clientId*|Optional custom data field (max 64 characters)
label*|Optional free label (max 64 characters) to group or tag trades, e.g. by strategy. Not unique.
nullimport { createHttpClient } from '@ln-markets/sdk/rest/v3'
const client = createHttpClient({
key: 'your-key',
secret: 'your-secret',
passphrase: 'your-passphrase',
})
const result = await client.perp.isolated.closeTrade({
id: 'd0b9f9a0-4f6e-4a5a-8b7a-7f0f5f9a8a1e',
instrument: 'inverse_perp',
pair: 'btc_usd'
}){
"id": "d0b9f9a0-4f6e-4a5a-8b7a-7f0f5f9a8a1e",
"instrument": "inverse_perp",
"pair": "btc_usd",
"type": "market",
"side": "buy",
"openingFee": 10,
"closingFee": 10,
"maintenanceMargin": 10,
"quantity": 100,
"entryNotionalUsd": 100,
"exitNotionalUsd": 100,
"margin": 1000,
"leverage": 10,
"price": 20000,
"liquidation": 18000,
"stoploss": 10,
"takeprofit": 10,
"stoplossTrailingDistance": 0,
"exitPrice": 20150,
"pl": 150,
"createdAt": "2025-09-01T15:04:21.129Z",
"filledAt": "2025-09-01T15:04:21.129Z",
"closedAt": "2025-09-02T15:04:21.129Z",
"entryPrice": 20000,
"entryMargin": 1000,
"entryBtcPrice": 100000,
"open": false,
"running": false,
"canceled": false,
"closed": true,
"sumFundingFees": 23,
"sumQuantoAdjustmentFees": 0,
"sumCashInPl": 0,
"sumCashInMargin": 0,
"clientId": "test-client-id-123",
"label": "strategy-a"
}Cash-in trade POST
Move amount sats from a running trade to your balance. Funds are first taken from the trade's P&L (if any), valued at the Mark price, then from its…
Get trade GET
Get one of your trades in any state, of any perpetual market, by its id or its clientId (pass exactly one). A running trade pl is the unrealized P&L…