Design

Raw data:

  • Historical Funding Rates Data (df): this DataFrame reads the CSV file containing original historical funding rate data collected by Monitor. To verify the simulation, you can use the monitor by restricting the time range and resetting the weight and allocation.

  • Simulation Configurations Input (simulations_df): this dataframe reads the CSV file containing inputs for different period funding rate weights and allocation weights for each simulation. These are the configurations that will be used to calculate tokens' scores and the simulation's realized APRs. (Simulations_df is created by Weight_Generator)

    • funding rate weights inputs: are established for a token's average funding rates over different periods—3 days, 7 days, 30 days, previous funding rate, and next funding rate within a simulation. These funding rate weights are defined in the code as

      WEIGHTS = [W3, W7, W30, W_prev, W_next]
    • allocation weights inputs: are determined for the top-ranked tokens selected based on their scores within a simulation. These allocation weights are defined in the code as

      ALLOCATIONS = [A1, A2, A3]

Calculations:

symbol: token's name

symbolunique(df[symbol])symbol∈unique(df[′symbol′])

simulations_id: index id of the specific simulation in 'simulations_df'

simulation_idSimulationID[0,1,2,3,4,5,....,n],whereSimulationIDsimulations_dfsimulation\_id∈Simulation\:ID[0,1,2,3,4,5,...., n], \\ \:\:\:where \: Simulation\: ID \isin simulations\_df

model_num: is the number represents the ithith generation for a simulation that generates in the model

model_num[1,2,3,4,5,6,7,8,9,10]model\_num \isin [1,2,3,4,5,6,7,8,9,10]

group: is the subset of 'df' where the token symbol matches symbolsymbol, specifically the funding rate data.

i\bold{i}: calculates index based on the length of 'group', the model number, and other factors. This will identify the rates that will be collected, beginning with index ii.

i=(len(group)mod90)+(model_num1)×9i = (len(group)\:\:mod\:90)+(model\_num−1)×9

W\bold{W}: List of weight arrays, where each weight array corresponds to a particular simulation

weights=[Wj[simulations_id]forWjinWEIGHTS]weights=[W_j​[simulations\_id] \: for \: W_j​ \: in \:WEIGHTS]

A\bold{A}: List of allocation weight arrays, where each allocation weight array corresponds to a particular rank for a token that selected in a simulation

allocations=[Aj[simulations_id]forAjinALLOCATIONS]allocations =[A_j​[simulations\_id] \: for \: A_j​ \: in \:ALLOCATIONS]

  • Token Scores Function 'token_score_func(symbol, simulations_id, model_num)': is a function to calculate all tokens' scores of a simulation in a single generation.

    Average Periodic APR Calculations: Calculate average funding rates over different periods and scale them to get APRs. For the APR calculations for different periods

APR3=Mean(group[i:i+9])×3×360×100APR7=Mean(group[i:i+21])×3×360×100APR30=Mean(group[i:i+90])×3×360×100APRprev=Mean(group[i+1])×3×360×100APRnext=Mean(group[i])×3×360×100APR_3 = Mean(group[i: i+9])\times 3\times360\times100 \\ APR_7 = Mean(group[i: i+21])\times 3\times360\times100 \\ APR_{30} = Mean(group[i: i+90])\times 3\times360\times100 \\ APR_{prev} = Mean(group[i+1])\times 3\times360\times100 \\ APR_{next} = Mean(group[i])\times 3\times360\times100
token_score_func=km(APRk(symbol,i)×Wk[simulation_id]),forkm=[3,7,30,prev,next]token\_score\_func= \displaystyle\sum_{k}^m(APR_k(symbol, i) × W_k[simulation\_id]) , \\ for\: k \isin m =[3,\: 7, \:30, \:prev,\:next]
  • Simulation Realized APR Function 'simulation_apr_func(Tokens_names, simulations_id, model_num)': is a function to calculate a simulation's APR in a single generation, using the top 3 tokens chosen by Token Scores Function.

    Average 3 days funding rate: Calculate average funding rate over 3 days for the token identified by 'symbol' that selected by its score in a simulation.

avg_3Days_rate=Mean(groupsymbol[i9:i])avg\_3Days\_rate = Mean(group_{symbol}[i-9 : i])
simulation_apr_func=jr(avg_3Days_rate(symbolj)×Aj[simulation_id]),forjr=[1,2,3,...], rrepresentstoptokensrankinasimulation.simulation\_apr\_func= \displaystyle\sum_{j}^r(avg\_3Days\_rate(symbol_j) × A_j[simulation\_id]) , \newline for\: j \isin r =[1,\: 2, \:3, \:...], \newline \ 'r'\:represents\:top\:token's\:rank\:in\:a\:simulation.
  • Average Simulation APR in all generations ('simulation_avg_apr'): is a average realized APR of a single simulation in all 10 generations.

simulation_avg_apr=h=1Tsimulation_apr_funch÷Tforhmodel_num,whereT=model_num,simulation\_{avg}\_{apr} = \displaystyle\sum_{h=1}^{T}simulation\_apr\_func_{h} \:\:\div\:\: T \\ for\: h\isin model\_num , \\ where \: T = \sum{model\_num}, \\

Output data:

Final Output ('final_output'): final output is a merged table that includes 'funding_rate_weight_df' with an additional column called 'Realized APR' and 'Tokens'. 'Realized APR' contains the average APRs from each of the 9 simulations across a total of 10 generations."

The Most Optimized Configurations: is the recommend configuration selected from a simulation with the highest 'Realized APR' in the final output, which will be fed into the monitor.