Margin Trading

Preview Margin Order Impact

Previews the margin impact of a hypothetical spot order without actually placing it.

Returns both pre-order and post-order margin risk statistics, allowing you to understand how an order would affect your margin account before execution. This is useful for risk management and planning trades.

Roles

The API key you use to access this endpoint must have the Trader or Auditor role assigned. See Roles for more information.

The OAuth scope must have orders:read assigned to access this endpoint. See OAuth Scopes for more information.

Account Type

This endpoint is only available for margin trading accounts.

post/v1/margin/order/preview

Request

  • Base URL
    https://api.gemini.com
  • URL
    https://api.gemini.com/v1/margin/order/preview
  • Auth
    API key in header X-GEMINI-APIKEY and API key in header X-GEMINI-SIGNATURE and API key in header X-GEMINI-PAYLOAD

Headers

X-GEMINI-APIKEYstring required

Your API key

X-GEMINI-SIGNATUREstring required

HEX-encoded HMAC-SHA384 of payload signed with API secret

X-GEMINI-PAYLOADstring required

Base64-encoded JSON payload

Content-Typestring
Content-Lengthstring
Cache-Controlstring

Request body

requeststring required

The literal string "/v1/margin/order/preview"

symbolstring required

The trading pair symbol (e.g., "btcusd")

side'buy' | 'sell' required

The order side

type'market' | 'limit' required

The order type

amountstring decimal

The order amount in base currency (required for limit orders and sell market orders)

pricestring decimal

The limit price (required for limit orders)

totalSpendstring decimal

Total spend in quote currency (required for buy market orders)

accountstring

Required for Master API keys as described in Private API Invocation. The name of the account within the subaccount group.

Example request

{
  "nonce": "1495127793000",
  "symbol": "btcusd",
  "side": "buy",
  "type": "limit",
  "amount": "0.5",
  "price": "50000.00",
  "totalSpend": "25000.00"
}

Response

Pre-order and post-order margin risk statistics

Example response

{
  "preorder": {
    "marginAssetValue": {
      "currency": "USD",
      "value": "10000.00"
    },
    "availableCollateral": {
      "currency": "USD",
      "value": "10000.00"
    },
    "notionalValue": {
      "currency": "USD",
      "value": "10000.00"
    },
    "totalBorrowed": {
      "currency": "USD",
      "value": "10000.00"
    },
    "leverage": "1.5",
    "reservedBuyOrders": {
      "currency": "USD",
      "value": "10000.00"
    },
    "reservedSellOrders": {
      "currency": "USD",
      "value": "10000.00"
    },
    "buyingPower": {
      "currency": "USD",
      "value": "10000.00"
    },
    "sellingPower": {
      "currency": "USD",
      "value": "10000.00"
    },
    "liquidationRisk": {
      "lossPercentage": "0.1550",
      "liquidationPrice": {
        "currency": "USD",
        "value": "10000.00"
      }
    }
  },
  "postorder": {
    "marginAssetValue": {
      "currency": "USD",
      "value": "10000.00"
    },
    "availableCollateral": {
      "currency": "USD",
      "value": "10000.00"
    },
    "notionalValue": {
      "currency": "USD",
      "value": "10000.00"
    },
    "totalBorrowed": {
      "currency": "USD",
      "value": "10000.00"
    },
    "leverage": "1.5",
    "reservedBuyOrders": {
      "currency": "USD",
      "value": "10000.00"
    },
    "reservedSellOrders": {
      "currency": "USD",
      "value": "10000.00"
    },
    "buyingPower": {
      "currency": "USD",
      "value": "10000.00"
    },
    "sellingPower": {
      "currency": "USD",
      "value": "10000.00"
    },
    "liquidationRisk": {
      "lossPercentage": "0.1550",
      "liquidationPrice": {
        "currency": "USD",
        "value": "10000.00"
      }
    }
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.