HomeDocumentationAPI Reference
Log In
API Reference

Get Margin

Method Name

public/get_margin

Calculates margin for a given portfolio and (optionally) a simulated state change.
Does not take into account open orders margin requirements.public/withdraw_debug

Parameters

margin_typestringrequired
PM (Portfolio Margin), PM2 (Portfolio Margin 2), orSM` (Standard Margin))
enum PMSMPM2
simulated_collateralsarray of objectsrequired
List of collaterals in a simulated portfolio
simulated_collaterals[].amountstringrequired
Collateral amount to simulate
simulated_collaterals[].asset_namestringrequired
Collateral ERC20 asset name (e.g. ETH, USDC, WSTETH)
simulated_positionsarray of objectsrequired
List of positions in a simulated portfolio
simulated_positions[].amountstringrequired
Position amount to simulate
simulated_positions[].instrument_namestringrequired
Instrument name
simulated_positions[].entry_pricestring
Only for perps. Entry price to use in the simulation. Mark price is used if not provided.
marketstring
Must be defined for Portfolio Margin
simulated_collateral_changesarray of objects
Optional, add collaterals to simulate deposits / withdrawals / spot trades
simulated_collateral_changes[].amountstringrequired
Collateral amount to simulate
simulated_collateral_changes[].asset_namestringrequired
Collateral ERC20 asset name (e.g. ETH, USDC, WSTETH)
simulated_position_changesarray of objects
Optional, add positions to simulate perp / option trades
simulated_position_changes[].amountstringrequired
Position amount to simulate
simulated_position_changes[].instrument_namestringrequired
Instrument name
simulated_position_changes[].entry_pricestring
Only for perps. Entry price to use in the simulation. Mark price is used if not provided.

Response

idstring or integerrequired
resultobjectrequired
result.is_valid_tradebooleanrequired
True if trade passes margin requirement
result.post_initial_marginstringrequired
Initial margin requirement post trade
result.post_maintenance_marginstringrequired
Maintenance margin requirement post trade
result.pre_initial_marginstringrequired
Initial margin requirement before trade
result.pre_maintenance_marginstringrequired
Maintenance margin requirement before trade
result.subaccount_idintegerrequired
Subaccount_id

Example

{request_example_shell}
{request_example_javascript}
{request_example_python}

The above command returns JSON structured like this:

{response_example_json}