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_type string required
PM (Portfolio Margin) or SM (Standard Margin)
enum PM SM
simulated_positions array of objects required
List of positions in a simulated portfolio
simulated_positions[].amount string required
Position amount to simulate
simulated_positions[].instrument_name string required
Instrument name
simulated_positions[].entry_price string
Only for perps. Entry price to use in the simulation. Mark price is used if not provided.
simulated_position_changes array of objects
Optional, add positions to simulate a trade
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}