Overview
Funding is a transfer of funds between holders of long and short positions with an amount and direction. These peer-to-peer payments act to incentivize the market to value the perpetual swap contract at a price closer to the underlying spot price.
- If the perpetual contract is trading higher than the spot price, longs make funding payments to the shorts. This makes the perpetual contract less attractive to longs and more attractive to shorts, pushing the price back down to the Index price.
- If the perpetual contract trades lower than the index, the shorts pay longs, creating the inverse effect.
Other trading platforms implement funding as a lump sum transfer at discrete time intervals. In theory, a rational market should price-in discrete funding events properly, but in practice funding events are disruptive to trading.
Qume Funding Mechanism
Qume's matching engine implements "continuous funding": the funding paid/received is based on the funding rate over the period that the position (of a given side and size) is held with a high degree of granularity.
- Our system processes every open position every second and credits or debits its portfolio balance based on the current funding rate scaled by the position size and the period since the last processing (1 second / 8 hour funding interval).
- At high update frequencies, this is not actually feasible with a potentially large number of open positions. Instead, we perform per-position funding calculations only when the position is changed. To do this, a single value "epoch unit funding" is calculated which tracks the amount of funding earned by a hypothetical size 1 short position which has been open since some arbitrary epoch.
- To calculate the funding of any other position, we store an "entry funding" value to which the size delta * current epoch unit funding is added whenever the position is increased. Then the current unrealized funding of a position is [entry funding - size * current epoch_unit_funding] (the order of values in the subtraction are the opposite of what you might expect because of the fact that an increase in "epoch unit funding" means longs pay shorts).
- Entry funding acts to offset the part of "epoch unit funding" from before the position (or portions of the position opened at different times) was opened. If "epoch unit funding" is the same when a position is closed as it was when the position was opened, funding is 0.
- Note that it may not be as obvious, but funding is still perfectly zero-sum in this implementation.
Instantaneous Funding Rate Calculation
The Funding Rate is presented as an interest rate. To calculate the Funding Rate at a given time, first calculate the Premium Rate:
Premium Rate = (Mark Price - Index Price) / Index Price
- If Premium Rate is between -0.05% and 0.05%, inclusive, then the Funding Rate is reduced to zero.
- If Premium Rate is lower than -0.05%, then the Funding Rate is equal to PremiumRate + 0.05%.
- If the Premium rate is higher than 0.05%, then the Funding Rate is equal to the PremiumRate - 0.05%
Based on the Premium Rate, we calculate the current Funding Rate:
- Funding Rate = max(0.05%, Premium Rate) + min(−0.05%, Premium Rate)
Comments
0 comments
Please sign in to leave a comment.