Skip to main content
A full, runnable perps bot. It opens a leveraged BTC long with a take-profit bracket, reads live PnL, and closes the position. Collateral is USDC, and closing settles back to USDC. Before you run it: create an API key and fund your wallet with USDC (Quickstart). Perpetuals are restricted in some regions and may require identity verification; a blocked call returns 403 (see Eligibility & geo restrictions).
Leverage can liquidate your collateral on an adverse move. Size positions you can afford to lose and watch liquidationPriceUsd.

The whole flow

Step by step

  1. Create a group (POST /groups) to open the idea in.
  2. Pick a market (GET /perps/markets/{symbol}) and read markPriceUsd to size your entry.
  3. Open a position (POST /perps/proposals) with side, collateralUsd, leverage, and an optional takeProfitPct / stopLossPct bracket (expressed as % of collateral ROI). You get back your assignmentId — your position’s id.
  4. Monitor (GET /perps/positions?filter=active) for live unrealizedPnlUsd, liquidationPriceUsd, and funding. For low-latency prices, use market data over WebSocket.
  5. Close (POST /perps/positions/{assignmentId}/reduce) with reduceFraction: "1" and isFullClose: true. Proceeds settle back to your wallet in USDC.
If your takeProfitPct bracket fires before you close, the position closes automatically and becomes claimable. In that case skip /reduce and call POST /perps/positions/{assignmentId}/claim to drain the proceeds. See the Perpetuals guide.