Skip to main content
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
  }'
{
  "success": true,
  "message": "Position closed successfully",
  "txHash": "0x1234567890abcdef1234567890abcdef12345680",
  "positionId": 12345,
  "exitPrice": "46123.50",
  "pricePnl": "125.50",
  "accumulatedFunding": "-2.25",
  "grossPnl": "123.25",
  "pnl": "114.50",
  "fee": "8.75",
  "gasUsed": 165000,
  "position": {
    "id": 12345,
    "wallet_address": "0x742d35cc6c6c7532b1140da4c8a2f6c8ecfc9b46",
    "symbol": "BTC-USD",
    "status": "closed",
    "exit_price": "46123.50",
    "realized_pnl": "114.50",
    "total_fee": "8.75",
    "closed_at": "2024-01-15T15:45:00Z"
  },
  "points": {
    "trading_points": 45.8,
    "referral_bonus": 0.0,
    "total_points": 45.8
  }
}
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
  }'
{
  "success": true,
  "message": "Position closed successfully",
  "txHash": "0x1234567890abcdef1234567890abcdef12345680",
  "positionId": 12345,
  "exitPrice": "46123.50",
  "pricePnl": "125.50",
  "accumulatedFunding": "-2.25",
  "grossPnl": "123.25",
  "pnl": "114.50",
  "fee": "8.75",
  "gasUsed": 165000,
  "position": {
    "id": 12345,
    "wallet_address": "0x742d35cc6c6c7532b1140da4c8a2f6c8ecfc9b46",
    "symbol": "BTC-USD",
    "status": "closed",
    "exit_price": "46123.50",
    "realized_pnl": "114.50",
    "total_fee": "8.75",
    "closed_at": "2024-01-15T15:45:00Z"
  },
  "points": {
    "trading_points": 45.8,
    "referral_bonus": 0.0,
    "total_points": 45.8
  }
}

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 Privy JWT token. You can only close positions that belong to your wallet.

Authentication

Include your Privy JWT token in the Authorization header:
X-API-Key: stk_your_api_key_here

Request Body

positionId
integer
required
The unique identifier of the position to close.How to get: Use Get Positions to find your position IDs
Example: 12345

Response Fields

success
boolean
Indicates if the position was closed successfully
message
string
Success message describing the operation
txHash
string
Blockchain transaction hash for the position closure
positionId
integer
ID of the closed position
exitPrice
string
Price at which the position was closed
pricePnl
string
PnL from price movement only (excludes funding)
accumulatedFunding
string
Total funding payments received/paid during position lifetime
grossPnl
string
Total PnL including funding (pricePnl + accumulatedFunding)
pnl
string
Net PnL after fees (grossPnl - fee)
fee
string
Total fees charged for closing the position
gasUsed
integer
Gas consumed for the transaction
position
object
Updated position object with closure details
points
object
Points breakdown earned from this trade:
  • trading_points: Base points from trading volume
  • referral_bonus: Additional points from referral multipliers
  • total_points: Total points awarded

Position Closure Mechanics

PnL Calculation

Long Positions

PnL = Position Size × ((Exit Price - Entry Price) / Entry Price)
Example:
  • Entry: 45,000 USD, Exit: 46,000 USD, Size: 1,000 USD
  • PnL = 1,000 USD × ((46,000 - 45,000 USD) / 45,000 USD) = 22.22 USD

Short Positions

PnL = Position Size × ((Entry Price - Exit Price) / Entry Price)
Example:
  • Entry: 45,000 USD, Exit: 44,000 USD, Size: 1,000 USD
  • PnL = 1,000 USD × ((45,000 - 44,000 USD) / 45,000 USD) = 22.22 USD

Fee Structure

Strike Protocol uses a dynamic fee structure for closing positions:

Base Fee

  • Standard rate: 0.1% of position size
  • Applied to all position closures

Dynamic Fees

Additional fees based on:
  • Position size: Larger positions pay higher fees
  • Profit percentage: Higher profits incur additional fees
  • Market impact: Fees adjust based on market conditions

