Fetch positions
positions() hits the core API and returns enriched data: liquidation price, accrued rollover, and unrealized funding are already computed. Pass trader= to read any address.
Position fields (human units)
data.position(pair_index, index) looks up a single position.
Price triggers
price_triggers unifies every TP/SL attached to a position:
- Global (on-chain) TP/SL —
is_globalisTrue. These are the levels set at open / viatrade.update_tp_sl(). Theirentity_idis deterministic (global-tp-{trader}-{pair}-{index}/global-sl-...) and is not accepted by the partial TP/SL CRUD; the SDK rejects it client-side too. - Partial (off-chain) triggers —
is_globalisFalse. Signed partial TP/SL orders whoseentity_idworks withtrade.update_partial_tp_sl()andtrade.cancel_partial_tp_sl(). Note that updating a partial order mints a newentity_id.
Live PnL
Combine a position with its pair snapshot and the live price for a UI-parity net PnL breakdown:Balance and raw reads
positions_onchain() when you need the unprocessed on-chain state; positions() is the right call for everything else.