コード例 #1
0
ファイル: Quaotation.py プロジェクト: pablopenalba/Trader
 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"
コード例 #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 "
コード例 #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"
コード例 #4
0
ファイル: StockMarket.py プロジェクト: pablopenalba/Trader
 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"
コード例 #5
0
ファイル: Quaotation.py プロジェクト: pablopenalba/Trader
 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"
コード例 #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
コード例 #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]
コード例 #8
0
ファイル: StockMarket.py プロジェクト: pablopenalba/Trader
 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"
コード例 #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]
コード例 #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
コード例 #11
0
ファイル: StockMarket.py プロジェクト: pablopenalba/Trader
 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"
コード例 #12
0
ファイル: StockMarket.py プロジェクト: pablopenalba/Trader
 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]
コード例 #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
コード例 #14
0
ファイル: Quaotation.py プロジェクト: pablopenalba/Trader
 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"
コード例 #15
0
 def EliminarInversor(self):
     Obase = BaseDatos()
     query=" DELETE FROM inversor where id= %s"
     param=(self._Id)
     Obase.Ejecutar(query,param)
     self.__del__()