Fee Calculation Example

Position Size: 1,000 USD
Base Fee (0.1%): 1.00 USD
Dynamic Fee (based on profit): 7.75 USD
Total Fees: 8.75 USD

Settlement Types

Immediate Settlement

  • Condition: Net payout ≤ available treasury balance
  • Timeline: Immediate credit to account
  • Best case: Instant access to funds

Queue Settlement

  • Condition: Net payout > available treasury balance
  • Timeline: Added to payout queue
  • Process: First-in-first-out queue processing

Funding Payments

Positions open for 8+ hours may have funding payments applied:
  • Long positions: Pay funding to short holders (if funding rate is positive)
  • Short positions: Pay funding to long holders (if funding rate is negative)
  • Accumulated funding: Included in PnL calculation

Business Logic

Position Validation

  • Position must exist and belong to authenticated wallet
  • Position must be in “open” status
  • Cannot close already closed or liquidated positions

Market Price Usage

  • Closure executed at current mark price
  • Price obtained from HyperLiquid price feed
  • No slippage protection (market order execution)

Balance Updates

After successful closure:
  1. Original margin: Always returned
  2. PnL: Added to (profit) or subtracted from (loss) balance
  3. Fees: Deducted from final amount
  4. Net result: Added to withdrawable balance (if positive)

Error Responses

400 Bad Request
object
Invalid position ID or position cannot be closed
{
  "error": 400,
  "message": "Position not found or already closed"
}
401 Unauthorized
object
Missing or invalid authentication token
{
  "error": 401,
  "message": "Authorization header missing"
}
403 Forbidden
object
Attempting to close position that doesn’t belong to your wallet
{
  "error": 403,
  "message": "Position does not belong to authenticated wallet"
}
429 Too Many Requests
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
}

Usage Examples

Closing a Profitable Position

Request:
{
  "positionId": 12345
}

Response:
{
  "success": true,
  "txHash": "0x...",
  "pnl": "125.50",
  "fees": "8.75", 
  "netPayout": "216.75"
}
Analysis: 100 USD margin + 125.50 USD profit - 8.75 USD fees = 216.75 USD payout

Closing a Loss Position

Request:
{
  "positionId": 12346
}

Response:
{
  "success": true,
  "txHash": "0x...",
  "pnl": "-45.25",
  "fees": "5.50",
  "netPayout": "49.25"
}
Analysis: 100 USD margin - 45.25 USD loss - 5.50 USD fees = 49.25 USD payout

Large Position Closure

Request:
{
  "positionId": 12347
}

Response:
{
  "success": true,
  "txHash": "0x...",
  "pnl": "2500.00",
  "fees": "125.00",
  "netPayout": "4375.00"
}
Analysis: Higher fees due to larger position size and profit

When to Close Positions

Take Profit Scenarios

  • Target reached: Close when profit target is achieved
  • Technical resistance: Close at key resistance levels
  • Risk management: Lock in profits before potential reversal

Stop Loss Scenarios

  • Loss limit: Close when maximum acceptable loss is reached
  • Technical breakdown: Close when key support levels break
  • Market conditions: Close during high volatility or news events

Portfolio Management

  • Rebalancing: Close positions to rebalance portfolio
  • Risk reduction: Close highly leveraged positions
  • Opportunity cost: Close underperforming positions for new opportunities

Alternative Closure Methods

Automatic Liquidation

  • Triggered when position reaches liquidation price
  • No control over timing or price
  • Higher fees than manual closure

Emergency Exit

  • Use Emergency Exit for immediate margin refund
  • No PnL realization
  • Should only be used in emergencies

Next Steps

After closing a position:
  1. Check Balance - View updated balance in Account
  2. Review Performance - Analyze trade in Dashboard
  3. Monitor Queue - If queued, check status with Queue Positions
  4. 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.

Authorizations

X-API-Key
string
header
required

Strike Protocol API key authentication

Body

application/json
positionId
integer
required

Position ID to close

Response

Position closed successfully

success
boolean
txHash
string
pnl
string
fees
string
netPayout
string