curl -X POST "https://api.strike.markets/close" \
-H "X-API-Key: stk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"positionId": 12345
}'
const response = await fetch('https://api.strike.markets/close', {
method: 'POST',
headers: {
'X-API-Key': 'stk_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
positionId: 12345
})
});
const data = await response.json();
console.log('Position closed:', data);
import requests
response = requests.post(
'https://api.strike.markets/close',
headers={
'X-API-Key': 'stk_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'positionId': 12345
}
)
data = response.json()
print('Position closed:', data)
{
"success": true,
"message": "Position closed successfully",
"txHash": "0x1234567890abcdef1234567890abcdef12345680",
"gasUsed": 165000,
"positionId": 12345,
"symbol": "BTC-USD",
"szi": "0.002217",
"margin": "100.0",
"entryPrice": "45123.50",
"exitPrice": "46123.50",
"realizedPnl": "114.50",
"pnlFee": "8.75",
"status": "closed",
"createdAt": "2024-01-15T14:30:00Z",
"closedAt": "2024-01-15T15:45:00Z",
"settledAt": null,
"spread": "5.25"
}
Trading Operations
Close Position
Manually close an existing position
POST
/
close
curl -X POST "https://api.strike.markets/close" \
-H "X-API-Key: stk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"positionId": 12345
}'
const response = await fetch('https://api.strike.markets/close', {
method: 'POST',
headers: {
'X-API-Key': 'stk_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
positionId: 12345
})
});
const data = await response.json();
console.log('Position closed:', data);
import requests
response = requests.post(
'https://api.strike.markets/close',
headers={
'X-API-Key': 'stk_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'positionId': 12345
}
)
data = response.json()
print('Position closed:', data)
{
"success": true,
"message": "Position closed successfully",
"txHash": "0x1234567890abcdef1234567890abcdef12345680",
"gasUsed": 165000,
"positionId": 12345,
"symbol": "BTC-USD",
"szi": "0.002217",
"margin": "100.0",
"entryPrice": "45123.50",
"exitPrice": "46123.50",
"realizedPnl": "114.50",
"pnlFee": "8.75",
"status": "closed",
"createdAt": "2024-01-15T14:30:00Z",
"closedAt": "2024-01-15T15:45:00Z",
"settledAt": null,
"spread": "5.25"
}
curl -X POST "https://api.strike.markets/close" \
-H "X-API-Key: stk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"positionId": 12345
}'
const response = await fetch('https://api.strike.markets/close', {
method: 'POST',
headers: {
'X-API-Key': 'stk_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
positionId: 12345
})
});
const data = await response.json();
console.log('Position closed:', data);
import requests
response = requests.post(
'https://api.strike.markets/close',
headers={
'X-API-Key': 'stk_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'positionId': 12345
}
)
data = response.json()
print('Position closed:', data)
{
"success": true,
"message": "Position closed successfully",
"txHash": "0x1234567890abcdef1234567890abcdef12345680",
"gasUsed": 165000,
"positionId": 12345,
"symbol": "BTC-USD",
"szi": "0.002217",
"margin": "100.0",
"entryPrice": "45123.50",
"exitPrice": "46123.50",
"realizedPnl": "114.50",
"pnlFee": "8.75",
"status": "closed",
"createdAt": "2024-01-15T14:30:00Z",
"closedAt": "2024-01-15T15:45:00Z",
"settledAt": null,
"spread": "5.25"
}
Overview
Manually close an existing position at the current market price. This endpoint allows you to realize profits or cut losses by closing your position immediately.This endpoint requires authentication with a valid API key. You can only close positions that belong to your wallet.
Authentication
Include your API key in the X-API-Key header:X-API-Key: stk_your_api_key_here
Request Body
integer
required
The unique identifier of the position to close.How to get: Use Get Positions to find your position IDs
Example: 12345
Example: 12345
Response Fields
boolean
Indicates if the position was closed successfully
string
Success message describing the operation
string
Blockchain transaction hash for the position closure
integer
ID of the closed position
string
Price at which the position was closed
string
PnL from price movement only (excludes funding)
string
Total funding payments received/paid during position lifetime
string
Total PnL including funding (pricePnl + accumulatedFunding)
string
Net PnL after fees (grossPnl - fee)
string
Total fees charged for closing the position
integer
Gas consumed for the transaction
object
Updated position object with closure details
Error Responses
object
Invalid position ID or position cannot be closed
{
"error": 400,
"message": "Position not found or already closed"
}
object
Missing or invalid authentication token
{
"error": 401,
"message": "Authorization header missing"
}
object
Attempting to close position that doesn’t belong to your wallet
{
"error": 403,
"message": "Position does not belong to authenticated wallet"
}
object
Rate limit exceeded (10 requests per minute for trading endpoints)
{
"error": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. Please wait 45 seconds.",
"retry_after": 45
}
Next Steps
After closing a position:- Check Balance - View updated balance in Account
- Review Performance - Analyze trade in Dashboard
- Monitor Queue - If queued, check status with Queue Positions
- Plan Next Trade - Use Market Data for analysis
Consider market conditions and your overall strategy before closing positions. Sometimes holding through temporary volatility can be more profitable than frequent trading.
Position closure is irreversible. Make sure you want to close the position before submitting the request.