Price

Learn how to retrieve the Index Price, Market Price, and Fill Price for trades using the available APIs.

Index Price

The Index Price represents the asset price as reported directly by the Pyth oracle feed. You can retrieve it from the price field in the response of either the Markets API or the Individual Market API.

Example Response:

{
  "marketId": "100",
  "symbol": "ETH",
  "skew": "-816032563610058179",
  "price": 2751.21510528,
  "currentOI": "171613599036410749027",
  ...
}

Market Price

The Mark Price is a dynamic price adjusted based on open interest skew. You can calculate it using the following formula:

const indexMultiplier = BigNumber(1e18)
  .plus(
    BigNumber(marketData.skew.toString())
      .dividedBy(marketData.skewScale as string)
      .multipliedBy(1e18)
  );

const markPrice = BigNumber(marketData.price)
  .multipliedBy(indexMultiplier.toString())
  .dividedBy(1e18)
  .toFixed(0);

Here, marketData is from the response from the Markets API or the Individual Market API.

Fill price

The Fill Price is the most accurate estimate of the execution price for a trade. It accounts for slippage, skew, and other adjustments, giving you a realistic expectation of what the trade will fill at for a given size.

You can fetch this value using the Post-Trade Details API:

{
  "totalFees": "113173321557870967",
  "fillPrice": "2735468306793171306346",
  ...
}

Note: When submitting a trade order, it’s recommended to pass a slightly more aggressive price than the one returned by the Post-Trade Details API. This is because the market can shift between the time you fetch the details and the moment the trade is executed. You can find an example implementation here.

Last updated

Was this helpful?