HomeDocumentationAPI Reference
Log In
API Reference

Compare Ffi Margin

Method Name

public/compare_ffi_margin

Internal debugging RPC to compare python and ffi results.

For get_margin_with_portfolio_delta, the delta portfolio is computed from new_order.

Parameters

ffi_function  string required
FFI function to compare with Python
enum get_margin get_all_margin margin_result_from_order get_margin_with_portfolio_delta get_margin_with_open_orders _get_or_raise_ffi_open_orders_margin _get_or_raise_ffi_worst_orders_subset

secret  string required
...

subaccount_id  integer required
Subaccount ID

is_initial  boolean
Whether initial or maintenance margin. Only applies to get_margin()

new_order  object
New order to simulate (only applies to certain ffi functions)

new_order. amount  string required
Order amount in units of the base

new_order. direction  string required
Order direction
enum buy sell

new_order. instrument_name  string required
Instrument name

new_order. limit_price  string required
Limit price in quote currency.
This field is still required for market orders because it is a component of the signature. However, market orders will not leave a resting order in the book in case of a partial fill.

new_order. max_fee  string required
Max fee per unit of volume, denominated in units of the quote currency (usually USDC).Order will be rejected if the supplied max fee is below the estimated fee for this order.

new_order. nonce  integer required
Unique nonce defined as (UTC_timestamp in ms)(random_number_up_to_3_digits) (e.g. 1695836058725001, where 001 is the random number).Note, using a random number beyond 3 digits will cause JSON serialization to fail.

new_order. signature  string required
Ethereum signature of the order

new_order. signature_expiry_sec  integer required
Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.

new_order. signer  string required
Owner wallet address or registered session key that signed order

new_order. subaccount_id  integer required
Subaccount ID

new_order. is_atomic_signing  boolean
Used by vaults to determine whether the signature is an EIP-1271 signature.

new_order. label  string
Optional user-defined label for the order

new_order. mmp  boolean
Whether the order is tagged for market maker protections (default false)

new_order. order_type  string
Order type:
- limit: limit order (default)
- market: market order, note that limit_price is still required for market orders, but unfilled order portion will be marked as cancelled

enum limit market

new_order. reduce_only  boolean
If true, the order will not be able to increase position's size (default false). If the order amount exceeds available position size, the order will be filled up to the position size and the remainder will be cancelled. This flag is only supported for market orders or non-resting limit orders (IOC or FOK)

new_order. referral_code  string
Optional referral code for the order

new_order. reject_timestamp  integer
UTC timestamp in ms, if provided the matching engine will reject the order with an error if reject_timestamp < server_time. Note that the timestamp must be consistent with the server time: use public/get_time method to obtain current server time.

new_order. time_in_force  string
Time in force behaviour:
- gtc: good til cancelled (default)
- post_only: a limit order that will be rejected if it crosses any order in the book, i.e. acts as a taker order
- fok: fill or kill, will be rejected if it is not fully filled
- ioc: immediate or cancel, fill at best bid/ask (market) or at limit price (limit), the unfilled portion is cancelled
Note that the order will still expire on the signature_expiry_sec timestamp.

enum gtc post_only fok ioc

new_order. trigger_price  string
(Required for trigger orders) "index" or "mark" price to trigger order at

new_order. trigger_price_type  string
(Required for trigger orders) Trigger with "mark" price as "index" price type not supported yet.
enum mark index

new_order. trigger_type  string
(Required for trigger orders) "stoploss" or "takeprofit"
enum stoploss takeprofit

Response

id  string or integer required

result  object required

result. ffi_cache  object required
FFI cache - includes valuation timestamps, feeds, currencies, assets, instruments and mmps

result. ffi_result  object required
FFI result

result. new_order  object required
New order passed into ffi

result. open_orders  array of objects required
Open orders passed into ffi

result. portfolio  object required
User portfolio which is sent to ffi

result. python_result  object required
Python result

Example

{request_example_shell}
{request_example_javascript}
{request_example_python}

The above command returns JSON structured like this:

{response_example_json}