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"
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 "
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"
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"
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"
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
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]
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"
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]
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
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"
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]
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
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"
def EliminarInversor(self): Obase = BaseDatos() query=" DELETE FROM inversor where id= %s" param=(self._Id) Obase.Ejecutar(query,param) self.__del__()