from recup import recupfunc
import urllib
import time

Valeur= 0

url=[]#
res=[]#
val=[]#

f = open('cac.txt','r')

for i in f:
	url.append(i)
	res.append(recupfunc(i))
	val.append(25.0)

annulation=0
validation=0

f.close()
tim=time.time()
i = 0
while 1:
	#vente
	temp=recupfunc(url[i])
	print("differenece"+str(temp[2]-res[i][2]))
	if res[i][2]<temp[2]:
		#on vend
		print ("vend")
		validation=validation+1
		Valeur=Valeur+val[i]*1+(temp[2]-res[i][2])/100
	else:
		#on annulle
		annulation=annulation+1
		print("annule")
		Valeur=Valeur+val[i]
		
	#achat
	res[i]=temp
	val[i]=25
	Valeur=Valeur-25
	i=i+1
	if i>39:
		i=0
	time.sleep(15)
	
	#affichage stat
	temps = time.time()-tim
	print ("temps : " + str(temps))
	print ("gagne : " + str(Valeur))
	print ("moyen session : " + str((Valeur/temps)*3600*8))
	print ("annulation : " + str(annulation) + " Validation : " + str(validation))
	
	



