python data science script that looks at the last X days to optimize variables

Job ID: 37489857

Budget: €8 – €30 EUR

I have a trading strategy python script.
I would like to make the following modifications to test a few things for the following optimizations:

For example, every day, I want the script to search in the last X days (30, 60, 365... this must be an editable variable) the number of winning trades for certain stochastic and moving average values. It optimizes the values and takes the trade that presents itself with those values.
Then the next day he always tests the last X days and takes the best values for the next trade.

This is a rolling optimization because the market evolves.

Here is an example of code to drag:

def optimize():
stats = []
k_period = [4, 9, 1] # Période RSI
d_period = [19, 22, 1] # Valeur de RSI
valSTO = [47, 60, 1] # Valeur de RSI
xEMA = [176, 180, 1] # X EMA

# Values change over time. This must be automatic.
# The values must be tested over the last x days until the day before, and must be memorized to take the
# future trade.
# 5 21 53 179 15 - 2010 > 2015
# 7 19 57 178 24 - 2015 > 2023
# 7 19 57 179 44 - 2010 > 2023

for valeur_k_period in range(k_period[0], k_period[1], k_period[2]):
for valeur_d_period in range(d_period[0], d_period[1], d_period[2]):
for valeur_STO in range(valSTO[0], valSTO[1], valSTO[2]):
for valeurXEMA in range(xEMA[0], xEMA[1], xEMA[2]):
print('.', end="")
# ICI vous pouvez tester la vitesse d'exécution d'un même script, optimisé ou non.
# MyStrat(df, stats, valeurRSI, valeurXRSI, valeurXEMA, initial_balance=10000, fees=0.00)
MyStratOPTIMIZE(df, stats, valeur_k_period, valeur_d_period, valeur_STO, valeurXEMA, initial_balance=10000, fees=0.001)
return stats
Related categories: Python Data Processing Statistics Data Mining