Get PrepPositions for an User Account
Fetch PrepPosition details for an userAccount of a particular Authority
A perpetual position in a perpetual market refers to a trader's open position in a perpetual futures contract. This position can be either long (betting that the price of the underlying asset will increase) or short (betting that the price will decrease). We can query PerpPositions data for a particular marketIndex via SuperIndexer using the following steps:
We query the user account details for an
authority
(user wallet)The user account details will contain perpPositions for the user. We need to filter positions where either the
baseAssetAmount
orquoteAssetAmount
or thelpShares
is not equal to zero(these are all perpPosition fields). Also, theopenOrders
field should not equal to zero.Once done, finally we filter the final list of positions while matching
marketIndex
field.
You can directly copy paste this code on replit and see it in action.
Fetch perpPosition for a User Account by authority and market index
Last updated
Was this helpful?