| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- from valeurs import *
- from scanValeur import *
- from timer import *
- from achatVente import *
- import time
- from threading import Thread, RLock
- f = open('cac.txt','r')
- valeur=[]
- for i in f:
- t = i.split(';')
- url = t[1]
- nom = t[0]
- valeur.append(Valeur(nom,url))
- f.close()
- tempsdepart =time.time()
- class AchatVente(Thread):
-
- def __init__(self):
- Thread.__init__(self)
-
-
- def run(self):
- i=0
- gain =0.0
- while 1:
- with verrou:
- if valeur[i].getAAnule() == 1:
- valeur[i].Anulation()
- if valeur[i].getAVendre() == 1:
- gain=gain+valeur[i].Vente()
- print ("Gain Total: "+ str(gain)+ " en " + str(time.time()-tempsdepart) + "s")
- if valeur[i].getMise()==0:
- valeur[i].Achat(25)
- time.sleep(00.001)
- i=i+1
- if i>39:
- i=0
- class Scan(Thread):
- def __init__(self):
- Thread.__init__(self)
-
- def run(self):
- i=0
- while 1:
- with verrou:
- tmp=valeur[i].getNewTaux()- valeur[i].getTaux()
-
- if tmp > 0.02:
- valeur[i].MiseEnVente()
- time.sleep(0.4)
- i=i+1
- if i>39:
- i=0
-
- class Timer(Thread):
- def __init__(self):
- Thread.__init__(self)
-
- def run(self):
- i=0
- while 1:
- with verrou:
- if valeur[i].tempsRestant() < 30:
- if valeur[i].getNewTaux() > 0:
- valeur[i].MiseEnVente()
- else:
- valeur[i].MiseEnAnnulation()
- time.sleep(0.4)
- i=i+1
- if i>39:
- i=0
- verrou = RLock()
- threadAchat = AchatVente()
- threadTimer = Timer()
- threadScan = Scan()
- threadAchat.start()
- threadTimer.start()
- threadScan.start()
- threadAchat.join()
- threadTimer.join()
- threadScan.join()
- #~ print(str(valeur[1].getTaux()))
- #~ print(str(valeur[1].getNewTaux()))
|