Funding Calculation
 Hướng dẫn CoinM Vĩnh cửu
Perpetual swaps have no expiry or delivery, and require a "Funding Mechanism" to anchor the contract price to the spot price.
Perpetual Swap is a period every 8 hours and is settled at the end of each period. That is, 00: 008: 00 is a period and the settlement time is 800; 8: 0016: 00 is a period and the settlement time is 16:00; 16: 0000:00 (+1 day) is a period. The settlement time is 00:00. The above time is GMT + 8 time.
Only users who hold positions at the funding timestamps will receive or pay funding; if the position has been closed before settlement, users won’t receive or pay funding.
At the funding timestamps, whether a user should receive or pay funding is determined by the funding rate of current period and the position situation of the user. If the funding rate is positive, then long positions will pay and short positions will receive the funding, and vice versa if the rate is negative.
Funding is payment exchanged between users. HTX perpetual swaps do not charge any funding.
Funding Calculation
The funding that the user will receive or pay is calculated as follows:
Funding = Net Position * Contract Face Value / Settlement Price * Funding Rate；
Among them, the net position = the quantity of long positions (conts) – the quantity of short positions (conts).
When the funding rate is greater than 0, users with a net position greater than 0 need to pay funds, and users with a net position less than 0 will receive funds; when the funding rate is less than 0, users with a net position greater than 0 will receive funds, and users with a net position less than 0 have to pay funds.
Funding Rate Calculation
Funding rate aims to ensure that the transaction price of Perpetual Swap closely follows the underlying reference price. The Funding rate for each period is calculated from the data of the previous period and has been determined at the beginning of the current period. It will not be changed during the period and will be applied in funding calculation at the end of the current period. Meanwhile, in this period, the estimated funding rate for the next period is calculated every minute, and the last calculated estimated funding rate will be used as the rate for the next period.
For example, the funding rate for the period 8: 0016: 00 is calculated from the data of the previous period 00: 008: 00. The rate has been determined at 8:00 and used for settlement at 16:00. And, during the period 8: 0016: 00, a estimated funding rate will be calculated every minute for period 16: 0000:00 (+1 day), and the last calculated estimated funding rate will be used as its Estimated Funding Rate Of Next Period.
Funding rate is composed of two parts: comprehensive interest rate and premium.
 comprehensive interest rate component：
Each contract traded on HTX is comprised of two currencies: the underlying currency and the denominated currency. For example: for BTC (perpetual) contract, the underlying currency is BTC, and the denominated currency is USD.
Underlying currency interest rate: The daily lending rate of the underlying currency on the market. Just like the underlying currency of the BTC perpetual contract is BTC, the lending rate of the underlying currency is the daily lending rate of BTC.
Denominated currency interest rate: The daily lending rate of denomination currency in the market. For example, the denomination currency of the BTC perpetual contract is USD, and the denomination currency interest rate is the daily lending rate of USD.
Comprehensive interest rate = (denominated currency interest rate – underlying currency interest rate) / (24 hours / settlement cycle)
Currently, the denominated currency interest rate of all perpetual contracts is 0.06% and underlying currency interest rate is 0.03%, and the settlement cycle is 8 hours (3 times per day). Therefore, the current comprehensive interest rate of all perpetual swap is 0.01%.
 Premium component：
