Skip to main content
avantis_trader_sdk.compute reimplements the Avantis app’s math as pure functions: no I/O, human units in and out. Numbers match what the UI displays.

PnL

Liquidation

Pre-trade / what-if estimate (margin edits, increases). For open positions, Position.liquidation_price from the core API is authoritative.

Fees & liquidity

TP/SL conversion

Convert between trigger prices and gain/loss percentages, as the UI does:
pnl_order_min_sl(leverage) gives the minimum SL percent for Upside positions.

Pre-trade validation

Run the UI’s full pre-trade rulebook locally before submitting:
The API performs the same validation on submit unless you pass skip_validation=True.