Action.py 2.4 KB

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