verif.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from datetime import datetime, timedelta
  2. import ast
  3. import os
  4. from Processing import *
  5. from Global import *
  6. def parse_float_array(string):
  7. # Séparation du nom et de la liste de flottants
  8. parts = string.split(':')
  9. nom = parts[0].strip()
  10. float_array = ast.literal_eval(parts[1].strip())
  11. return float_array
  12. if(1):
  13. print("================NEW==============================="+ "\n")
  14. Atest = os.listdir("res")
  15. # Parcours des fichiers
  16. for entest in Atest:
  17. Portfeuille = PortefeuilleInit
  18. pourc = 0
  19. Action = [0] * 40
  20. print(entest)
  21. with open("res/"+entest, "r") as file:
  22. weight1 = parse_float_array(file.readline())
  23. weight2 = parse_float_array(file.readline())
  24. weight3 = parse_float_array(file.readline())
  25. weight4 = parse_float_array(file.readline())
  26. couche1 = parse_float_array(file.readline())
  27. couche2 = parse_float_array(file.readline())
  28. couche3 = parse_float_array(file.readline())
  29. couche4 = parse_float_array(file.readline())
  30. with open("dateV.txt", "r") as file:
  31. dates = file.readlines()
  32. for date in dates:
  33. date = date.strip()
  34. # ~ print(date)
  35. valeurs_ponderees, valeurs_date = lirefichier(date)
  36. res = processing(valeurs_ponderees,weight1,weight2,weight3,weight4,couche1,couche2,couche3,couche4)
  37. for i in range(0,40):
  38. Action[i],Portfeuille=evaluation(res[i], valeurs_date[i], Action[i], Portfeuille)
  39. pourc = verification(valeurs_date,Action,Portfeuille)
  40. print (pourc)
  41. print(" ")