Action.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from define import *
  2. import os.path
  3. import ast
  4. class Action():
  5. def __init__(self,ID):
  6. self.add = ID.split(";")[1]
  7. self.name = ID.split(";")[0]
  8. self.path = "/home/remy/Projet/Valeurs/"
  9. self.Journee = {}
  10. self.valeur = 0
  11. #nombre d'action
  12. self.possedent = 0
  13. #Total de l'argent dépenser pour l'achat des actions
  14. self.valeurAchat = 0
  15. #NBNeurone par action
  16. self.Tab = [0]*NBNeurone
  17. self.chaleur = 0
  18. def MajQuotidient(self,date):
  19. name=self.path+self.name+"-"+date
  20. F_Journee = open(name,"r")
  21. self.Journee = ast.literal_eval(F_Journee.readline())
  22. Quoti = ast.literal_eval(F_Journee.readline())
  23. self.Tab[0]=float(Quoti["1semaine"][0].strip("%"))
  24. self.Tab[1]=float(Quoti["1mois"][0].strip("%"))
  25. self.Tab[2]=float(Quoti["3mois"][0].strip("%"))
  26. self.Tab[3]=float(Quoti["6mois"][0].strip("%"))
  27. self.Tab[4]=float(Quoti["1an"][0].strip("%"))
  28. _3ans=Quoti["3ans"][0].strip("%")
  29. if (_3ans != '-'):
  30. self.Tab[5]=float(_3ans)
  31. _5ans=Quoti["5ans"][0].strip("%")
  32. if (_5ans != '-'):
  33. self.Tab[6]=float(_5ans)
  34. _10ans=Quoti["10ans"][0].strip("%")
  35. if (_10ans != '-'):
  36. self.Tab[7]=float(_10ans)
  37. #Plus tard ajout des NM ...
  38. #self.Tab[0]=Quoti["MM20"]
  39. #self.Tab[0]=Quoti["MM50"]
  40. #self.Tab[0]=Quoti["MM100"]
  41. #self.Tab[0]=Quoti["RSI14"]
  42. def Maj1min(self,heure):
  43. val=self.Journee.get(heure)
  44. if (val != None):
  45. self.Tab.insert(NBInfoSupplementaire,val)
  46. self.Tab=self.Tab[0:-1]
  47. else : # SI on est égale a none on ajout la derniere valeurs L'enregistrement des valeurs a commencé plus tard
  48. val=self.Tab[NBInfoSupplementaire+1]
  49. self.Tab.insert(NBInfoSupplementaire,val)
  50. self.Tab=self.Tab[0:-1]
  51. def getTable(self):
  52. return self.Tab
  53. def getValue(self):
  54. return self.valeur * self.possedent
  55. def MAJchaleur(self,pour):
  56. self.chaleur = pour
  57. def Surveillance(self,Portefeuille,Frais):
  58. if (self.chaleur>0.5):
  59. print ("Achat " + self.name )
  60. self.possedent+=ValeursAchat/self.valeur
  61. Portefeuille-=ValeursAchat
  62. Frais+=1
  63. if (self.chaleur<0.5):
  64. print ("Vente " + self.name )
  65. Portefeuille+=self.possedent*self.valeur
  66. self.possedent=0
  67. Frais+=1