# -*- coding: utf-8 -*-

from functionMain import *
from RDN import *
from Action import *
import time

Portefeuille = initPortefeuille
FraisBancaire = 0

print ("debut init  gererate")
ID = GenerateFile()

RDN=RDN(ID)

F_resume=open("resume.txt",'a')
F_cac=open("cac.txt","r")
F_jour = open("jour.txt","r")

F_resume.write(str(ID)+":")
F_resume.close()
Actions = []
print ("fin init gererate")

for i in F_cac:
	Actions.append(Action(i))

print ("debut init RDN")
for i in range (NBJour):
	jou=F_jour.readline()
	jou=jou[:-1]
	MAJQuotidient(jou,Actions)
	for minu in minute:
		RDN.MiseAJourC1(MAJ1min(minu,Actions))
print ("fin init RDN")

print ("debut RDN")
for jou in F_jour:
	print (jou)
	jou = jou.strip('\n')
	MAJQuotidient(jou,Actions)
	for minu in minute:
		
		# ~ t1=time.time()
		RDN.MiseAJourC1(MAJ1min(minu,Actions))
		# ~ print(time.time()-t1)
		
		# ~ t1=time.time()
		res = RDN.tour()
		# ~ print(time.time()-t1)
		
		i = 0
		for act in Actions:
			if(act.name!="Cac40"):
				act.MAJchaleur(res[i])
				act.Surveillance(Portefeuille,FraisBancaire)
				i+=1
		print(Portefeuille)

F_resume.write(str(CalculPourcentage(Portefeuille,Actions,FraisBancaire)))
F_resume.close()
