API Reference

Get Margin

Method Name

private/get_margin

Calculates margin for a given subaccount and (optionally) a simulated state change. Does not take into account
open orders margin requirements.
Required minimum session key permission level is read_only

Parameters

subaccount_id integer required
Subaccount_id
simulated_collateral_changes array of objects
Optional, add collaterals to simulate deposits / withdrawals / spot trades
simulated_collateral_changes[].amount string required
Collateral amount to simulate
simulated_collateral_changes[].asset_name string required
Collateral ERC20 asset name (e.g. ETH, USDC, WSTETH)
simulated_position_changes array of objects
Optional, add positions to simulate perp / option trades
simulated_position_changes[].amount string required
Position amount to simulate
simulated_position_changes[].instrument_name string required
Instrument name
simulated_position_changes[].entry_price string
Only for perps. Entry price to use in the simulation. Mark price is used if not provided.

Response

id string or integer required
result object required
result.is_valid_trade boolean required
True if trade passes margin requirement
result.post_initial_margin string required
Initial margin requirement post trade
result.post_maintenance_margin string required
Maintenance margin requirement post trade
result.pre_initial_margin string required
Initial margin requirement before trade
result.pre_maintenance_margin string required
Maintenance margin requirement before trade
result.subaccount_id integer required
Subaccount_id

Example

{request_example_shell}
{request_example_javascript}
{request_example_python}

The above command returns JSON structured like this:

{response_example_json}