Overview

You can close open positions by asset or close all positions. When you close all open margin positions, BitGo will start an asynchronous process that buys and sells assets in an attempt to net them to zero.

Prerequisites

Cookbook

Need just the steps? Expand the cookbook below to get started:

Close Margin PositionsOpen Cookbook

Close Positions

Endpoint: Close All Margin Positions

export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export ACCOUNT_ID="<YOUR_ACCOUNT_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X POST \
  http://$BITGO_EXPRESS/api/prime/trading/v1/accounts/$ACCOUNT_ID/margin/positions/close \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
        "all": true
      }'

See Also