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
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
Calculations:
symbol: token's name
simulations_id: index id of the specific simulation in 'simulations_df'
model_num: is the number represents the generation for a simulation that generates in the model
group: is the subset of 'df' where the token symbol matches , specifically the funding rate data.
: 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 .
: List of weight arrays, where each weight array corresponds to a particular simulation
: List of allocation weight arrays, where each allocation weight array corresponds to a particular rank for a token that selected in a simulation
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
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.
Average Simulation APR in all generations ('simulation_avg_apr'): is a average realized APR of a single simulation in all 10 generations.
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.