-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to calculate correct Liquidation price #201
Comments
Any updates for this issue? |
Did you find the right answer for this issue? |
Would also be interested! |
Hey @Kampfk3ks7 |
I used the exact description provided in the official documentation to calculate it. This seems to work for a single position but not for multiple positions. For multiple position the liq. price is always 50% closer than it should be... |
Yeah.. same to me. Very strange... or all we are thinking something wrong..?
|
Hey @sniper365 and @Kampfk3ks7 we solved it quite some time back so I don't remember exact solution but can you try this code snippet
|
Currently I have two positions like above I tried as following your way So for BTC liq.price, in summary ,
If so, I tried, but sometimes the difference with my real liq.price on dydx (around few hundreds gap) When you did before, all are working well? |
Hi @Abhimanyu121 and @Kampfk3ks7 Have you had a chance to check my calculation by following @Abhimanyu121 's fomula? |
I am trying to get the liquidation price of an order, I have implemented the same formula given in the docs
Close Price (Short) = P × (1 + (M × V / W))
Close Price (Long) = P × (1 − (M × V / W))
But the prices I am getting are different not even in 1-5% delta
https://docs.dydx.exchange/?json#liquidations
Here P( Oracle Price), V( Equity), M ( Maintenance margin fraction) the 3 i am getting from the getMarket and getAccount API's itself.
for W: i am using the below formula (https://docs.dydx.exchange/?json#portfolio-margining)
Total Maintenance Margin Requirement = Σ abs(Si × Pi × Mi)
Where
S is the size of the position (positive if long, negative if short)
P is the oracle price for the market
M is the maintenance margin fraction for the market
I am taking this data from getPositions API where I am only using the positions which are open i.e "Position.status == OPEN "
The text was updated successfully, but these errors were encountered: