Portfolio-margin calculations over a caller-supplied position list.
This module nets offsetting long and short quantities before computing maintenance margin, liquidation price, and margin usage. It performs no I/O and assumes all positions in a call belong to the same risk unit.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
margin_usage | 1 | Calculate used and available margin under portfolio-margin netting. | account: value |
portfolio_liquidation_price | 1 | Estimate liquidation price for the netted portfolio book. | account: value |
combined_maintenance_margin | 1 | Calculate maintenance margin after netting offsetting portfolio positions. | account: value |
Summary
Types
Portfolio-margin account input.
Portfolio-margin position input.
Position side used for net exposure.
Margin usage under the portfolio model.
Functions
Return net quantity x mark price x max MMR across the portfolio.
Return used maintenance margin, available equity, and usage percentage.
Return the price where equity equals net maintenance margin, or nil for a flat book.
Types
@type account() :: %{ :positions => [position()], optional(:equity) => DeltaCalc.Decimal.input() }
Portfolio-margin account input.
@type position() :: %{ side: side(), quantity: DeltaCalc.Decimal.input(), mark_price: DeltaCalc.Decimal.input(), mmr: DeltaCalc.Decimal.input() }
Portfolio-margin position input.
@type side() :: :long | :short
Position side used for net exposure.
Margin usage under the portfolio model.
Functions
Return net quantity x mark price x max MMR across the portfolio.
Return used maintenance margin, available equity, and usage percentage.
Return the price where equity equals net maintenance margin, or nil for a flat book.