Exemplo n.º 1
0
 def Create(self, idAccion, nameAccion, price, date, open, max, min, close,
            volume):
     oBase = BaseDatos()
     query="insert into quaotation(idaccion,accion,fecha,apertura,cierre,maximo,minimo,volumen,precio) " \
           "values (%s,%s,%s,%s,%s,%s,%s,%s,%s)"
     param = (idAccion, nameAccion, date, open, max, min, close, volume,
              price)
     print query + str(param)
     try:
         oBase.Ejecutar(query, param)
         query1 = "SELECT max(id) FROM quaotation"
         try:
             id = oBase.ConsultaSoloValor(query1)
             self._id = int(id)
             self._idstockmarket = idAccion
             self._price = price
             self._date = date
             self._open = open
             self._max = max
             self._min = min
             self._close = close
             self._volume = volume
             self._idtransacion = 0
         except:
             print "Error in get Id quaotation"
     except:
         print "Error in Create quatation"
Exemplo n.º 2
0
 def Update(self, date, type, idAccion, quantity, price, com):
     oBase = BaseDatos()
     query = "UPDATE operacion(fecha,tipo,idAccion,precio,comision) values() where id= %s"
     param = (date, type, idAccion, quantity, price, self._Id)
     try:
         oBase.Ejecutar(query, param)
     except:
         print "Error in Update operation "
Exemplo n.º 3
0
 def Delete(self):
     oBase = BaseDatos()
     try:
         query = "DELETE FROM operacion where id= %s"
         param = (self._Id)
         oBase.Ejecutar(query, param)
     except:
         print "Error al crear la operacion"
Exemplo n.º 4
0
 def Delete(self):
     oBase = BaseDatos()
     query = "DELETE FROM StockMarket WHERE id= %s"
     param = (self._Id)
     try:
         oBase.Ejecutar(query, param)
     except:
         print "Error in Delete StockMarket"
Exemplo n.º 5
0
 def Delete(self):
     oBase = BaseDatos()
     query = "DELETE FROM quaotation WHERE id= %s"
     param = (self._id)
     try:
         oBase.Ejecutar(query, param)
     except:
         print "Error in Delete Quatation"
Exemplo n.º 6
0
 def Update(self,Nombre,Inversioninicial,InversionFinal):
     Obase=BaseDatos()
     query="UPDATE inversor SET nombre=%s,InvInic=%s,Total=%s where id=%s"
     param=(Nombre,Inversioninicial,InversionFinal,self._Id)
     Obase.Ejecutar(query,param)
     self.Nombre=Nombre
     self._InversionInicial=Inversioninicial
     self._Gananciatotal=InversionFinal
     self._PorcGanancia=InversionFinal/Inversioninicial
Exemplo n.º 7
0
 def ObtenerInversorPorId(self,nombre):
     OBase=BaseDatos();
     query="SELECT * from inversor where nombre=%s ";
     param=(nombre)
     registro=OBase.Select(query,param)
     self._Id= int(registro[0])
     self.Nombre = registro[1]
     self._InversionInicial = registro[2]
     self._Gananciatotal = registro[3]
     self._PorcGanancia = registro[4]
Exemplo n.º 8
0
 def Update(self, description, initials, price):
     oBase = BaseDatos()
     query = "UPDATE stockmarket set description=%s,initials=%s,lastquantation=%s where id=%s"
     param = (description, initials, price, self._Id)
     try:
         oBase.Ejecutar(query, param)
         self._description = description
         self._lastquantation = price
         self._initials = initials
     except:
         print "Error in Update StockMarket"
Exemplo n.º 9
0
 def Get(self):
     oBase = BaseDatos()
     query = "SELECT * FROM operacion where id= %s"
     param = (self._Id)
     try:
         registro = oBase.Select(query, param)
     except:
         print "Error in select of operation"
     self._IdAccion = registro[0]
     self._DateTime = registro[1]
     self._TypeOperation = registro[2]
     self._IdAccion = registro[3]
     self._Quantity = registro[6]
     self._Price = registro[4]
     self._Commission = registro[5]
Exemplo n.º 10
0
  def Crear(self,Nombre,InversionIni):
      Obase = BaseDatos()
      query="insert into inversor(nombre,InvInic,Total,PorcGanac) values(%s, %s , %s , 0)"
      query1="select max(id) as Id from inversor"
      param=(Nombre,InversionIni,InversionIni)
      try:
         Obase.Ejecutar(query,param)
         id=Obase.ConsultaSoloValor(query1)

      except:
          print "Error en inversor"
      self._Id=int(id)
      self.Nombre=Nombre
      self._InversionInicial=InversionIni
      self._Gananciatotal=InversionIni
      self._PorcGanancia=0
Exemplo n.º 11
0
 def Create(self, description, initials, price):
     oBase = BaseDatos()
     query = "insert into StockMarket(description,initials,lastquantation) values (%s,%s,%s)"
     param = (description, initials, price)
     try:
         oBase.Ejecutar(query, param)
         query1 = "SELECT max(id) FROM StockMarket"
         try:
             id = oBase.ConsultaSoloValor(query1)
             self._Id = int(id)
             self._description = description
             self._initials = initials
             self._lastquantation = price
         except:
             print "Error in get Id StockMarket"
     except:
         print "Error in Create StockMarket"
Exemplo n.º 12
0
 def Get(self, nombre):
     oBase = BaseDatos()
     query = "SELECT * FROM StockMarket"
     registro = oBase.FUNCION
     self._Id = int(registro[0])
     self._description = registro[1]
     self._initials = registro[3]
     self._lastquantation = registro[2]
Exemplo n.º 13
0
    def Create(self, stockmarketname, type, quantity):
        oBase = BaseDatos()
        self._DateTime = time.strftime("%c")
        self._TypeOperation = type
        try:
            query = "SELECT id FROM accion WHERE nombre= %s"
            param = (stockmarketname)
            self._IdAccion = oBase.ConsultaSoloValor(query, param)
        except:
            print "Error al crear la operacion"
        try:
            query1 = "SELECT max(id) FROM accion"
            id = oBase.ConsultaSoloValor(query1)
            self._Id = id
        except:
            print "Error trying to get id"

        self._Quantity = quantity
        self._price = 100  #conectarse con mercado
Exemplo n.º 14
0
 def Update(self, idAccion, nameAccion, price, date, open, max, min, close,
            volume):
     oBase = BaseDatos()
     query="insert into quaotation(idaccion,accion,fecha,apertura,cierre,maximo,minimo,volumen,precio) " \
           "values (%s,%s,%s,%s,%s,%s,%s,%s,%s)"
     param = (idAccion, nameAccion, date, open, max, min, close, volume,
              price)
     try:
         oBase.Ejecutar(query, param)
         self._idstockmarket = idAccion
         self._price = price
         self._date = date
         self._open = open
         self._max = max
         self._min = min
         self._close = close
         self._volume = volume
         self._idtransacion = 0
     except:
         print "Error in Update quatation"
Exemplo n.º 15
0
 def EliminarInversor(self):
     Obase = BaseDatos()
     query=" DELETE FROM inversor where id= %s"
     param=(self._Id)
     Obase.Ejecutar(query,param)
     self.__del__()