If you want to double-check whether the Mark Price has, in fact, reached your Liquidation Price, you can follow the guide below.
What information do I need to get started and where can I find them?
Here are the details you'll need before you can jump into calculating the Mark Price:
- Time of Liquidation
- Funding rate at the time of Liquidation
- Time until funding at the time of Liquidation
- Funding Interval
- Index Price at the time of Liquidation
- Funding Basis & Mark Price formula
1. Time of liquidation
This is shown on the Trade History page and in the Liquidation email that's been sent to your inbox:
You'll need to convert the time of liquidation to a JSON format so, when you use the API Explorer later, you can enter a startTime and endTime interval that includes the time you were liquidated.
For example, the highlighted date above, "Aug 23, 2021, 10:17:48 AM UTC" is "2021-08-23T10:17:48.000Z" in JSON format.
2. Funding rate at the time of liquidation
You can get the historical Funding rate from the /Funding endpoint or the Funding History page.
You'll need to take the first funding Rate that occurs after your liquidation as that will be the funding Rate at the time you were liquidated. In this examples case, 12:00:00 is the first funding timestamp after 10:17 UTC.
Getting funding rate through /Funding endpoint
To get the funding rate from the /Funding endpoint, you'll need to enter the contract for symbol and your time of liquidation in JSON format for startTime. The rest of the values can remain untouched.
Once you enter these values and click Try it out!, the Response Body will return the first funding rate after your start Time. In this case, the first value is 0.0001:
[
{
"timestamp": "2021-08-23T12:00:00.000Z",
"symbol": "XBTUSD",
"fundingInterval": "2000-01-01T08:00:00.000Z",
"fundingRate": 0.0001,
"fundingRateDaily": 0.00030000000000000003
},
fundingRate from the RestAPI must be multiplied by 100, to convert the value into a percentage. So, our funding rate is 0.0001 * 100 = 0.01%.
Getting funding Rate through Funding History page
You can filter the Funding History page by Symbol and Time to get the Funding Rate you're looking for quicker. In this case, the search would be:
{"symbol":"XBTUSD","timestamp":"2021-08-23T12:00:00.000Z"}
3. Time until funding at the time of liquidation
Funding occurs every 8 hours at 04:00 UTC, 12:00 UTC and 20:00 UTC. You'll need to calculate how many hours are left from your time of liquidation until the next funding.
In this case, liquidation happened at 10:17 UTC and the next funding is at 12:00 UTC, which means 1 hour 42 minutes were left. You'll need to express this in just hours though.
Convert minutes into hours:
= minutes/60
= 42/60
= 0.7
We can then add that to 1 hour, which leaves us with 1.7 for time until funding.
4. Funding Interval
Funding Interval for perpetual contracts are 8 hours
5. Index Price at the time of liquidation
Since the price on the Trading Chart is only at 1-minute intervals, you'll have to use our /instrument/compositeIndex endpoint as that includes the 5-second snapshot price movements of the index. You can find what Index the contract it uses on their Contract Specification page.
BMI is the Index price which is calculated as a weighted average of the Last Price for each constituent exchange. You'll be looking for the lastPrice for this reference.
What information you'll need to fill out on the API Explorer:
- You'll have to enter the Index in question under symbol. XBTUSD uses the .BXBT Index.
- For startTime, it will need to be time before your liquidation at a 5-second interval. In the example case, the time of liquidation was 10:17:48 so the startTime was set to 10:17:45. Specifically, 2021-08-23T10:17:45.000Z
Once you hit, Try it out!, you'll have to take the lastPrice value for "reference": "BMI" from the Response Body.
In our case, the last price is 50489.935.
[
{
"timestamp": "2021-08-23T10:17:45.000Z",
"symbol": ".BXBT",
"indexSymbol": ".BXBT",
"reference": "BMI",
"sourcePrice": null,
"conversionIndex": "",
"conversionIndexPrice": null,
"relation": "",
"lastPrice": 50489.935,
"weight": null,
"indexMultiplier": null,
"logged": "2021-08-23T10:17:45.061Z"
},
What is the Funding Basis & Mark Price formula?
Once you've gathered all the information mentioned above, you can start calculating the Funding Basis and then the Mark Price.
Funding Basis Formula
Funding Basis = Funding Rate * (Time Until Funding / Funding Interval)
For our example, the calculation is the one below:
Funding Basis = Funding Rate * (Time Until Funding / Funding Interval)
Funding Basis = 0.0100% * (1.7/8)
Funding Basis = 0.00002125
Mark Price Formula
Mark Price = Index Price * (1 + Funding Basis)
For our example:
Mark Price = Index Price * (1 + Funding Basis)
Mark Price = 50489.935 (1 + 0.00002125)
Mark Price = 50491.0
Now that you've manually calculated the Mark Price, you can compare it against what it says in your Liquidation Email. If the values don't match, or if you have any further questions, you can reach out to our Support team.