Mark Price determination
The mark price is used as the price at which the PnL of positions is calculated, and so feeds into the Margin Account Equity checks, which in turn determine whether a trade can be completed by a margin account, or if it can be liquidated.
The mark price is determined by the average price of all trades originating from all trading protocols that have submitted trades to the clearing system.
Mark price is calculated as an exponentially weighted moving average (EVWMA), weighted by volume, exponential decay calculated over time constant period \(\tau\). Mark Price \(MP\) at time \(t\) is defined as:
\[ \textbf{MP}_t = S_{t} / V_{t} \]
Where:
- \(S_{t}\) is the exponentially weighted sum of \({price \cdot quantity}\) traded at that time
- \(V_{t}\) is the exponentially weighted total of \(quantity\) traded at that time
To calculate for the mark price after a trade update at timestamp \(i\):
\[ S_{i} = S_{i-1}\cdot e^{-\Delta t / \tau} + p_i \cdot q_i \]
\[ V_{i} = V_{i-1}\cdot e^{-\Delta t/ \tau} + q_i \]
\[ \textbf{MP}_i = S_{i} / V_{i} \]
Where:
- \(p_i\) is the price of the new trade
- \(q_i\) is the quantity of the new trade
- \(\tau\) is the characteristic time constant and is defined as equal to \(markPriceInterval / 2\), where \(markPriceInterval\) is measured in seconds and set as a protocol parameter
- \(\Delta t\) is the time interval over which exponential decay occurs; it is the time since trade \(i\) and the preceding trade, \({i-1}\)
- \(e^{-\Delta t/ \tau}\) is the exponential decay factor for older trades.