Perpetual Swap may have a premium or discount relative to its fair price. We use the premium index to measure the premium level of the contract and add it to the calculation of the funding rate. The higher the level of premium, the greater the funding rate, and the more motivation the shorts have to go short; the lower the level of the premium, the smaller the funding rate, and the more motivation the longs have to go long. By raising or lowering the funding rate, the contract price will be returned to a relatively reasonable level.
a. Funding rate basis rate
Funding rate basis rate reflects the basis difference generated by the capital expense in the current period.
Funding rate basis rate = current funding rate * (current time interval from the current settlement period / settlement cycle)
If the current BTC perpetual swap funding rate is 0.01%, the current time is 12:00, and the current settlement time is 16:00, that is, 4 hours before the settlement, and the settlement cycle is 8 hours (settle every 8 hours), then the current funding rate basis rate = 0.01% * ( 4 / 8 ) = 0.005%.
b. Fair price
The fair price is a relatively reasonable reference price for the perpetual swap calculated based on the current spot index price and the current funding rate basis rate.
Fair price = index price * (1 + funding rate basis rate)
For example, if the current BTC index price is 10,000 USD and the BTC perpetual swap funding rate basis rate is 0.005%, then the current BTC perpetual swap fair price = 10000 * ( 1 + 0.005% ) = 10000.5 USD.
c. Depthweighted bid / ask prices
The depthweighted bid price refers to the average bid pending order price of N contracts from the first bid of the current order, based on the current pending order situation.
The depthweighted ask price refers to the average ask pending order price of N contracts from the first ask of the current order, based on the current pending order situation.
Among them, the value range of N is 80 for BTC perpetual swap and 800 for contracts of other currencies.
d. Premium index
The premium index reflects the current premium situation caused by the combination of funding rate basis rate and the deviation of the depth buy/sell price from the fair price.
Premium index = [Max (0, depthweighted bid price – fair price)Max (0, fair price – depthweighted ask price)] / index price + funding rate basis rate；
Thus it can be seen from the formula that:
a).When the depthweighted ask price ≥ fair price ≥ depthweighted bid price, the premium index = funding rate basis rate;
b).When the depthweighted ask price > depthweighted bid price > fair price, the premium index = (depthweighted bid price – fair price) / index price + funding rate basis rate;
c).When fair price > depthweighted ask price > depthweighted bid price, the premium index = (depthweighted ask price – fair price) / index price + funding rate basis rate;
The premium index is calculated every minute.
e. Average premium index
The current average premium index is the arithmetic mean of all current premium indices in the 8hours.
For example, in the period 8:0016:00, the average premium index at 8:30 is the arithmetic mean of all premium indices at 8: 008: 30; the average premium index at 15:00 is 8: 0015: 00 Arithmetic mean of all premium indices.
Average premium index is calculated every minute.
Estimated Funding Rate Of Next Period, which is determined by the comprehensive interest rate and average premium index, is as follows:
Estimated Funding Rate Of Next Period = clamp (average premium index + clamp (comprehensive interest rate – average premium index, premium deviating from upper limit, premium deviating from lower limit), upper limit of funding rate, lower limit of funding rate)
Among them, clamp is an intervallimited function. When the target value exceeds the upper and lower limits, only the boundary value is taken. For example, clamp (a, max, min), the result is max when a > max; the result is a when a < min.
The comprehensive interest rate – average premium index is limited by the premium deviation from the upper limit and the premium deviation from the lower limit, which is in between; the final forecasting the funding rate of next period is limited by the upper limit of the capital rate and the lower limit of the fund rate, which is in between. The corresponding upper and lower limits of each contract are as follows：
 As a example for BTC：
Swaps 
Strict price limit 
No basis price limit 
Basis price limit 

The highest bid quotation 
The lowest asked quotation 
The highest bid quotation 
The lowest asked quotation 
The highest bid quotation 
The lowest asked quotation 

BTC 
6.0% 
6.0% 
4.0% 
4.0% 
2.0% 
2.0% 
[searching Limit of more trading pairs]
[The above data and indicator contents may be adjusted in real time according to market conditions, and the adjustments will be made without further notice.]
Other Circumstances of Funding
Funding are charged at settlement. For users with low margin rates, they will be charged less (or not). Only the maximum payable funding of the user will be charged, and the excess will not be charged. The maximum payable funding is calculated as follows:
Maximum payable funding = max (0, static equity  adjustment factor * abs (net position) * contract face value / settlement price/leverage multiple)