| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- from datetime import datetime, timedelta
- import ast
- import os
- from Processing import *
- import importlib
- import sys
- module_name = "Global"
- if len(sys.argv) != 2:
- print("Usage: python Entrainement.py <Numerodu global>")
- sys.exit(1)
- try:
- parametre = int(sys.argv[1])
- module_name = "Global_" + str(parametre)
-
- except ValueError:
- print("Le paramètre doit être un entier.")
- sys.exit(1)
- try:
- imported_module = importlib.import_module(module_name)
- except ImportError:
- print(f"Aucun fichier {module_name}")
- sys.exit(1)
- liste_fichiers = []
- nbtour=0
- valeurs_ponderees =[]
- valeurs_date = []
- with open("dateE.txt", "r") as file: #le date.txt est modifier pour commencer 30 jours apres
- dates = file.readlines()
- for date in dates:
- date = date.strip()
- ponde,da = lirefichier(date)
- valeurs_ponderees.append(ponde)
- valeurs_date.append(da)
- print(len(valeurs_ponderees[0]))
- while(nbtour<1000):
- Portfeuille = imported_module.PortefeuilleInit
- pourc = 0
- Action = [0] * 40
-
- weight1 = generatePoids(imported_module.nbCouche1)
- weight2 = generatePoids(imported_module.nbCouche2)
- weight3 = generatePoids(imported_module.nbCouche3)
- weight4 = generatePoids(imported_module.nbCouche4)
- couche1 = generateCouche(imported_module.nbCouche1,imported_module.nbCouche0)
- couche2 = generateCouche(imported_module.nbCouche2,imported_module.nbCouche1)
- couche3 = generateCouche(imported_module.nbCouche3,imported_module.nbCouche2)
- couche4 = generateCouche(imported_module.nbCouche4,imported_module.nbCouche3)
-
-
- print("tour: ",nbtour)
- nbtour+=1
- for date in range(len(dates)):
- res = processing(valeurs_ponderees[date],weight1,weight2,weight3,weight4,couche1,couche2,couche3,couche4,imported_module.nbCouche1,imported_module.nbCouche2,imported_module.nbCouche3,imported_module.nbCouche4)
- for i in range(0,40):
- Action[i],Portfeuille=evaluation(res[i], valeurs_date[date][i], Action[i], Portfeuille,imported_module.resAchat1,imported_module.resAchat2,imported_module.resAchat3,imported_module.resVente,imported_module.Achat1,imported_module.Achat2,imported_module.Achat3,imported_module.Frais)
- pourc = verification(valeurs_date[date],Action,Portfeuille,imported_module.PortefeuilleInit)
- if pourc > 1.6:
- var=[]
- var.append(imported_module.nbCouche1)
- var.append(imported_module.nbCouche2)
- var.append(imported_module.nbCouche3)
- var.append(imported_module.resAchat1)
- var.append(imported_module.resAchat2)
- var.append(imported_module.resAchat3)
- var.append(imported_module.resVente)
- enregistre(nbtour,parametre,var,pourc,weight1,weight2,weight3,weight4,couche1,couche2,couche3,couche4)
|