Subaccounts

public/get_margin

Changed on

Calculates net initial and maintenance margin for a fully simulated portfolio under a chosen margin type (SM or PM2; market selects the currency a PM2 manager must cover), optionally with a further simulated state change layered on top. Values are net margin — mark-to-market value minus the requirement — so positive means healthy. Does not take open-order margin into account.

post/public/get_margin

Request

  • Base URL
    https://api.derive.xyz/v3
  • Auth
    none declared

Request body

PublicGetMarginRequest required
margin_type, string required

SM (standard margin) or PM2 (portfolio margin).

market, string nullable

Currency the manager must cover; required for PM2.

simulated_collateral_changes, SimulatedCollateralRequest[] nullable

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

simulated_collaterals, SimulatedCollateralRequest[] required

Collaterals of the simulated portfolio.

simulated_position_changes, SimulatedPositionRequest[] nullable

Optional position deltas to simulate perp / option trades.

simulated_positions, SimulatedPositionRequest[] required

Positions of the simulated portfolio.

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