Subaccounts

private/get_margin

Changed on

Calculates net initial and maintenance margin for a subaccount before and after an optional simulated state change (position and/or collateral deltas), and whether that change would pass the margin requirement. Values are net margin — mark-to-market value minus the requirement — so positive means healthy. Does not take open-order margin into account. Margins use the subaccount's manager's params. Set is_delayed_liquidation to use its delayed-liquidation override instead, as order checks do; the request is rejected for a subaccount without one.

post/private/get_margin

Request

  • Base URL
    https://api.derive.xyz/v3
  • Auth
    API key in header X-DeriveWallet and API key in header X-DeriveTimestamp and API key in header X-DeriveSignature

Request body

PrivateGetMarginRequest required
is_delayed_liquidation, boolean

true margins under the subaccount's delayed-liquidation override, as order checks do. Rejected for a subaccount without one.

simulated_collateral_changes, SimulatedCollateralRequest[] nullable

Optional collateral deltas to simulate deposits / withdrawals / spot trades.

simulated_position_changes, SimulatedPositionRequest[] nullable

Optional position deltas to simulate perp / option trades.

subaccount_id, integer required

Response

Success

GetMarginResponse required

Result of public/get_margin / private/get_margin: net margin (MtM minus requirement; positive = healthy) before and after the simulated changes, as USD decimal strings.

is_valid_trade, boolean required

true when post-change initial margin passes, or the change is risk-reducing while maintenance margin stays healthy.

post_initial_margin, string required
post_maintenance_margin, string required
pre_initial_margin, string required
pre_maintenance_margin, string required
subaccount_id, integer required

0 for the public simulated-portfolio variant.

Changes

    • info

      the endpoint scheme security DeriveWallet AND DeriveTimestamp AND DeriveSignature was added to the API

    • info

      added the media type application/json for the response with the status