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
- Index Price at the time of Liquidation
- Impact Mid Price at time of Liquidation
- Time until contract expiry
- Fair Basis %, Fair Value, and Mark Price formula
1. Time of Liquidation
You can find the time of Liquidation on the Trade History page or 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, Mon, 26 Apr 2021 09:45:50 GMT, is 2021-04-26T09:45:50.000Z
2. Index Price at the time of liquidation
You can use the /Trade endpoint to get the Index Price at the time of your liquidation.
What information you'll need to fill out on the API Explorer:
- You'll need to enter the Index the contract is using under the symbol parameter. If you're unsure what Index the contract is priced on, you can find it on its' Contract Specification page. For our example, XBTM21 uses the .BXBT Index.
-
You'll also need to enter the startTime in JSON format, which will need to be time before your liquidation.
Once you hit, Try it out!, you'll have to take the price value for your Index. In our case, the Index Price is 52684.82:
[
{
"timestamp": "2021-04-26T09:45:00.000Z",
"symbol": ".BXBT",
"side": "Buy",
"size": 0,
"price": 52684.82,
"tickDirection": "PlusTick",
"trdMatchID": "00000000-0000-0000-0000-000000000000",
"grossValue": null,
"homeNotional": null,
"foreignNotional": null,
"trdType": ""
}
]
3. Impact Mid Price at the time of Liquidation
You can get the Bid and Ask from /quote endpoint and calculate the Impact Mid Price from there.
You'll have to enter the contract you were trading as the symbol (In this case XBTM21) and startTime in JSON format just before your liquidation.
{
"timestamp": "2021-04-26T09:45:49.919Z",
"symbol": "XBTM21",
"bidSize": 255703,
"bidPrice": 54511,
"askPrice": 54511.5,
"askSize": 60
}
]
Once you have the Bid and Ask Price, you can average those to get Impact Mid Price using the formula below:
Impact Mid Price formula
Impact Mid Price = (bidPrice + askPrice)/2
Impact Mid Price = (54511+54511.5)/2
Impact Mid Price = 54511.25
Please note this example assumes the quantity on the top of orderbook exceeds the 'Impact Margin Notional' for the instrument, therefore the simple 'Mid Price' calculated here is equal to the 'Impact Mid Price'. If market making conditions require, you may need to sum up multiple levels of the order book to reproduce the Impact Bid/Impact Ask - the process for doing this is beyond the scope of this document, please contact support@bitmex.com if you require more information on this topic.
4. Time until contract expiry
You can find the contract's expiration on its' Contract Specification page. For our example, XBTM21 expires on 25 June 2021 and our date is 26 Apr 2021, so the time until expiry is 60 days.
What is the % Fair Basis, Fair Value, and Fair/Mark Price formula?
Once you've gathered all the information mentioned above, you can start calculating the Funding Basis, Fair Value and then the Mark Price.
% Fair Basis formula
% Fair Basis = (Impact Mid Price / Index Price - 1) / (Time To Expiry / 365)
For our example, the calculation is the following:
% Fair Basis = (Impact Mid Price / Index Price - 1) / (Time To Expiry / 365)
% Fair Basis = (54511.25/52684.82 -1)/(60/365)
% Fair Basis = 0.210891534
Mark Price Formula
Fair Value = Index Price * % Fair Basis * (Time to Expiry / 365)
For our example:
Fair Value = Index Price * % Fair Basis * (Time to Expiry / 365)
Fair Value = 52684.82 * 0.210891534 * (60/365)
Fair Value = 1826.43000137
Fair/Mark Price Formula
Fair/Mark Price = Index Price + Fair Value
For our example:
Fair/Mark Price = Index Price + Fair Value
Fair/Mark Price = 52684.82 + 1826.43000137
Fair/Mark Price = 54511.25
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.