Skip to content

Not able to calculate correct Liquidation price #201

@Abhimanyu121

Description

@Abhimanyu121

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 "

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions