Simplified analytical liquidation-price calculations for long and short positions.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
liquidation | 4 | Calculate liquidation price using simplified analytical model. | entry: value, leff: value, mmr_total: value, side: value |
Summary
Functions
Calculate liquidation price using simplified analytical model.
Types
Functions
@spec liquidation(Decimal.t(), Decimal.t(), Decimal.t(), :long | :short) :: decimal_result()
Calculate liquidation price using simplified analytical model.
Parameters
entry- Entry price (> 0) as a canonical decimal string; native Elixir callers may also pass Decimal or integer. (value)leff- Effective leverage (>= 0) as a canonical decimal string; native Elixir callers may also pass Decimal or integer. (value)mmr_total- Total minimum margin requirement (0-1) as a canonical decimal string; native Elixir callers may also pass Decimal or integer. (value)side- Position side (:long or :short) (value)
Returns
Estimated liquidation price, or {:error, :non_positive_entry | :negative_effective_leverage} (decimal)
# descripex:contract
%{
params: %{
entry: %{
description: "Entry price (> 0) as a canonical decimal string; native Elixir callers may also pass Decimal or integer.",
kind: :value,
schema: %{"type" => "string"}
},
side: %{
description: "Position side (:long or :short)",
kind: :value,
schema: %{"enum" => ["long", "short"], "type" => "string"}
},
leff: %{
description: "Effective leverage (>= 0) as a canonical decimal string; native Elixir callers may also pass Decimal or integer.",
kind: :value,
schema: %{"type" => "string"}
},
mmr_total: %{
description: "Total minimum margin requirement (0-1) as a canonical decimal string; native Elixir callers may also pass Decimal or integer.",
kind: :value,
schema: %{"type" => "string"}
}
},
returns: %{
type: :decimal,
description: "Estimated liquidation price, or {:error, :non_positive_entry | :negative_effective_leverage}"
}
}