from PyQt5.QtWidgets import QApplication
from xulpymoney.libxulpymoneyfunctions import qmessagebox
from xulpymoney.libxulpymoneytypes import eTickerPosition, eLeverageType, eProductType, eOperationType
import sys

class Update:
    """DB update system
    Cuando vaya a crear una nueva modificación pondre otro if con menor que current date para uqe se ejecute solo una vez al final, tendra que 
    poner al final self.me.set_database_version(current date)
    
    To check if this class works fine, you must use a subversion 
        Subversion      DBVersion
        1702                None
    
    El sistema update sql ya tiene globals y  mete la versión de la base de datos del desarrollador, no obstante,
    El desarrollador deberá meter por código todos los cambios, ha ser preferible usando objetos.7
    
    AFTER EXECUTING I MUST RUN SQL UPDATE SCRIPT TO UPDATE FUTURE INSTALLATIONS
    
    OJO EN LOS REEMPLAZOS MASIVOS PORQUE UN ACTIVE DE PRODUCTS LUEGO PASA A LLAMARSE AUTOUPDATE PERO DEBERA MANTENERSSE EN SU MOMENTO TEMPORAL
    """
    def __init__(self, mem):
        self.mem=mem
        self.dbversion=self.get_database_version()
        self.lastcodeupdate=201905162140
        self.need_update()

    def get_database_version(self):
        """REturns None or an Int"""
        cur=self.mem.con.cursor()
        cur.execute("select value from globals where id_globals=1;")
        if cur.rowcount==0:
            cur.close()
            return None
        resultado=cur.fetchone()['value']
        cur.close()
        self.dbversion=int(resultado)
        return self.dbversion

    def set_database_version(self, valor):
        """Tiene el commit"""
        print("**** Updating database from {} to {}".format(self.dbversion, valor))
        cur=self.mem.con.cursor()
        if self.dbversion==None:
            cur.execute("insert into globals (id_globals,global,value) values (%s,%s,%s);", (1,"Version", valor ))
        else:
            cur.execute("update globals set global=%s, value=%s where id_globals=1;", ("Version", valor ))
        cur.close()        
        self.dbversion=valor
        self.mem.con.commit()
        
    def need_update(self):
        """Returns a tuple (boolean, problem) if update must be done
        None, returns a problem
        True needs to update
        False doesn't need to update"""
        if self.dbversion>self.lastcodeupdate:
            qmessagebox(QApplication.translate("Core","Xulpymoney app is older than database. Please update it."))
            sys.exit(3)
            return

        if self.dbversion==self.lastcodeupdate:
            return 

        if self.dbversion<self.lastcodeupdate:
            if self.mem.con.is_superuser():
                self.run()
            else:
                qmessagebox(QApplication.translate("Core","Xulpymoney database needs to be updated. Please login with a superuser role."))
                sys.exit(2)

    def run(self): 
        if self.dbversion==None:
            self.set_database_version(200912310000)
        if self.dbversion<201001010000:
            self.set_database_version(201001010000)
        if self.dbversion<201412280840:
            cur=self.mem.con.cursor()
            cur.execute("update products set isin=%s where id=%s;", ("LU0252634307", 81693))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201412280840)
        if self.dbversion<201412280940:
            cur=self.mem.con.cursor()
            cur.execute("alter table inversiones rename in_activa to active;")
            cur.execute("alter table cuentas rename cu_activa to active;")
            cur.execute("alter table tarjetas rename tj_activa to active;")
            cur.execute("alter table entidadesbancarias rename eb_activa to active;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201412280940)
        if self.dbversion<201412290741:
            cur=self.mem.con.cursor()
            cur.execute("alter table products drop column system;")
            cur.execute("alter table products drop column deletable;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201412290741)
        if self.dbversion<201412290753:
            cur=self.mem.con.cursor()
            cur.execute("alter table inversiones rename mystocksid to products_id;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201412290753)
        if self.dbversion<201501102221:
            cur=self.mem.con.cursor()
            cur.execute("update products set type=%s, ticker=%s, obsolete=%s where id=%s;", (1, "CIN.MC", True, 75202))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501102221)
        if self.dbversion<201501110635:
            cur=self.mem.con.cursor()
            cur.execute("update products set isin=%s where id=%s;", ("LU0171289225", 75042))
            cur.execute("update products set isin=%s, obsolete=%s where id=%s;", ("ES0147623039",True,  75258))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501110635)
        if self.dbversion<201501130928:
            cur=self.mem.con.cursor()
            cur.execute("update products set priorityhistorical=%s where type=2 and char_length(isin)>0", ([8, ], ))#Todos los fondos con isin deben estar en morning star
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501130928)      
        if self.dbversion<201501131001:
            cur=self.mem.con.cursor()
            cur.execute("update products set active=true where priorityhistorical[1]=8 and active=false;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501131001)     
        if self.dbversion<201501140855:
            cur=self.mem.con.cursor()
            cur.execute("alter table products drop column active;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501140855)            
        if self.dbversion<201501141359:
            cur=self.mem.con.cursor()
            cur.execute("update products set ticker=Null where ticker='None';")
            cur.execute("update products set ticker=Null where ticker='';")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501141359)    
        if self.dbversion<201501141403:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76962))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76515))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501141403)    
        if self.dbversion<201501142025:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75538))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78069))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77255))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75392))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75792))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75506))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76215))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75205))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75259))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76806))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78050))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 74966))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501142025)    
        if self.dbversion<201501151022:
            cur=self.mem.con.cursor()
            cur.execute("update products set priority=%s where id=79329", ([1, ], ))#Todos los fondos con isin deben estar en morning star
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501151022)   
        if self.dbversion<201501151153:
            cur=self.mem.con.cursor()
            cur.execute("update products set pci='p' where name ilike '%put%' and type=5;")#Warrants put to put
            cur.execute("update products set apalancado=1 where type=5;")#Leverage to variable for all warrants
            cur.execute("update products set obsolete=true where  name like '%/11 %' and type=5;")#Old warrants to obsolete
            cur.execute("update products set obsolete=true where  name like '%/12 %' and type=5;")#Old warrants to obsolete
            cur.execute("update products set obsolete=true where  name like '%/13 %' and type=5;")#Old warrants to obsolete
            cur.execute("update products set obsolete=true where  name like '%/14 %' and type=5;")#Old warrants to obsolete
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501151153)   
        if self.dbversion<201501160640:
            cur=self.mem.con.cursor()
            cur.execute("""insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, tpc, pci,  apalancado, id_bolsas, ticker, priority, priorityhistorical , comentario,  obsolete) values  (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
                (81701, 'Abengoa B',  'ES0105200002', 'EUR', 1, '|IBEX|MERCADOCONTINUO|', None, None, None, None, 100, 'c',0, 1, 'ABG-P.MC',[1, ],[3, ], None, False))
            cur.execute("update products set agrupations=%s where id=%s", ( '|IBEX|MERCADOCONTINUO|',81111 ))
            cur.execute("update products set agrupations=%s where id=%s", ( '|MERCADOCONTINUO|',81115 ))
            cur.execute("update products set agrupations=%s where id=%s", ( '|MERCADOCONTINUO|',79397 ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501160640)      
        if self.dbversion<201501160812:
            cur=self.mem.con.cursor()
            cur.execute("""insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, tpc, pci,  apalancado, id_bolsas, ticker, priority, priorityhistorical , comentario,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
                (81702, 'Airbus group',  'NL0000235190', 'EUR', 1, '|CAC|EUROSTOXX|', None, None, None, None, 100, 'c',0, 3, 'AIR.PA',[1, ],[3, ], None, False))
            cur.execute("update products set agrupations=%s where id=%s", ( None,81085 ))
            cur.execute("update products set agrupations=%s where id=%s", ( None,75143 ))
            cur.execute("update products set agrupations=%s where id=%s", ( '|CAC|',78915 ))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 79008))
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('MUV2.DE',[1, ],[3, ],  80407))
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('PHIA.AS',[1, ],[3, ],  77096))
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('SAN.PA',[1, ],[3, ],  79028))
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('SAP.DE',[1, ],[3, ],  80867))
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('SU.PA',[1, ],[3, ],  77242))
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('SIE.DE',[1, ],[3, ],  80920))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501160812)     
        if self.dbversion<201501160838:
            cur=self.mem.con.cursor()
            cur.execute("update products set ticker=%s, agrupations=%s, priority=%s, priorityhistorical=%s where id=%s;", ('DPW.DE','|DAX|DEUTSCHEBOERSE|EUROSTOXX|', [1, ],[3, ],  79588))
            cur.execute("update products set agrupations=%s where id=%s", ( None,79008 ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501160838)      
        if self.dbversion<201501170838:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=true where type=2 and id in (select id from products where type=2 except select id from products where type=2 and id in (select distinct (id) from quotes));")#Pone obsoletos fondos que no tengan cotizaciones despues de varios morningstar
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501170838)      
        if self.dbversion<201501220838:
            cur=self.mem.con.cursor()
            cur.execute("update products set priority=NULL where  2=any(priority);")#Removing priority 2
            cur.execute("update products set priority=%s where  agrupations ilike '%%mercadocontinuo%%';", ([9, ], ))#Asign 9 to mercadocontinuo products
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78175))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 74821))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77112))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77343))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78063))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78328))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78862))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78869))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 79088))
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('CUN.MC',[3, ],  81428))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('EGPW.MC',[3, ],  78881))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('MTF.MC',[3, ],  79221))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('PSG.MC',[3, ],  79356))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('NAT.MC',[3, ], 75607))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('PRM.MC',[3, ],75609 ))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('COL.MC',[3, ],77072))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('UBS.MC',[3, ],78252))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('CPL.MC',[3, ],78446))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('ALB.MC',[3, ],78461))#priority ya es 9
            cur.execute("update products set ticker=%s, priorityhistorical=%s where id=%s;", ('ENC.MC',[3, ],79141))#priority ya es 9
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501220838)       
        if self.dbversion<201501222338:
            cur=self.mem.con.cursor()
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('MT.AS',[1, ],[3, ],  78915))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201501222338)     
        if self.dbversion<201502111124:
            cur=self.mem.con.cursor()
            cur.execute("update products set name=%s where id=%s;", ('Bono Estado Español 4,20  31012037', 81680))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, tpc, pci,  apalancado, id_bolsas, ticker, priority, priorityhistorical , comentario,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81703, 'Masmovil Ibercom S.A.', 'ES0184696013', 'EUR', 1, '|MERCADOCONTINUO|', 'http://www.ibercom.com', None, None, None, 100, 'c', 0, 1, 'MAS.MC', [9, ],[3, ], None, False ))
            cur.execute("update products set name=%s where id=%s;", ('Telefónica S.A.', 75130))
            cur.execute("update products set name=%s where id=%s;", ('Telefónica S.A.', 78241))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201502111124)     
        if self.dbversion<201502120609:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, tpc, pci,  apalancado, id_bolsas, ticker, priority, priorityhistorical , comentario,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81704, 'AENA S.A.', 'ES0105046009 ', 'EUR', 1, '|MERCADOCONTINUO|', 'http://www.aena.es', None, None, None, 100, 'c', 0, 1, 'AENA.MC', [9, ],[3, ], None, False ))
            cur.execute("update products set name=%s, isin=%s, ticker=%s, priority=%s, priorityhistorical=%s where id=%s;",
                    ('3D Systems Corporation','US88554D2053','DDD',[1, ],[3, ],  78596))            
            cur.execute("update products set isin=%s, ticker=%s, priority=%s, priorityhistorical=%s where id=%s;",
                    ('CH0012221716','ABB',[1, ],[3, ],  78545))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78907))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201502120609)     
        if self.dbversion<201502120631:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=%s where id=%s;", (False, 78907))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 79807))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201502120631)     
        if self.dbversion<201502131010:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, tpc, pci,  apalancado, id_bolsas, ticker, priority, priorityhistorical , comentario,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81705, 'Logista Holdings', 'ES0105027009 ', 'EUR', 1, '|MERCADOCONTINUO|', 'http://www.logista.es', None, None, None, 100, 'c', 0, 1, 'LOG.MC', [9, ],[3, ], None, False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201502131010)     
        if self.dbversion<201503081017:
            cur=self.mem.con.cursor()
            cur.execute("CREATE TABLE annualtargets ( year integer NOT NULL,  percentage numeric(6,2),  CONSTRAINT annualtargets_pk PRIMARY KEY (year)) WITH (  OIDS=FALSE);")
            cur.execute("ALTER TABLE annualtargets OWNER TO postgres;")
            cur.execute("CREATE INDEX annualtargets_index_year ON annualtargets USING btree (year);")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201503081017)     
            
        if self.dbversion<201503110632: #This corrects what was done in 201501170838 and has not fill all system prices
            cur=self.mem.con.cursor()
            cur.execute("""update products set obsolete=false where id in (81443, 75234, 80854, 80853, 80866, 75341, 81288, 75497, 77335, 77440, 78545, 78172, 79287, 78399, 78381, 78401, 78457, 79015, 79416, 79382, 79387, 75379, 75393, 75847, 77291, 77438, 80494, 79398, 80557, 80844, 80845, 81158, 79854, 78306, 75488, 78209, 79203, 79210, 81359, 81362, 81446, 81444, 81424, 81445, 77096, 74793, 81703, 74816, 74808, 79206, 79372, 79490, 79526, 79629, 79751, 74809, 78748, 74845, 74849, 74851, 74888, 74900, 74823, 74832, 74787, 78575, 81427, 75130, 81358, 79761, 79762, 79963, 79971, 79991, 80007, 80060, 80074, 80075, 80155, 74789, 81361, 81363, 74756, 79468, 79484, 79489, 79509, 79510, 79516, 79517, 79553, 74801, 81278, 75446, 79890, 79891, 79920, 79923, 79925, 80205, 81423, 80215, 80218, 80440, 80722, 80725, 74933, 81085, 75762, 74804, 81704, 75043, 80322, 80323, 75212, 75282, 80856, 80858, 80864, 79487, 80252, 79513, 78596, 81176, 81184, 81272, 81274, 79040, 78907, 79043, 79404, 79409, 75598, 79692, 75646, 79901, 79902, 80946, 80947, 75884, 75914, 75348, 81611, 75586, 75527, 75543, 75544, 75726, 75727, 75728, 75731, 76131, 76138, 76139, 76093, 76095, 76096, 76097, 76267, 76263, 76243, 76372, 76500, 76477, 76685, 76698, 76699, 76700, 76702, 76812, 76814, 76894, 76895, 76896, 76898, 77012, 77015, 77016, 77018, 77022, 77121, 77238, 77246, 77224, 77231, 77349, 77352, 77353, 77502, 77503, 77481, 79132, 77520, 77522, 77638, 77639, 77728, 77998, 78040, 78024, 78025, 78112, 78214, 78280, 78283, 78290, 78295, 78370, 78373, 78495, 78531, 78606, 78607, 78703, 78712, 78777, 78779, 78871, 78874, 78882, 78883, 79102, 79104, 79276, 79294, 79303, 79368, 79453, 79460, 79462, 79438, 78219, 79217, 78885, 79970, 80173, 80326, 80339, 80353, 80481, 80678, 80680, 80919, 80921, 80922, 80923, 80924, 75065, 81151, 81152, 81253, 81153, 81266, 81269, 81598, 81380, 79996, 80182, 81563, 74765, 79961, 81375, 81578, 81505, 76430, 81705, 81695, 81686, 80876, 74788, 76851, 78222, 77210, 75066, 74753, 74759, 77370, 77453, 77555, 77707, 77855, 78098, 78117, 78159, 78160, 78221, 78834, 79078, 80728, 80734, 80735, 80744, 80746, 80748, 80750, 74950, 74934, 74943, 75055, 75061, 75070, 75085, 79350, 79352, 75098, 74998, 75038, 75090, 75093, 75095, 75039, 75071, 75073, 75704, 75110, 81604, 81676, 81659, 81661, 81662, 81663, 81664, 81668, 81669, 81670, 81673, 81674, 81675, 81660, 81671, 81665, 80485, 81667, 81672, 80110, 75122, 75160, 75156, 75158, 75159, 75163, 75169, 75188, 75154, 75157, 75182, 75086, 75087, 75097, 75102, 80321, 80324, 80327, 75199, 77553, 78447, 79377, 79962, 79703, 79177, 74847, 74968, 79019, 76650, 80156, 80206, 80298, 80403, 80503, 80639, 80716, 80727, 81213, 81214, 81241, 81244, 81263, 74792, 74806, 74807, 74820, 74825, 74769, 74790, 78968, 78999, 74852, 79000, 79011, 79175, 79199, 79219, 79224, 79225, 79236, 79237, 79253, 79258, 79264, 79265, 79268, 79296, 79309, 79334, 79348, 79353, 79375, 79376, 79390, 79401, 79402, 79405, 79407, 79415, 79437, 79442, 79455, 79456, 79457, 74881, 79458, 79459, 79464, 79466, 79467, 79554, 79578, 79579, 79580, 79585, 79590, 79591, 79593, 74870, 74983, 79598, 79622, 79623, 79628, 79632, 79633, 79635, 79636, 79697, 79712, 79716, 79720, 79721, 79736, 79737, 79795, 79835, 74891, 74887, 79837, 79838, 79842, 79845, 79846, 79859, 79888, 79934, 79936, 79939, 79941, 79944, 79945, 79948, 79954, 79960, 80005, 80006, 80015, 80016, 80019, 80021, 80022, 80025, 80026, 80051, 80053, 80055, 80056, 80057, 80058, 80059, 80094, 80099, 80102, 74890, 74904, 80106, 80112, 80113, 80116, 80127, 80128, 80168, 80178, 80187, 80191, 80192, 80194, 80196, 80219, 80228, 80231, 80248, 80261, 80263, 80272, 80276, 80279, 80285, 80300, 80305, 80316, 80342, 80354, 80355, 80357, 80368, 74896, 74899, 74928, 74906, 74907, 80388, 80396, 80402, 80405, 80411, 80413, 80418, 80419, 80420, 80429, 80434, 80438, 80449, 80454, 80477, 80483, 80489, 80508, 80524, 80526, 80532, 80535, 80539, 80544, 80565, 80566, 80591, 80600, 80603, 80604, 74924, 74930, 74931, 74932, 74989, 74910, 74922, 74923, 74926, 80607, 80619, 80630, 80631, 80634, 80636, 80641, 80644, 80650, 80651, 80652, 80695, 80696, 80718, 80721, 74944, 74935, 74939, 74954, 74957, 74962, 74963, 80751, 80753, 80800, 80861, 81245, 81249, 81256, 81257, 81277, 81291, 81296, 75018, 74955, 74975, 78952, 78958, 75002, 74999, 75014, 75016, 81600, 81625, 81628, 81630, 81640, 81642, 81643, 81644, 81646, 81657, 81658, 74996, 79007, 79009, 79010, 79012, 79014, 79021, 79023, 79024, 74990, 75032, 75164, 79189, 75078, 75069, 75059, 75074, 74992, 74994, 75194, 75196, 75198, 75200, 75201, 75225, 75226, 75213, 80328, 80329, 80330, 80331, 80517, 80625, 80626, 80627, 75233, 79186, 75235, 75240, 75248, 75249, 75250, 75237, 75239, 75251, 80628, 80629, 80833, 80834, 75241, 75257, 75309, 75298, 75303, 75306, 75307, 75548, 75308, 75328, 75330, 75332, 75299, 75313, 80868, 80869, 80870, 80871, 80872, 81169, 75340, 75345, 75378, 75337, 75356, 79187, 75380, 81170, 81172, 81173, 81174, 81175, 81185, 81186, 81187, 81188, 81189, 81190, 81191, 75391, 75400, 75403, 75404, 81192, 81193, 81194, 81195, 81196, 81197, 81198, 81199, 81217, 81218, 75436, 75428, 75429, 75438, 75440, 75441, 75444, 75447, 75448, 75457, 75455, 81219, 81220, 81270, 81271, 81279, 81280, 81281, 81282, 81283, 81285, 81287, 81289, 81290, 81292, 81293, 81295, 81300, 81302, 81303, 75430, 75487, 75490, 75491, 75505, 75510, 75489, 75513, 74833, 74848, 74874, 74927, 78947, 78948, 78949, 78950, 78951, 78963, 79003, 79006, 79027, 79029, 79038, 79044, 79045, 79050, 79184, 79185, 79190, 79239, 79240, 79241, 79246, 79247, 79248, 79259, 79261, 79263, 79269, 79270, 75483, 75536, 75528, 75552, 75524, 75545, 75537, 75541, 79271, 79274, 79284, 79285, 79311, 79314, 79315, 79318, 79321, 79322, 79324, 79325, 79327, 79328, 79338, 79339, 79340, 79341, 79342, 79344, 79345, 79346, 79347, 79357, 79403, 79417, 79421, 79422, 79429, 79430, 79432, 79433, 79434, 75519, 75520, 75578, 75583, 75556, 75579, 75555, 79497, 79498, 79499, 79501, 79503, 79504, 79505, 79506, 79507, 79515, 79518, 79519, 79539, 79540, 79587, 79589, 79594, 79595, 79596, 79597, 79600, 79602, 79603, 79605, 79606, 79616, 79617, 79619, 79620, 79621, 79624, 79626, 79627, 79630, 79631, 79673, 79674, 79675, 79676, 79681, 79684, 79685, 79686, 79688, 75600, 75601, 75608, 75616, 75634, 75635, 75637, 75596, 75611, 75614, 79693, 79696, 79701, 79702, 79704, 79705, 79706, 79707, 79710, 79717, 79722, 79724, 79725, 79726, 79727, 79728, 75123, 75124, 75129, 75141, 79729, 79730, 79734, 79738, 79777, 79778, 79779, 79780, 79782, 79785, 79792, 79793, 79794, 79798, 79801, 79802, 79803, 75644, 75647, 75643, 75661, 75669, 75673, 75675, 75653, 75657, 75674, 79806, 79808, 79810, 79811, 79812, 79814, 79815, 79816, 79830, 79831, 79832, 79833, 79836, 79839, 79843, 79847, 79848, 79851, 79895, 79896, 79897, 79898, 79899, 75155, 75167, 75175, 75176, 75177, 75178, 75180, 75181, 75193, 79900, 75641, 75652, 75683, 75702, 75686, 75690, 75705, 75730, 75738, 75712, 79919, 79921, 79922, 79927, 79928, 79929, 79931, 79932, 79933, 79937, 79940, 79943, 79947, 80020, 80035, 80040, 80041, 80042, 80045, 80046, 80047, 75197, 75203, 75211, 75214, 75217, 75221, 75224, 75229, 75744, 75756, 75780, 75777, 75749, 75765, 75232, 80050, 80052, 80143, 80144, 80145, 80146, 80147, 80148, 80149, 80150, 80152, 80153, 80154, 80157, 80160, 80341, 80343, 80550, 80883, 80885, 80886, 80887, 80888, 80889, 80890, 80891, 75242, 75244, 75252, 80892, 80893, 75739, 75746, 75787, 75782, 75796, 75798, 75811, 75785, 75791, 75826, 80894, 80895, 80896, 80897, 80898, 80899, 80900, 80901, 80902, 80903, 80904, 80905, 80906, 80907, 80908, 80909, 80910, 80911, 80912, 80913, 80914, 80915, 80916, 80936, 80937, 80938, 80939, 80940, 80941, 80942, 80943, 80944, 80945, 75827, 75828, 75848, 75849, 75851, 80948, 80949, 80950, 80951, 80952, 80953, 80954, 75277, 75279, 75788, 75253, 75260, 75266, 75271, 75272, 75274, 75276, 80955, 80956, 80957, 80958, 80959, 80960, 80961, 80962, 80963, 80964, 80965, 80966, 80967, 80968, 80969, 80970, 80971, 80972, 80973, 80974, 80975, 80996, 80997, 80998, 80999, 81000, 81001, 75830, 75871, 75875, 81613, 75863, 75890, 75895, 75854, 75855, 75857, 75858, 81002, 81003, 81004, 81005, 81006, 81007, 75305, 75311, 75315, 75323, 75324, 75326, 75331, 75336, 81008, 81009, 81010, 81011, 81012, 81013, 81014, 81015, 81016, 81017, 81018, 81019, 81020, 81021, 81025, 81026, 81027, 81028, 81029, 81030, 81031, 75891, 75869, 75870, 75873, 75880, 75882, 75901, 75916, 75927, 75929, 75931, 75935, 75936, 75942, 75943, 75913, 81058, 81059, 81060, 75353, 75339, 75358, 75363, 75367, 75368, 75369, 75371, 75372, 75373, 75374, 75375, 75376, 75377, 75381, 75384, 81063, 81065, 81066, 81067, 81068, 81069, 81070, 81072, 81073, 81086, 81565, 81566, 81587, 81588, 75898, 75928, 75900, 75955, 75964, 75966, 75602, 75977, 75968, 75969, 75970, 81589, 81590, 81591, 75422, 75424, 75385, 75394, 75397, 75402, 75405, 75419, 75421, 75427, 81592, 81607, 81608, 81609, 81610, 81612, 81614, 81615, 81616, 81617, 81618, 81619, 81620, 81621, 81622, 81623, 81624, 81626, 81634, 81637, 81638, 81639, 81647, 81648, 81649, 81650, 81651, 75945, 75948, 75950, 75953, 75978, 75986, 75987, 75989, 76009, 75980, 76020, 76836, 76010, 76018, 81652, 81653, 75432, 75442, 75445, 75451, 75453, 75463, 75466, 75470, 81654, 81655, 81656, 75493, 75494, 75508, 75521, 75522, 75549, 75550, 75551, 75553, 75557, 75560, 75566, 75568, 75569, 75571, 75573, 75576, 75979, 75988, 76019, 76048, 76025, 76045, 75584, 75585, 75591, 75592, 75593, 75603, 75604, 75627, 76296, 75665, 75666, 75668, 75670, 75671, 75672, 75679, 76333, 75734, 75736, 75685, 75691, 75701, 75706, 75707, 75719, 75721, 75723, 76164, 75735, 75747, 75766, 76079, 76092, 76100, 75751, 75752, 75755, 75757, 75763, 75764, 75769, 75770, 75773, 76461, 75783, 75794, 75795, 75805, 75808, 75813, 75821, 75822, 75823, 76540, 75843, 75831, 75833, 75834, 75837, 75841, 75842, 75850, 76582, 75894, 75905, 75912, 75921, 75923, 75926, 75932, 75934, 76116, 76120, 76140, 76149, 76162, 76165, 76125, 76117, 76126, 76163, 75961, 75962, 75963, 75965, 75967, 75974, 75976, 75982, 75985, 75991, 76008, 76011, 76014, 76015, 76060, 76070, 76035, 76036, 76042, 76043, 76044, 76046, 76047, 76058, 76062, 76087, 76099, 76118, 76132, 76178, 76184, 76185, 76186, 76194, 76202, 76214, 76203, 76213, 76192, 76105, 76098, 76101, 76115, 76147, 76119, 76123, 76127, 76128, 76129, 76135, 76144, 76146, 76148, 76150, 76151, 76169, 76166, 76170, 76172, 76174, 76177, 76179, 76182, 76183, 76368, 76219, 76220, 76224, 76228, 76282, 76324, 76328, 76238, 76240, 76242, 76225, 76188, 76190, 76197, 77085, 76218, 76221, 76222, 76223, 76235, 76239, 76241, 80212, 80213, 80214, 80216, 80217, 80433, 76266, 76276, 76269, 76277, 76275, 76244, 76245, 76262, 76315, 76326, 76327, 76331, 76336, 76283, 76325, 76281, 76319, 76329, 76339, 76343, 76285, 76286, 76290, 76292, 76293, 76294, 76295, 76297, 76303, 76311, 76312, 76323, 76334, 76335, 76349, 76350, 76386, 76364, 76376, 76395, 76396, 76409, 76369, 76375, 76385, 76387, 76410, 76360, 76361, 76363, 76367, 76379, 76382, 76389, 76390, 76391, 76392, 76399, 76406, 76407, 76408, 76411, 76412, 76420, 76435, 76637, 76467, 76472, 76413, 76416, 76459, 76460, 76466, 76423, 76437, 76468, 76426, 76428, 76431, 76433, 76434, 76436, 76438, 76441, 76442, 76445, 76451, 76452, 76453, 76454, 76462, 76464, 76465, 76473, 76474, 76475, 76478, 76479, 76481, 76498, 76511, 76513, 76547, 76526, 76512, 76499, 76480, 76484, 76495, 76496, 76497, 76504, 76516, 76518, 76519, 76520, 76521, 76523, 76530, 76539, 76542, 76545, 76548, 76553, 76559, 76560, 76561, 76563, 76564, 76588, 76590, 76572, 76550, 76571, 76554, 76555, 76566, 76567, 76568, 76569, 76573, 76583, 76584, 76585, 76586, 76587, 76589, 76595, 76597, 76599, 76600, 76604, 76606, 76607, 76610, 76602, 76593, 76617, 76622, 76594, 76598, 76601, 76616, 76618, 76619, 76642, 76649, 76624, 76653, 76658, 76665, 76644, 76645, 76640, 76663, 76643, 76625, 76631, 76633, 76634, 76635, 76636, 76638, 76639, 76646, 76647, 76648, 76652, 76666, 76668, 76669, 76673, 76681, 76682, 76683, 76684, 76711, 76689, 76696, 76705, 76706, 76709, 76687, 76695, 76697, 76703, 76717, 76718, 76719, 76736, 76737, 76741, 76744, 76749, 76742, 76750, 76721, 76722, 76726, 76727, 76732, 76733, 76734, 76735, 76743, 76747, 76748, 76753, 76768, 76785, 76763, 76792, 76755, 76761, 76783, 76754, 76759, 76769, 76770, 76771, 76773, 76776, 76777, 76778, 76781, 76782, 76788, 76800, 76802, 76811, 76801, 76808, 76803, 76809, 76813, 76817, 76842, 76854, 76855, 76856, 76840, 76843, 76818, 76819, 76820, 76822, 76823, 76824, 76825, 76826, 76827, 76849, 76850, 76853, 76859, 76863, 76860, 76864, 76865, 76867, 76868, 76869, 76870, 76871, 76876, 76877, 76878, 76879, 76880, 76882, 76883, 76885, 76890, 76891, 76901, 76903, 77024, 76902, 76881, 76886, 76887, 76893, 76899, 76900, 76904, 76907, 76941, 76942, 76943, 76940, 76944, 76908, 76909, 76918, 76919, 76921, 76923, 76924, 76926, 76938, 76939, 76946, 76950, 76956, 76963, 76964, 76974, 76989, 76959, 76965, 76966, 76973, 76975, 76976, 76977, 76978, 76983, 76985, 76986, 76988, 76991, 76994, 77006, 77010, 76993, 77004, 77132, 77011, 76995, 77000, 77002, 77005, 77023, 77025, 77030, 77031, 77032, 77041, 77039, 77064, 77065, 77052, 77066, 77033, 77037, 77040, 77044, 77048, 77062, 77063, 77067, 77068, 77070, 77073, 77071, 77074, 77076, 77077, 77078, 77081, 77082, 77086, 78464, 77093, 77095, 77098, 77101, 77091, 77094, 77092, 77097, 77104, 77109, 77146, 77138, 77141, 77113, 77114, 77119, 77120, 77126, 77127, 77128, 77129, 77133, 77149, 77151, 77154, 77184, 77188, 77153, 77185, 77187, 77281, 77157, 77152, 77155, 77156, 77159, 77160, 77161, 77162, 77163, 77164, 77165, 77166, 77167, 77177, 77178, 77179, 77180, 77181, 77182, 77183, 77198, 77207, 77209, 77197, 77200, 77201, 77205, 77194, 77196, 77206, 77208, 77213, 77215, 77216, 77219, 77220, 77222, 77223, 78711, 77235, 77236, 77239, 77232, 77237, 77241, 77258, 77254, 77261, 77263, 77267, 77268, 77269, 77270, 77275, 77279, 77280, 77283, 77284, 77288, 77293, 77295, 77296, 77334, 77341, 77342, 77340, 77286, 77292, 77339, 77299, 77300, 77302, 77303, 77305, 77306, 77307, 77327, 77338, 77348, 77373, 77374, 77377, 77387, 77391, 77385, 77354, 77355, 77356, 77368, 77369, 77375, 77379, 77381, 77382, 77383, 77386, 77390, 77398, 77405, 77396, 77399, 77426, 77392, 77403, 77411, 77419, 77420, 77421, 77422, 77424, 77433, 77472, 77454, 77442, 77455, 77457, 77429, 77437, 77439, 77447, 77463, 77464, 77465, 77474, 77475, 77484, 77487, 77494, 77495, 77496, 77497, 77498, 77499, 77500, 77501, 77530, 77533, 77527, 77535, 77504, 77505, 77506, 77507, 77508, 77509, 77512, 77518, 77519, 77521, 77534, 77540, 77543, 77544, 77545, 77536, 77554, 77537, 77560, 77563, 77564, 77577, 77581, 77583, 77565, 77566, 77567, 77570, 77571, 77574, 77585, 77598, 77599, 77586, 77587, 77588, 77602, 77589, 77590, 77591, 77593, 77594, 77595, 77597, 77637, 77620, 77606, 77608, 77629, 77635, 77621, 77622, 77623, 77624, 77625, 77626, 77640, 77642, 77644, 77681, 77682, 77696, 77646, 77650, 77651, 77652, 77653, 77654, 77655, 77657, 77659, 77672, 77673, 77674, 77675, 77676, 77679, 77680, 77687, 77688, 77692, 77694, 77697, 77699, 77703, 77708, 77709, 77717, 77723, 77726, 77727, 77731, 77735, 77716, 77698, 77715, 77706, 77710, 77713, 77718, 77719, 77720, 77721, 77722, 77725, 77732, 77733, 77734, 79575, 77767, 77768, 77738, 77771, 77774, 77776, 77778, 77741, 77742, 77743, 77744, 77745, 77746, 77747, 77748, 77759, 77760, 77761, 77769, 77775, 77777, 77779, 77780, 77781, 77783, 77821, 77820, 77782, 77784, 77786, 77787, 77788, 77789, 77790, 77791, 77792, 77793, 77794, 77800, 77801, 77802, 77803, 77804, 77805, 77806, 77810, 77816, 77818, 77819, 77822, 77826, 77827, 77828, 77830, 77840, 77841, 77837, 77849, 77857, 77823, 77831, 77833, 77834, 77835, 77842, 77843, 77844, 77845, 77847, 77848, 79784, 77861, 77862, 77864, 77866, 77868, 77870, 77876, 77890, 77896, 77858, 77859, 77860, 77874, 77875, 77877, 77878, 77879, 77887, 77888, 77889, 77893, 77894, 77895, 79809, 77900, 77903, 77908, 77919, 77915, 77918, 77923, 77938, 77928, 77914, 77997, 77922, 77901, 77902, 77906, 77909, 77910, 77911, 77921, 77930, 77931, 77932, 77933, 77934, 77935, 77936, 77964, 77945, 77951, 77952, 77954, 77965, 77966, 77944, 77947, 77946, 77948, 77939, 77940, 77941, 77942, 77943, 77953, 77956, 77960, 77963, 77969, 77970, 77996, 77999, 78001, 78002, 78003, 77973, 78000, 78279, 77992, 77974, 77975, 77976, 77979, 77980, 77981, 77986, 77987, 77988, 77991, 77993, 77995, 78005, 78006, 78013, 78019, 78038, 78042, 78043, 78028, 78029, 78030, 78031, 78032, 78033, 78034, 78035, 78037, 78039, 78053, 78058, 78051, 78046, 78047, 78049, 78052, 78054, 78055, 78057, 78059, 78062, 78064, 78065, 78077, 78072, 78080, 78101, 78103, 78079, 78104, 78107, 78088, 78102, 78100, 78082, 78084, 78085, 78086, 78087, 78090, 78096, 78109, 78128, 78199, 78149, 78111, 78138, 78150, 78115, 78113, 78114, 78116, 78119, 78120, 78121, 78124, 78125, 78131, 78132, 78134, 78135, 78136, 78137, 78151, 78152, 78155, 78153, 78180, 78154, 78164, 78165, 78168, 78157, 78161, 78162, 78163, 78166, 78167, 78169, 78170, 78171, 78174, 78177, 78178, 78179, 80291, 78182, 78185, 78187, 78192, 78194, 78216, 78217, 78218, 78223, 78228, 78211, 78213, 78183, 78193, 78197, 78200, 78206, 78207, 78227, 78208, 78212, 78224, 78225, 78226, 78233, 78234, 78239, 78245, 78232, 78230, 78240, 78243, 78244, 78246, 78247, 78248, 78255, 78256, 78260, 78262, 78265, 78266, 78267, 80425, 78294, 78282, 78284, 78285, 78289, 78291, 78292, 78302, 78388, 78304, 78305, 78275, 78277, 78297, 78298, 78301, 78303, 78307, 78349, 78308, 78311, 78312, 78337, 78315, 78347, 78309, 78236, 78310, 78313, 78314, 78320, 78321, 78329, 78335, 78336, 78338, 78339, 78340, 78341, 78343, 78344, 78345, 78348, 78352, 78354, 78356, 78359, 78366, 78374, 78375, 78376, 78377, 78360, 78361, 78363, 78364, 78367, 78358, 78362, 78368, 78369, 78414, 78386, 78394, 78396, 78397, 78413, 78416, 78417, 80640, 78389, 78385, 78387, 78390, 78391, 78392, 78393, 78395, 78400, 78404, 78408, 78409, 78411, 78421, 78422, 78423, 78431, 78434, 78436, 78438, 78439, 78430, 78441, 78424, 78425, 78426, 78427, 78428, 78429, 78432, 78433, 78435, 78437, 78440, 78443, 78444, 78469, 78548, 78481, 78482, 78483, 78499, 78475, 78486, 78491, 78476, 78492, 78445, 78448, 78449, 78454, 78460, 78465, 78466, 78467, 78468, 78477, 78479, 78480, 78487, 78494, 78496, 78500, 78515, 78506, 78508, 78511, 78512, 78521, 78525, 78527, 78539, 78516, 78502, 78503, 78504, 78507, 78509, 78510, 78513, 78514, 78517, 78520, 78523, 78526, 78528, 78532, 78533, 78542, 78543, 78544, 78550, 78540, 78541, 78551, 78549, 78552, 78553, 78554, 78555, 78556, 78562, 78570, 78572, 78573, 78564, 78566, 78571, 78574, 78563, 78522, 78557, 78558, 78560, 78561, 78576, 78584, 78586, 78600, 78588, 78599, 78597, 78601, 78585, 78587, 78589, 78590, 78592, 78593, 78594, 78598, 78605, 78608, 78629, 78631, 78642, 78645, 78602, 78633, 78609, 78640, 78603, 78604, 78610, 78619, 78635, 78637, 78641, 78648, 78612, 78613, 78620, 78627, 78628, 78630, 78632, 78634, 78644, 78647, 78691, 78697, 78705, 78708, 78653, 78578, 78580, 78581, 78582, 78583, 78679, 78686, 78688, 78652, 78684, 78685, 78689, 78650, 78658, 78662, 78664, 78670, 78674, 78675, 78677, 78680, 78681, 78682, 78690, 78693, 78701, 78706, 78713, 78714, 78715, 78722, 78729, 78745, 78716, 78718, 78723, 78724, 78725, 78726, 78727, 78728, 78730, 78731, 78734, 78736, 78737, 78738, 78739, 78743, 78763, 78791, 78796, 78797, 78678, 78772, 78776, 78798, 78746, 78749, 78750, 78752, 78762, 78760, 78761, 78767, 78768, 78769, 78771, 78781, 78800, 78812, 78814, 78825, 78836, 78839, 78817, 78821, 78927, 78822, 78827, 78828, 78829, 78804, 78805, 78806, 78809, 78811, 78813, 78815, 78819, 78837, 78873, 78870, 78965, 78753, 78845, 78846, 78853, 78854, 78855, 78856, 78858, 78859, 78863, 78864, 78865, 78866, 78868, 78906, 78910, 78920, 78935, 78939, 78942, 78953, 78926, 78912, 78896, 78897, 78898, 78900, 78901, 78902, 78905, 78932, 78961, 78899, 78917, 78918, 78919, 78923, 78925, 78928, 78929, 78933, 78934, 79004, 79022, 78971, 79087, 78972, 78973, 78991, 79041, 79047, 79048, 78979, 78981, 78982, 78983, 78987, 78989, 78995, 78997, 78998, 78966, 78988, 78994, 79013, 79017, 79018, 79053, 79056, 79057, 79060, 79061, 79064, 79069, 79063, 79070, 79058, 79052, 79055, 79067, 79071, 79077, 79086, 79089, 79096, 79105, 79093, 79095, 79107, 79113, 79091, 79081, 79082, 79083, 79085, 79072, 79079, 79080, 79084, 79090, 79097, 79099, 79100, 79101, 79108, 79109, 79110, 79111, 79112, 79114, 79117, 79125, 79126, 79127, 79128, 79164, 79176, 79179, 79129, 79131, 79134, 79146, 79165, 79168, 79172, 79138, 79167, 79130, 79137, 79143, 79148, 79149, 79152, 79471, 79173, 79133, 79166, 79153, 79154, 79158, 79169, 79170, 79174, 79178, 79180, 79182, 79273, 79254, 79211, 79218, 79213, 79222, 79231, 79233, 79232, 79205, 79230, 79234, 79209, 79226, 79227, 79243, 79301, 79302, 79291, 79312, 79297, 79286, 79358, 79288, 79290, 79292, 79305, 79306, 79307, 79308, 79323, 79326, 79365, 79396, 79411, 79214, 79419, 79378, 79380, 79381, 79383, 79384, 79385, 79882, 79386, 79388, 79370, 79362, 79373, 79389, 79392, 79393, 79414, 79431, 79391, 79394, 79400, 79492, 79494, 79508, 79514, 79521, 79439, 79440, 79441, 79443, 79447, 79448, 79450, 79512, 79527, 79463, 79469, 79470, 79472, 79480, 79491, 79493, 79500, 79543, 79582, 79584, 79599, 79572, 79573, 79625, 79545, 79546, 79548, 79549, 79550, 79551, 79552, 79555, 79556, 79557, 79558, 79576, 79581, 79586, 79544, 79542, 79669, 79700, 79711, 79713, 79667, 79668, 79670, 79671, 79637, 79638, 79639, 79640, 79641, 79642, 79643, 79644, 79647, 79661, 79709, 79634, 79708, 79796, 79850, 79755, 80498, 79756, 79797, 79844, 79849, 79753, 79760, 79763, 79764, 79765, 79766, 79767, 79770, 79771, 79774, 79749, 79750, 79789, 79747, 79758, 79856, 79865, 80068, 79918, 79852, 79853, 79855, 79857, 79864, 79874, 79875, 79876, 79879, 79883, 79884, 79885, 79886, 79889, 79892, 79893, 79894, 79861, 79862, 79887, 79967, 79968, 79975, 80008, 80014, 80024, 79969, 79972, 79976, 79980, 79981, 79982, 79984, 79985, 79988, 79964, 79966, 79990, 79997, 79987, 79992, 79995, 80009, 80010, 80011, 80012, 80013, 80017, 80018, 80071, 80121, 80082, 80096, 80097, 80105, 80162, 80063, 80064, 80065, 80095, 80098, 80062, 80066, 80067, 80091, 80092, 80077, 80129, 80100, 80101, 80111, 80119, 80122, 80123, 80124, 80125, 80126, 80142, 80190, 80207, 80237, 80238, 80163, 80174, 80175, 80166, 80179, 80188, 80195, 80227, 80181, 80200, 80203, 80204, 80233, 80234, 80235, 80236, 80247, 80167, 80169, 80170, 80171, 80172, 80176, 80177, 80209, 80275, 80251, 80255, 80256, 80253, 80310, 80311, 80313, 80264, 80265, 80267, 80270, 80274, 80286, 80287, 80288, 80320, 80249, 80250, 80254, 80294, 80296, 80358, 80312, 80317, 80318, 80319, 80325, 80340, 80344, 80383, 80390, 80410, 80421, 80391, 80394, 80397, 80400, 80406, 80345, 80356, 80387, 80416, 80435, 80408, 80409, 81064, 80412, 80424, 80427, 80431, 80352, 80360, 80382, 80386, 80389, 80422, 80423, 80426, 80428, 80430, 80432, 80459, 80529, 80538, 80455, 80439, 80461, 80474, 80476, 80536, 80549, 80457, 80458, 80470, 80471, 80472, 80473, 80478, 80480, 80482, 80514, 80516, 80486, 80487, 80488, 80490, 80492, 80493, 80523, 80527, 80528, 80533, 80537, 80540, 80547, 80548, 80567, 80589, 80592, 80663, 80554, 80555, 80556, 80558, 80580, 80581, 80582, 80583, 80563, 80590, 80597, 80632, 80642, 80664, 80584, 80585, 80586, 80588, 80621, 80623, 80624, 80593, 80595, 80596, 80598, 80599, 80673, 80697, 80747, 80665, 80666, 80929, 80684, 80686, 80688, 80703, 80704, 80736, 80737, 80739, 80757, 80758, 80759, 80671, 80674, 80675, 80667, 80672, 80707, 80712, 80715, 80745, 80749, 80806, 80823, 80824, 80855, 80859, 80860, 80862, 80760, 80761, 80796, 80802, 80804, 80822, 80847, 80766, 80769, 80793, 80794, 80831, 80832, 80873, 80917, 80918, 80925, 80926, 80927, 80928, 80930, 80931, 80932, 80976, 80977, 80978, 80979, 80980, 80981, 80982, 80983, 80984, 80985, 80986, 80987, 80988, 80989, 81032, 81033, 81035, 81036, 81037, 81038, 81039, 81107, 81108, 81109, 81150, 81022, 81023, 81024, 81154, 81156, 81159, 81162, 81171, 81155, 81157, 81160, 81161, 81242, 81243, 81246, 81247, 81255, 81258, 81297, 81299, 81265, 81259, 81264, 81275, 81298, 81364, 81360, 81487, 81488, 81489, 81490, 81491, 81492, 81493, 81494, 81495, 81496, 81498, 81499, 81351, 81353, 81354, 81355, 81430, 81465, 81466, 81467, 81468, 81469, 81471, 81470, 81425, 81501, 81502, 81564, 81567, 81627, 81593, 81596, 81599, 81601, 81602, 81603, 81605, 81606, 81631, 81632, 81633, 81594, 81595, 81597, 81629, 81636, 81645, 81536, 81522, 81503, 81504, 81506, 81507, 81508, 81509, 81510, 81511, 81512, 81500, 81682, 75990, 76106, 76107, 77001, 77276, 77277, 77278, 77714, 77752, 78317, 78318, 78319, 81702, 79028, 80867, 77242, 80920, 78668, 78671, 78672, 78843, 78985, 78986, 78990, 79026, 79034, 79042, 79956, 80468, 80576, 80577, 80578, 80587, 80594, 80691, 80784, 80995, 79032, 79913, 80491, 76102, 76670, 76674, 76852, 76916, 76917, 77118, 77186, 77195, 77203, 77240, 77477, 77482, 77882, 77978, 76384, 78747, 78754, 77329, 81393, 81395, 81396, 81409, 81415, 81419, 81432, 81433, 81434, 81435, 81437, 75091, 75170, 75465, 76112, 76289, 76298, 76404, 76415, 76417, 76419, 76422, 76398, 76425, 76427, 76429, 76432, 76463, 76469, 76470, 76483, 76486, 76487, 76488, 76489, 76490, 76491, 76492, 76493, 76494, 76505, 76506, 76508, 76509, 76510, 76517, 76522, 80359, 76524, 76531, 76532, 76533, 76534, 76657, 76667, 76675, 76676, 76677, 76678, 76680, 76686, 77150, 77260, 77262, 77266, 77282, 77285, 77287, 77289, 77297, 77298, 77308, 77309, 77310, 77311, 77312, 77314, 77345, 77346, 77361, 77365, 77366, 77367, 77404, 77406, 77407, 77408, 77410, 77412, 77413, 77982, 77983, 77984, 77985, 78004, 78330, 78331, 78355, 78519, 78529, 78530, 78534, 78538, 78546, 78547, 78595, 78611, 78615, 78616, 78710, 78720, 78733, 78740, 78741, 78785, 78787, 78894, 78895, 78914, 78921, 78931, 78938, 78941, 78944, 79059, 79062, 79065, 79068, 79074, 79075, 79076, 79092, 79098, 79103, 79106, 79115, 79116, 79118, 79119, 79120, 79121, 79122, 79123, 79124, 79147, 79257, 79260, 79266, 79293, 79304, 79330, 79612, 79613, 79618, 79645, 79646, 79648, 80037, 80039, 80044, 80049, 80054, 80061, 80069, 80072, 80073, 80076, 80079, 80080, 80086, 80087, 80088, 80109, 80114, 80115, 80117, 80118, 80120, 80130, 80131, 80134, 80135, 80137, 80138, 80139, 80140, 80141, 80151, 80159, 80884, 80161, 80164, 81071, 80165, 80180, 80183, 80184, 80185, 80186, 80189, 80197, 80198, 80199, 80201, 80220, 80221, 80222, 80223, 80224, 80225, 80258, 74758, 74739, 74740, 74757, 74760, 74767, 80259, 80260, 74971, 75103, 75165, 75166, 80262, 75357, 75526, 75722, 76006, 80266, 76257, 77058, 77108, 80268, 80269, 80273, 80277, 77233, 77234, 80282, 80283, 80284, 79139, 80289, 80290, 80292, 80293, 80297, 80299, 80301, 80307, 80308, 80309, 80314, 80315, 80333, 80436, 80437, 80441, 80442, 80443, 80444, 80446, 80501, 80504, 80506, 80507, 80509, 80510, 80511, 80519, 80520, 80521, 80522, 80525, 80534, 80542, 80605, 80606, 80609, 80611, 80612, 80613, 80614, 80615, 80616, 80617, 80618, 80620, 80622, 80633, 80643, 80645, 80646, 80726, 80731, 80743, 80754, 80756, 80762, 80763, 80764, 80777, 80778, 80779, 80781, 80782, 80783, 80687, 80785, 80786, 80787, 80788, 80790, 80792, 80799, 80801, 80805, 80807, 80808, 80809, 80810, 80811, 80812, 80814, 80815, 80826, 80827, 80828, 80993, 80994, 81040, 81041, 81042, 81044, 81045, 81047, 81048, 81049, 81052, 81054, 81055, 81056, 81057, 81061, 81076, 81077, 81079, 81211, 81212, 81215, 81216, 81221, 81224, 81225, 81227, 81228, 81229, 81231, 81232, 81233, 81234, 81235, 81237, 81238, 81239, 81240, 81248, 81316, 81317, 81318, 81319, 81320, 81321, 81322, 81323, 81324, 81325, 81326, 81328, 81331, 81332, 81333, 81334, 81339, 81340, 81341, 81343, 81344, 81345, 81365, 81366, 81386, 81387, 81388, 81389, 81390, 81397, 81399, 81400, 81401, 81403, 81404, 81405, 81406, 81407, 81414, 81416, 81422, 81455, 81456, 81457, 81462, 81482, 81483, 81484, 81485, 81486, 77633, 77649, 77656, 77658, 77663, 77664, 77677, 77678, 77683, 77684, 74853, 74844, 81294, 77686, 77691, 77701, 77724, 77740, 77770, 77772, 77785, 77796, 78415, 78473, 79036, 78964, 78775, 78455, 81699, 81700, 81102, 78333, 78238, 78346, 78383, 78398, 78127, 78471, 79329, 78472, 78518, 76268, 81438, 76821, 77376, 78924, 79574, 80271, 81034, 76264, 76603, 76739, 77211, 77384, 77344, 77582, 76651, 77627, 77020, 75709, 80158, 77578, 81267, 74803, 78962, 80407, 79016, 79588, 79051, 79135, 79163, 79200, 79202, 79136, 79277, 79278, 79279, 79283, 79289, 79298, 79300, 79333, 74785, 79663, 79699, 78231, 80103, 77046, 78524, 81082, 75540, 78094, 80475, 78717, 79788, 77529, 75852, 79520, 79592, 75450, 77347, 79502, 75625, 75732, 75829, 75325, 78649, 75872, 75462, 75638, 75748, 77628, 77739, 78110, 75700, 81276, 77603, 78687, 78751, 79374, 75715, 78830, 77328, 75806, 76990, 75786, 74824, 77904, 77274, 75944, 76557, 78936, 81091, 75930, 79834, 79694, 75295, 81090, 81083, 75302, 75838, 75559, 76029, 75758, 76330, 76701, 76920, 77552, 78083, 78220, 78646, 78810, 79310, 79379, 79335, 81088, 79336, 77580, 75420, 75741, 79465, 78270, 77949, 78903, 76527, 77546, 76258, 74872, 78372, 75322, 76691, 79171, 75278, 76167, 74843, 77456, 76280, 74895, 81087, 80093, 75037, 74993, 74873, 75973, 76720, 76082, 76217, 76738, 76790, 76897, 76981, 78278, 77134, 77301, 77430, 79256, 79343, 80229, 77605, 78017, 78020, 78915, 78967, 80767, 80768, 81286, 74746, 75971, 76081, 79262, 78259, 75006, 78272, 74747, 81691, 81694, 81439, 79354, 79355, 79395, 79399, 79425, 79201, 80662, 80839, 81348, 81350, 81352, 81356, 81370, 81371, 81372, 81447, 78273, 79495, 79533, 79534, 79689, 79690, 80230, 80348, 75136, 81429, 81426, 81514, 81515, 81516, 81517, 81518, 81519, 81520, 81523, 81525, 81526, 81527, 81528, 81529, 81531, 81535, 81537, 81513, 81533, 81701, 81111, 79397, 80846, 78451, 81114, 81104, 81101, 78880, 81346, 81093, 79192, 81530, 78334, 79299, 81534, 80820, 81690, 81521, 79418, 75588, 78867, 81532, 76001, 76002, 76103, 76104, 75284, 75290, 81688, 78269, 79037, 81698, 81428, 78881, 79221, 79356, 75607, 75609, 77072, 78252, 78446, 78461, 79141, 76256, 76259, 76365, 76381, 76383, -7, 76388, 76476, 78241, 76053, 77363, 77466, 77469, 81683, 81440, 81692, 74959, 75147, 79360, 77609, 77611, 77612, 77613, -18, 77617, 77619, 81115, 77883, 77892, 77920, 78016, 78026, 78089, 78091, 78229, 78235, 81681, 81357, 78237, 78253, 81336, 81337, 81338, 75140, 75053, -3, 74791, -6, -8, 81582, -5, 81583, 81585, 79361, 80575, 80579, 75143, 80677, 80685, 80740, 81204, 81410, 81411, 81412, 81043, 75677, 75815, 75816, 75817, 75818, 75866, 75383, 75041, 81092, 81394, 76113, 81685, 81448, 78908, 75867, 75993, 76049, 76414, 76421, 76623, 74967, 81680, 77853, 77856, 75067, 75135, 77880, 81112, 81524, 80515, 79142, 79223, 79046, 78281, 81689, 79331, 79332, 79454, 79486, 79488, 80361, 80635, 80637, 80638, 80877, 80878, 80879, 81436, 80880, 80881, 81113, 75052, 75280, 78474, 78325, 81452, 81454, 81459, 74796, 74797, 74799, 74819, 74827, 74855, 74866, 74868, 76996, 74869, 79244, 78412, 78886, 81480, 75042, 79743, 77199, 74908, 74929, 74936, 74893, 79197, 78327, 81441, 74958, 81684, -9, 79204, 74961, 74965, 74744, 74986, 80840, 81105, 81117, 81347, 78384, 81103, 79228, -4, 81687, 75119, 75120, 81693, 75126, 75128, 75131, 75144, 75162, 75168, 79359, 81127, 79162, 75063, 75127, 75417, 75458, 75580, 75581, 75590, 75630, 75636, 78940, 79746, 79989, 81053, 74795, 75118, 75291, 75300, 75558, 75703, 75710, 75711, 81463, 81472, 75714, 75861, 75862, 75960, 76110, 76133, 76134, 76152, 76153, 76154, 76155, 76156, 76158, 76248, 76249, 76250, 76580, 76581, 76596, 76730, 76731, 76866, 76872, 77753, 77754, 77755, 77756, 77851, 78257, 78258, 78263, 78274, 78316, 81335, 81475, 81584, 81586, 81417, 81418, 74858, 75293, 75390, 79025, 79030, 78380, 78459, 78493, 78577, 78579, 78721, 78742, 81460, 81461, 81473, 81474, 81476, 81477, 81478, 81479, 78744, 75542, 78210, 75236, 78036, 78066, 78831, 78788, 78189, 80852, 79140, 79194, 79317, 79682, 81301, 74784, 74969, 74987, 74991, 74995, 75001, 75044, 75064, 75174, 75184, 75190, 75191, 75192, 75218, 75219, 75220, 75222, 75223, 75228, 75263, 75270, 75273, 75283, 75288, 75319, 75320, 75321, 75343, 75344, 75351, 75352, 75360, 75362, 75366, 75408, 75409, 75410, 75413, 75415, 75416, 75431, 75433, 75437, 75439, 75443, 75449, 75370, 75460, 75464, 75468, 75473, 75474, 75478, 75480, 75482, 75486, 75498, 75499, 75501, 75502, 75518, 75525, 75530, 75564, 75567, 75610, 75613, 75617, 75618, 75623, 75624, 75649, 75655, 75656, 75659, 75660, 75667, 75688, 75689, 75695, 75716, 75718, 75761, 75767, 75768, 75771, 75772, 75775, 75801, 75812, 75814, 75819, 75835, 75844, 75853, 75864, 75865, 75868, 75881, 75889, 75904, 75906, 75908, 75909, 75937, 75939, 75941, 76003, 76005, 76007, 76030, 76032, 76034, 76038, 76051, 76054, 76055, 76056, 76057, 76061, 76075, 76076, 76077, 76083, 76094, 76013, 76159, 76160, 76161, 76204, 76205, 76206, 76207, 76209, 76210, 76211, 76261, 76300, 76302, 76304, 76305, 76309, 76310, 76314, 76316, 76318, 76342, 76347, 76357, 76358, 76393, 76394, 76400, 76403, 76440, 76443, 76447, 76448, 76449, 76450, 76456, 76457, 76458, 76535, 76536, 76537, 76538, 76543, 76544, 76552, 76570, 76575, 76578, 76627, 76628, 76630, 76632, 76641, 76654, 76655, 76656, 76688, 76692, 76704, 76710, 76713, 76714, 76716, 76723, 76728, 76746, 76751, 76758, 76774, 76775, 76779, 76787, 76789, 76793, 76795, 76805, 76816, 76828, 76830, 76832, 76844, 76847, 76873, 76875, 76888, 76892, 76922, 76927, 76930, 76931, 76932, 76933, 76934, 76935, 76947, 76957, 76958, 76980, 76997, 76998, 77008, 77009, 77014, 77017, 77021, 77026, 77028, 77029, 77035, 77050, 77053, 77060, 77061, 77069, 77075, 77084, 77088, 77099, 77102, 77107, 77122, 77123, 77124, 77131, 77135, 77136, 77137, 77139, 77140, 77142, 77143, 77145, 77147, 77169, 77170, 77173, 77174, 77175, 77212, 77214, 77217, 77221, 77225, 77226, 77227, 77228, 77244, 77245, 77315, 77317, 77318, 77319, 77320, 77321, 77322, 77323, 77324, 77325, 77326, 77330, 77331, 77333, 77336, 77337, 77414, 77415, 77427, 77441, 77443, 77459, 77460, 77461, 77462, 77510, 77513, 77514, 77516, 77524, 77556, 77557, 77558, 77559, 77561, 77562, 77569, 77667, 77668, 77669, 77670, 77671, 77757, 77758, 77763, 77764, 77811, 77832, 77838, 77929, 77937, 78007, 78009, 78011, 78012, 78122, 78133, 78139, 78141, 78143, 78144, 78156, 78158, 78173, 78181, 78184, 78188, 78191, 78195, 78196, 78323, 78324, 78403, 78405, 78406, 78418, 78419, 78442, 78450, 78452, 78453, 78462, 78463, 78470, 78484, 78485, 78488, 78501, 78624, 78626, 78654, 78656, 78660, 78661, 78663, 78665, 78666, 78667, 78673, 78676, 78683, 78692, 78694, 78695, 78696, 78698, 78719, 78792, 78795, 78807, 78808, 78816, 78838, 78840, 78848, 78849, 78851, 78857, 78877, 78878, 78879, 78884, 78889, 78890, 78892, 78945, 78954, 78957, 78969, 78970, 78976, 78978, 78980, 78984, 79049, 79054, 79150, 79151, 79155, 79156, 79159, 79160, 79161, 79183, 79188, 79191, 79193, 79195, 79196, 79198, 79207, 79212, 79245, 79252, 79255, 79363, 79366, 79367, 79406, 79408, 79420, 79423, 79426, 79427, 79428, 79436, 79444, 79449, 79452, 79483, 79511, 79522, 79523, 79524, 79525, 79528, 79529, 79531, 79536, 79537, 79541, 79559, 79560, 79561, 79562, 79563, 79564, 79565, 79569, 79570, 79571, 79601, 79609, 79610, 79650, 79651, 79652, 79653, 79655, 79657, 79658, 79665, 79666, 79672, 79683, 79687, 79719, 79731, 79732, 79733, 79735, 79739, 79740, 79745, 79757, 79759, 79773, 79775, 79783, 79791, 79820, 79821, 79828, 79840, 79841, 79858, 79860, 79863, 79870, 79871, 79880, 79904, 80032, 79912, 79914, 79915, 79917, 79924, 79926, 79930, 79942, 79946, 79949, 79950, 80081, 79951, 79955, 79958, 79959, 79973, 79977, 79978, 79986, 79993, 79994, 79999, 80000, 80002, 80003, 80004, 80023, 80029, 80031, 80033, 80034, 80036, 80038, 80090, 80107, 80108, 80226, 80240, 80241, 80242, 80243, 80244, 80245, 80246, 80257, 80335, 80336, 80346, 80349, 80351, 80367, 80371, 80373, 80374, 80378, 80381, 80392, 80393, 80395, 80398, 80399, 80404, 80415, 80417, 80452, 80453, 80456, 80460, 80464, 80465, 80466, 80467, 80469, 80484, 80495, 80496, 80497, 80499, 80500, 80543, 80545, 80551, 80552, 80559, 80564, 80568, 80570, 80571, 80572, 80573, 80574, 80601, 80602, 80657, 80659, 80660, 80661, 80669, 80676, 80679, 80681, 80682, 80692, 80693, 80700, 80708, 80711, 80713, 80714, 80720, 80723, 80741, 80765, 80770, 80771, 80772, 80773, 80775, 80776, 80780, 80829, 80836, 80838, 80841, 80848, 80849, 80851, 80857, 80863, 80882, 80990, 80992, 81080, 81081, 81094, 81098, 81099, 81100, 81116, 81119, 81123, 81124, 81125, 81126, 81128, 81129, 81130, 81132, 81133, 81138, 81141, 81144, 81145, 81306, 81179, 81180, 81181, 81182, 81183, 81201, 81203, 81205, 81206, 81207, 81208, 81250, 81251, 81260, 81261, 81268, 81307, 81310, 81313, 81314, 81315, 81373, 81377, 81378, 81379, 81381, 81382, 81383, 81384, 81385, 81544, 81545, 81546, 81547, 81549, 81553, 81554, 81555, 81556, 81557, 81558, 81559, 81568, 81569, 81570, 81571, 81577, 81581, 74751, 76614, 75737, 75760, 76021, 76023, 76026, 76027, 76028, 76050, 76067, 76068, 76072, 76136, 76137, 76145, 76187, 76189, 76198, 76199, 76200, 76237, 76252, 76253, 76320, 76321, 76322, 76370, 76374, 76377, 76378, 76380, 76612, 76613, 76664, 77350, 77351, 77357, 77358, 77473, 77523, 77526, 77539, 77542, 77575, 77576, 77592, 77601, 77630, 77631, 77632, 77814, 77815, 77863, 77869, 77871, 77872, 77905, 77912, 77957, 77959, 77967, 77971, 78060, 78073, 78099, 78105, 78145, 78146, 78198, 78242, 78249, 78250, 78286, 78287, 78288, 78293, 78300, 78707, 78735, 78888, 78992, 79002, 81413, 80837, 81421, 80001, 80752, 81458)""") 
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201503110632)  

        if self.dbversion<201504121011:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=%s where id=%s;", (True, 74744))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 74959))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 74967))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75052))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75053))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75135))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75136))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75140))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75147))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75280))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75284))
            cur.execute("update products set ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ('TIT.MI',[1, ],[3, ],  75067))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201504121011)     
            
        if self.dbversion<201504150622:
            cur=self.mem.con.cursor()
            cur.execute("update products set tpc=%s where id=%s;", (0, 76309))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201504150622)   
        if self.dbversion<201507151008:
            cur=self.mem.con.cursor()#Empty due to check role probes
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201507151008)        
        if self.dbversion<201507291541:
            cur=self.mem.con.cursor()
            cur.execute("alter table operinversiones add column show_in_ranges boolean")
            cur.execute("alter table operinversiones alter column show_in_ranges set default true;")
            cur.execute("update operinversiones set show_in_ranges =true")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201507291541)         
        if self.dbversion<201507291626:
            cur=self.mem.con.cursor()
            cur.execute("update operinversiones set show_in_ranges=false where id_tiposoperaciones in (5,6)")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201507291626)         
        if self.dbversion<201508242037:
            cur=self.mem.con.cursor()
            cur.execute("CREATE SEQUENCE simulations_seq  INCREMENT 1  MINVALUE 1  MAXVALUE 9223372036854775807  START 1  CACHE 1;")
            cur.execute("CREATE TABLE simulations(  database text,  id integer NOT NULL DEFAULT nextval('simulations_seq'::regclass),  starting timestamp with time zone,  ending timestamp with time zone,  type integer,  creation timestamp with time zone,  CONSTRAINT simulations_pk PRIMARY KEY (id)) WITH (OIDS=FALSE);")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201508242037)         
        if self.dbversion<201508270623:
            cur=self.mem.con.cursor()
            cur.execute("alter table inversiones  add column selling_expiration date default now()")
            cur.execute("update inversiones set selling_expiration=now()::date-1;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201508270623)         
        if self.dbversion<201510041406:#Cambia pago de impuesto a sistema
            cur=self.mem.con.cursor()
            #Comprueba si tiene los id_conceptos ocupados de impuestos 6 y 37
            cur.execute("select * from conceptos where id_conceptos=6")
            if cur.rowcount==0:
                cur.execute("insert into conceptos(id_conceptos, concepto, id_tiposoperaciones,editable) values(%s,%s, %s, %s)", (6, QApplication.translate("Core","Taxes. Returned"), 2,  False ))
            else:
                cur.execute("update conceptos set editable=%s where id_conceptos=%s", ( False, 6 ))
            cur.execute("select * from conceptos where id_conceptos=37")
            if cur.rowcount==0:
                cur.execute("insert into conceptos(id_conceptos, concepto, id_tiposoperaciones,editable) values(%s,%s, %s, %s)", (37, QApplication.translate("Core","Taxes. Paid"), 1,  False ))
            else:
                cur.execute("update conceptos set editable=%s where id_conceptos=%s", ( False, 37 ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201510041406)        
        if self.dbversion<201601050843:
            cur=self.mem.con.cursor()
            cur.execute("delete from globals where id_globals>=7")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201601050843)          
        if self.dbversion<201601170811:
            cur=self.mem.con.cursor()
            cur.execute("alter table products rename comentario to comment")
            cur.execute("alter table products rename id_bolsas to stockmarkets_id")
            cur.execute("alter table products rename apalancado to leveraged")
            cur.execute("alter table products rename tpc to percentage")
            
            cur.execute("alter table bolsas rename to stockmarkets")
            cur.execute("alter table stockmarkets rename id_bolsas to id")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201601170811)          
        if self.dbversion<201601290517:
            cur=self.mem.con.cursor()
            cur.execute("CREATE SEQUENCE orders_seq  INCREMENT 1  MINVALUE 1  MAXVALUE 9223372036854775807  START 1  CACHE 1;")
            cur.execute("""
                CREATE TABLE orders (
                    id integer NOT NULL DEFAULT nextval('orders_seq'::regclass),  
                    date date NOT NULL,  
                    expiration date NOT NULL,  
                    amount numeric(100,2),  
                    shares numeric(100,6),  
                    price numeric(100,2),  
                    investments_id integer NOT NULL,  
                    investmentoperations_id integer, 
                    CONSTRAINT orders_pk PRIMARY KEY (id),
                    CONSTRAINT orders_investments_id_fk_inversiones_id_inversiones FOREIGN KEY (investments_id) REFERENCES public.inversiones (id_inversiones) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT
                ) WITH (  OIDS=FALSE);
            """)
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201601290517)             
        if self.dbversion<201602040412:
            cur=self.mem.con.cursor()
            cur.execute("alter table orders drop investmentoperations_id")
            cur.execute("alter table orders add investmentoperations_id timestamp with time zone")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201602040412)             
        if self.dbversion<201602040422:
            cur=self.mem.con.cursor()
            cur.execute("alter table orders rename investmentoperations_id to executed")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201602040422)    
        if self.dbversion<201602100700:
            cur=self.mem.con.cursor()
            cur.execute("update products set isin=%s, ticker=%s, priority=%s, priorityhistorical=%s where id=%s;", ("US4642872000", "IVV",[1, ],[3, ],75704))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75625))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81698))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77904))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201602100700)         
        if self.dbversion<201602260424:
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE entidadesbancarias  ADD CONSTRAINT entidadesbancarias_pk PRIMARY KEY (id_entidadesbancarias)")
            cur.execute("ALTER TABLE cuentas  ADD CONSTRAINT cuentas_pk PRIMARY KEY (id_cuentas)")
            cur.execute("ALTER TABLE cuentas  ADD CONSTRAINT cuentas_fk_id_entidadesbancarias FOREIGN KEY (id_entidadesbancarias) REFERENCES entidadesbancarias (id_entidadesbancarias) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE dividends  ADD CONSTRAINT dividendos_fk_id_inversiones FOREIGN KEY (id_inversiones) REFERENCES inversiones (id_inversiones) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE dividends ADD CONSTRAINT dividendos_fk_id_conceptos FOREIGN KEY (id_conceptos) REFERENCES conceptos (id_conceptos) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201602260424)      
        if self.dbversion<201602260442:
            cur=self.mem.con.cursor()
            cur.execute("delete from quotes where id=7932")
            cur.execute("delete from quotes where id=81497")
            cur.execute("ALTER TABLE dps  ADD CONSTRAINT dps_fk_id FOREIGN KEY (id) REFERENCES products (id)  ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE inversiones ADD CONSTRAINT inversiones_fk_id_cuentas FOREIGN KEY (id_cuentas) REFERENCES cuentas (id_cuentas) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE opercuentas ADD CONSTRAINT opercuentas_fk_id_conceptos FOREIGN KEY (id_conceptos) REFERENCES conceptos (id_conceptos) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE opercuentas ADD CONSTRAINT opercuentas_fk_id_cuentas FOREIGN KEY (id_cuentas) REFERENCES cuentas (id_cuentas) ON UPDATE NO ACTION ON DELETE RESTRICT;")
            cur.execute("ALTER TABLE operinversiones  ADD CONSTRAINT operinversiones_fk_id_inversiones FOREIGN KEY (id_inversiones) REFERENCES inversiones (id_inversiones) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE opertarjetas ADD CONSTRAINT opertarjetas_fk_id_conceptos FOREIGN KEY (id_conceptos) REFERENCES conceptos (id_conceptos) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE opertarjetas ADD CONSTRAINT opertarjetas_fk_id_tarjetas FOREIGN KEY (id_tarjetas) REFERENCES tarjetas (id_tarjetas) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE products ADD CONSTRAINT products_fk_stockmarkets_id FOREIGN KEY (stockmarkets_id) REFERENCES stockmarkets (id) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE quotes ADD CONSTRAINT quotes_fk_id FOREIGN KEY (id) REFERENCES products(id) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE tarjetas ADD CONSTRAINT tarjetas_fk_id_cuentas FOREIGN KEY (id_cuentas) REFERENCES cuentas(id_cuentas) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201602260442)       
        if self.dbversion<201602260535:
            cur=self.mem.con.cursor()
            cur.execute("delete from estimations_dps where id=37")
            cur.execute("delete from estimations_dps where id=40")
            cur.execute("delete from estimations_dps where id=74")
            cur.execute("delete from estimations_dps where id=110")
            cur.execute("delete from estimations_dps where id=127")
            cur.execute("delete from estimations_dps where id=151")
            cur.execute("delete from estimations_dps where id=174")
            cur.execute("delete from estimations_dps where id=167")
            cur.execute("delete from estimations_dps where id=216")
            cur.execute("ALTER TABLE estimations_dps ADD CONSTRAINT estimations_dps_fk_id FOREIGN KEY (id) REFERENCES products (id) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE estimations_eps ADD CONSTRAINT estimations_eps_fk_id FOREIGN KEY (id) REFERENCES products (id) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE inversiones ADD CONSTRAINT inversiones_fk_products_id FOREIGN KEY (products_id) REFERENCES products (id) ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201602260535)       
        if self.dbversion<201602291116:
            cur=self.mem.con.cursor()
            cur.execute("DROP VIEW ohlcdaily")
            cur.execute("DROP VIEW ohlcmonthly")
            cur.execute("DROP VIEW ohlcweekly")
            cur.execute("DROP VIEW ohlcyearly")
            cur.execute("DROP VIEW tmpohlcdaily")
            cur.execute("DROP VIEW tmpohlcmonthly")
            cur.execute("DROP VIEW tmpohlcweekly")
            cur.execute("DROP VIEW tmpohlcyearly")
            cur.execute("DROP AGGREGATE first(anyelement)")
            cur.execute("DROP AGGREGATE last(anyelement)")
            cur.execute("DROP FUNCTION first_agg(anyelement, anyelement)")
            cur.execute("DROP FUNCTION last_agg(anyelement, anyelement)")
            cur.execute("DROP TABLE status")
            cur.close()
            self.mem.con.commit() 
            self.set_database_version(201602291116)       
        if self.dbversion<201603010700:
            cur=self.mem.con.cursor()
            cur.execute("update products set agrupations=%s where id=%s", ( '|MERCADOCONTINUO|',81701 ))
            cur.execute("update products set agrupations=%s where id=%s", ( '|IBEX|MERCADOCONTINUO|',78325 ))
            cur.execute("update products set agrupations=%s where id=%s", ( '|IBEX|MERCADOCONTINUO|', 81704))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 79201))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81706, 'Merlin Properties Socimi S.A.', 'ES0105025003  ', 'EUR', 1, '|IBEX|MERCADOCONTINUO|', 'http://www.merlinproperties.com/', None, None, None, 100, 'c', 0, 1, 'MRL.MC', [9, ],[3, ], None, False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201603010700)      
        if self.dbversion<201603010710:
            cur=self.mem.con.cursor()
            cur.execute("update products set agrupations=%s where id=%s", ( '|MERCADOCONTINUO|',79201 ))
            cur.execute("update products set agrupations=%s where id=%s", ( '|MERCADOCONTINUO|',80840 ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201603010710)        
        if self.dbversion<201603030510:
            cur=self.mem.con.cursor()
            cur.execute("update products set agrupations=null where id=%s", ( 81480,  ))
            cur.execute("update products set agrupations='|f_es_BMF|' where agrupations ilike '%|00%'")
            cur.execute("update products set agrupations='|f_es_BMF|' where agrupations ilike '%\_00%'")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201603030510)        
        if self.dbversion<201603030535:
            cur=self.mem.con.cursor()
            cur.execute("update products set agrupations='|f_es_BMF|' where agrupations ilike '%BMF%'")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201603030535)       
        if self.dbversion<201603030541:
            cur=self.mem.con.cursor()
            cur.execute("update products set agrupations='|f_fr_CARMIGNAC|' where agrupations ilike '%CARMIGNAC%'")
            cur.execute("update products set agrupations='|w_fr_SG|' where agrupations ilike '%SGW%'")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201603030541)        
        if self.dbversion<201603210933:
            cur=self.mem.con.cursor()            
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values  (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                (81707, 'Put IBEX 35 | 9000 € | 20/05/16 | F2644',  'LU1298303105', 'EUR', 5, '|w_fr_SG|', None, None, None, None, 100, 'p',1, 1, '', None,  None, None, False))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201603210933)        
        if self.dbversion<201604170750:
            cur=self.mem.con.cursor()            
            cur.execute("alter table dividends alter column fecha set data type timestamp with time zone using fecha  + interval '12 hours'")
            cur.execute("alter table opertarjetas alter column fechapago set data type timestamp with time zone using fechapago  + interval '12 hours'")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201604170750)        
        if self.dbversion<201604220610:
            cur=self.mem.con.cursor()            
            cur.execute("insert into conceptos values(67,'{}',2,false)".format(QApplication.translate("Core","Credit card refund")))     
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201604220610)        
        if self.dbversion<201604240810:
            cur=self.mem.con.cursor()            
            cur.execute("drop index annualtargets_index_year")     
            cur.execute('drop index "conceptos-id_conceptos-index"')     
            cur.execute('drop index "cuentas-id_cuentas-index"')     
            cur.execute('drop index "entidadesbancarias-id_entidadesbancarias-index" cascade')     
            cur.execute('drop index dividendosestimaciones_id')     
            cur.execute('drop index estimaciones_eps')     
            cur.execute('drop index "inversiones-id_inversiones-index"')     
            cur.execute('drop index "opercuentas-id_opercuentas-index"')     
            cur.execute('drop index "operinversiones-id_operinversiones-index"')     
            cur.execute('drop index "opertarjetas-id_opertarjetas-index"')     
            cur.execute('drop index investments_id')     
            cur.execute('ALTER TABLE opercuentasdeoperinversiones ADD CONSTRAINT opercuentasdeoperinversiones_pk PRIMARY KEY (id_opercuentas)')
            cur.execute("ALTER TABLE cuentas ADD CONSTRAINT cuentas_fk_id_entidadesbancarias FOREIGN KEY (id_entidadesbancarias) REFERENCES entidadesbancarias(id_entidadesbancarias) ON UPDATE NO ACTION ON DELETE RESTRICT")
            
            #cuentas_fk_id_entidadesbancarias  
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201604240810)        
        if self.dbversion<201607132000:
            cur=self.mem.con.cursor()            
            cur.execute("""CREATE OR REPLACE FUNCTION create_role_if_not_exists(rolename NAME) RETURNS TEXT AS
$$
BEGIN
    IF NOT EXISTS (SELECT * FROM pg_roles WHERE rolname = rolename) THEN
        EXECUTE format('CREATE ROLE %I', rolename);
        RETURN 'CREATE ROLE';
    ELSE
        RETURN format('ROLE ''%I'' ALREADY EXISTS', rolename);
    END IF;
END;
$$
LANGUAGE plpgsql;""")     
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201607132000)        

        if self.dbversion<201610141057:
            cur=self.mem.con.cursor()                        
            cur.execute("ALTER TABLE operinversiones   ADD COLUMN currency_conversion numeric(10,6) DEFAULT 1")
            cur.execute("UPDATE operinversiones SET currency_conversion=1")
            cur.execute("ALTER TABLE operinversiones  ALTER COLUMN currency_conversion SET NOT NULL")
            cur.execute("COMMENT ON COLUMN operinversiones.currency_conversion IS 'Conversión de divisa de la inversión a la de la cuenta. Multiplicando acciones*valor_accion*currency_conversion obtenemos el precio en la divisa de la cuenta de inversion->cuenta. Los impuestos y la comisión van en la divisa de la cuenta y no necesita conversión.'")

            cur.close()
            self.mem.con.commit()
            self.set_database_version(201610141057)        
        if self.dbversion<201610161057:
            cur=self.mem.con.cursor()                        
            cur.execute("ALTER TABLE dividends ADD COLUMN currency_conversion numeric(10,6) DEFAULT 1")
            cur.execute("UPDATE dividends SET currency_conversion=1")
            cur.execute("ALTER TABLE dividends  ALTER COLUMN currency_conversion SET NOT NULL")
            cur.execute("COMMENT ON COLUMN dividends.currency_conversion IS 'Conversión de divisa del dividendo a la de la cuenta. Bruto, retención, neto y valorxaccion van en la divisa de la inversión. La comisión va en la divisa de la cuenta y no necesita conversión. Para convertir a la divisa de la cuenta gross*currency_conversion'")

            cur.close()
            self.mem.con.commit()
            self.set_database_version(201610161057)                    
        if self.dbversion<201611020740:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81708, 'LYXOR ETF LEVERAGED FTSE MIB', 'FR0010446658  ', 'EUR', 4, '', '', None, None, None, 100, 'c', 2, 6, 'LEVMIB.MI', [1, ],[3, ], None, False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81709, 'LYXOR ETF LEVERAGED CAC 40', 'FR0010592014  ', 'EUR', 4, '', '', None, None, None, 100, 'c', 2, 3, 'LVC.PA', [1, ],[3, ], None, False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81710, 'LYXOR ETF LEVERAGED DAX', 'LU0252634307  ', 'EUR', 4, '', '', None, None, None, 100, 'c', 2, 3, 'LVD.PA', [1, ],[3, ], None, False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611020740)      
        if self.dbversion<201611041030:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81711, 'ULTRA S&P 500 PROSHARES', 'US74347R1077  ', 'USD', 4, '', '', None, None, None, 100, 'c', 2, 2, 'SSO', [1, ],[3, ], None, False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611041030)      
        if self.dbversion<201611101136:
            cur=self.mem.con.cursor()
            cur.execute("delete from quotes where id=81710")
            cur.execute("delete from products where id=81710")
            cur.execute("ALTER TABLE operinversiones  ALTER COLUMN currency_conversion TYPE numeric(30,10)")
            cur.execute("COMMENT ON COLUMN operinversiones.currency_conversion  IS 'Conversión de divisa de la inversión a la de la cuenta. Multiplicando acciones*valor_accion*currency_conversion obtenemos el precio en la divisa de la cuenta de inversion->cuenta. Todos los campos de operinversiones van en la divisa del producto de la inversión'")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611101136)      
        if self.dbversion<201611110750:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81712, 'PROSHARES ULTRA QQQ', 'US74347R2067  ', 'USD', 4, '', '', None, None, None, 100, 'c', 2, 2, 'QLD', [1, ],[3, ], None, False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81713, 'PROSHARES ULTRA DOW30', 'US74347R3057  ', 'USD', 4, '', '', None, None, None, 100, 'c', 2, 2, 'DDM', [1, ],[3, ], None, False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81714, 'PROSHARES ULTRA RUSSELL2000', 'US74347R3057  ', 'USD', 4, '', '', None, None, None, 100, 'c', 2, 2, 'UWM', [1, ],[3, ], None, False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611110750)      
            
        if self.dbversion<201611270750:##Transfer comments migration
            cur=self.mem.con.cursor()
            cur.execute("select id_opercuentas, comentario from opercuentas where id_tiposoperaciones=3 and comentario like ('%|%') order by datetime")
            for row in cur:
                split=row["comentario"].split("|")
                if len(split)==3:#SOLO ORIGENES
                    aoo=row
                    aod=self.mem.con.cursor_one_row("select id_opercuentas, comentario from opercuentas where id_opercuentas=%s", (int(split[1]), ))
                    aoc=self.mem.con.cursor_one_row("select id_opercuentas, comentario from opercuentas where id_opercuentas=%s", (int(split[2]), ))
                    print("==================")
                    
                    if aoc==None:
                        operaccountorigincomission_id=-1
                    else:
                        operaccountorigincomission_id=aoc["id_opercuentas"]
                    c1="10001,{},{},{}".format(aoo['id_opercuentas'], aod['id_opercuentas'], operaccountorigincomission_id)        
                    c2="10002,{},{},{}".format(aoo['id_opercuentas'], aod['id_opercuentas'], operaccountorigincomission_id)        
                    c3="10003,{},{},{}".format(aoo['id_opercuentas'], aod['id_opercuentas'], operaccountorigincomission_id)        
                    print ("Origin: {} ==> {}".format(aoo['comentario'], c1))
                    print("Destiny: {} ==> {}".format(aod['comentario'], c2))
                    if aoc!=None:
                        print("Comision: {} ==> {}".format(aoc['comentario'], c3))
                    
                    curcommit=self.mem.con.cursor()
                    curcommit.execute("update opercuentas set comentario='{}' where id_opercuentas={}".format(c1, aoo['id_opercuentas']))
                    curcommit.execute("update opercuentas set comentario='{}' where id_opercuentas={}".format(c2, aod['id_opercuentas']))
                    if aoc!=None:
                        curcommit.execute("update opercuentas set comentario='{}' where id_opercuentas={}".format(c3, aoc['id_opercuentas']))
                    curcommit.close()
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611270750)                  
            
        if self.dbversion<201611271250:##Updates dividends operaccount comment
            cur=self.mem.con.cursor()
            cur.execute("select * from dividends")
            for row in cur:
                cur2=self.mem.con.cursor()
                cur2.execute("update opercuentas set comentario=%s where id_opercuentas=%s", ("10004,{}".format(row['id_dividends']), row['id_opercuentas']))
                cur2.close()
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611271250)      
                
            
        if self.dbversion<201611271315:##Updates dividends operaccount comment
            cur=self.mem.con.cursor()
            cur.execute("select * from opercuentasdeoperinversiones")
            for row in cur:
                cur2=self.mem.con.cursor()
                cur2.execute("update opercuentasdeoperinversiones set comentario=%s where id_opercuentas=%s", ("10000,{}".format(row['id_operinversiones']), row['id_opercuentas']))
                cur2.close()
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611271315)    
            
        if self.dbversion<201611271815:##Updates dividends operaccount comment
            cur=self.mem.con.cursor()
            cur.execute("select distinct(id_opercuentas),id_tarjetas from opertarjetas where fechapago is not null  order by id_opercuentas;")
            for row in cur:
                cur2=self.mem.con.cursor()
                cur2.execute("update opercuentas set comentario=%s where id_opercuentas=%s", ("10005,{},{}".format(row['id_tarjetas'], row['id_opercuentas']), row['id_opercuentas']))
                cur2.close()
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201611271815)      
            
        if self.dbversion<201701140654:
            cur=self.mem.con.cursor()
            cur.execute("delete from globals where id_globals=6")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201701140654)      
                        
        if self.dbversion<201701140716:
            cur=self.mem.con.cursor()
            cur.execute("UPDATE products SET ticker='F0GBR04JLT' WHERE id=78089;")
            cur.execute("UPDATE products SET ticker='F000001W2L' WHERE id=74751;")
            cur.execute("UPDATE products SET ticker='F0GBR04MZH' WHERE id=78173;")
            cur.execute("UPDATE products SET ticker='F0GBR04MZD' WHERE id=75162;")
            cur.execute("UPDATE products SET ticker='F0GBR05WNU' WHERE id=78181;")
            cur.execute("UPDATE products SET ticker='F0000040M3' WHERE id=78139;")
            cur.execute("UPDATE products SET ticker='F0GBR04H3S' WHERE id=75812;")
            cur.execute("UPDATE products SET ticker='F0000040M2' WHERE id=78141;")
            cur.execute("UPDATE products SET ticker='F0GBR05WOC' WHERE id=75001;")
            cur.execute("UPDATE products SET ticker='F000005ODZ' WHERE id=78143;")
            cur.execute("UPDATE products SET ticker='F0GBR04GCF' WHERE id=78144;")
            cur.execute("UPDATE products SET ticker='F0GBR04MZJ' WHERE id=78184;")
            cur.execute("UPDATE products SET ticker='F0GBR04MZB' WHERE id=78188;")
            cur.execute("UPDATE products SET ticker='F0GBR04OMT' WHERE id=78189;")
            cur.execute("UPDATE products SET ticker='F00000M9L3' WHERE id=78191;")
            cur.execute("UPDATE products SET ticker='F00000M9L5' WHERE id=78195;")
            cur.execute("UPDATE products SET ticker='F00000M9L4' WHERE id=78210;")
            cur.execute("UPDATE products SET ticker='F000000RI9' WHERE id=78229;")
            cur.execute("UPDATE products SET ticker='F000000GQ1' WHERE id=78235;")
            cur.execute("UPDATE products SET ticker='F000000GQ0' WHERE id=78237;")
            cur.execute("UPDATE products SET ticker='F0GBR04DUC' WHERE id=74784;")
            cur.execute("UPDATE products SET ticker='F0GBR04QAW' WHERE id=78316;")
            cur.execute("UPDATE products SET ticker='F0GBR04PU1' WHERE id=78317;")
            cur.execute("UPDATE products SET ticker='F000001GJA' WHERE id=78091;")
            cur.execute("UPDATE products SET ticker='F0GBR04DTU' WHERE id=78318;")
            cur.execute("UPDATE products SET ticker='F0GBR04DU6' WHERE id=78403;")
            cur.execute("UPDATE products SET ticker='F0GBR04DUL' WHERE id=78418;")
            cur.execute("UPDATE products SET ticker='F0GBR04DUZ' WHERE id=78450;")
            cur.execute("UPDATE products SET ticker='F0GBR0557F' WHERE id=78485;")
            cur.execute("UPDATE products SET ticker='F0000001UH' WHERE id=78463;")
            cur.execute("UPDATE products SET ticker='F0GBR06U3E' WHERE id=78530;")
            cur.execute("UPDATE products SET ticker='F0GBR04DVB' WHERE id=75443;")
            cur.execute("UPDATE products SET ticker='F0GBR04J02' WHERE id=75460;")
            cur.execute("UPDATE products SET ticker='F0GBR04J04' WHERE id=75431;")
            cur.execute("UPDATE products SET ticker='F0GBR04J06' WHERE id=75433;")
            cur.execute("UPDATE products SET ticker='F0GBR04J01' WHERE id=78595;")
            cur.execute("UPDATE products SET ticker='F0GBR05V3B' WHERE id=77099;")
            cur.execute("UPDATE products SET ticker='F0GBR04DIV' WHERE id=77329;")
            cur.execute("UPDATE products SET ticker='F000002JPP' WHERE id=74819;")
            cur.execute("UPDATE products SET ticker='F00000J75P' WHERE id=74958;")
            cur.execute("UPDATE products SET ticker='F00000GZW2' WHERE id=78611;")
            cur.execute("UPDATE products SET ticker='F0GBR04K0I' WHERE id=76596;")
            cur.execute("UPDATE products SET ticker='F0GBR04KJ8' WHERE id=75814;")
            cur.execute("UPDATE products SET ticker='F0GBR04K0E' WHERE id=75288;")
            cur.execute("UPDATE products SET ticker='F0GBR04OOF' WHERE id=75291;")
            cur.execute("UPDATE products SET ticker='F00000J3T4' WHERE id=77427;")
            cur.execute("UPDATE products SET ticker='F00000LL48' WHERE id=75190;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4H' WHERE id=78654;")
            cur.execute("UPDATE products SET ticker='F00000JYM0' WHERE id=78656;")
            cur.execute("UPDATE products SET ticker='F0GBR04PY3' WHERE id=78660;")
            cur.execute("UPDATE products SET ticker='F0GBR04J5K' WHERE id=78661;")
            cur.execute("UPDATE products SET ticker='F0GBR04JK5' WHERE id=75437;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITP' WHERE id=75498;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITL' WHERE id=75499;")
            cur.execute("UPDATE products SET ticker='F0GBR0601D' WHERE id=75801;")
            cur.execute("UPDATE products SET ticker='F0GBR04IUB' WHERE id=78692;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITR' WHERE id=78694;")
            cur.execute("UPDATE products SET ticker='F0GBR04IU9' WHERE id=78695;")
            cur.execute("UPDATE products SET ticker='F0GBR04IUF' WHERE id=78696;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITN' WHERE id=76655;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITX' WHERE id=76641;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITZ' WHERE id=76654;")
            cur.execute("UPDATE products SET ticker='F000000PWZ' WHERE id=74908;")
            cur.execute("UPDATE products SET ticker='F0GBR0614W' WHERE id=75624;")
            cur.execute("UPDATE products SET ticker='F000000PX0' WHERE id=75835;")
            cur.execute("UPDATE products SET ticker='F00000MAA1' WHERE id=75844;")
            cur.execute("UPDATE products SET ticker='F0GBR06155' WHERE id=75853;")
            cur.execute("UPDATE products SET ticker='F000000PX1' WHERE id=74827;")
            cur.execute("UPDATE products SET ticker='F000002L68' WHERE id=76656;")
            cur.execute("UPDATE products SET ticker='F0GBR04CAH' WHERE id=76657;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYA' WHERE id=75558;")
            cur.execute("UPDATE products SET ticker='F00000H0P4' WHERE id=74855;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYE' WHERE id=76704;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYK' WHERE id=76888;")
            cur.execute("UPDATE products SET ticker='F00000H0P5' WHERE id=76746;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYG' WHERE id=76787;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYI' WHERE id=76789;")
            cur.execute("UPDATE products SET ticker='F00000H0P6' WHERE id=76793;")
            cur.execute("UPDATE products SET ticker='F00000JO2S' WHERE id=74936;")
            cur.execute("UPDATE products SET ticker='F0GBR06U7J' WHERE id=76847;")
            cur.execute("UPDATE products SET ticker='F0GBR054EX' WHERE id=78470;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q3Z' WHERE id=75044;")
            cur.execute("UPDATE products SET ticker='F0GBR04E18' WHERE id=75091;")
            cur.execute("UPDATE products SET ticker='F0GBR04FMA' WHERE id=75530;")
            cur.execute("UPDATE products SET ticker='F00000201H' WHERE id=75542;")
            cur.execute("UPDATE products SET ticker='F0GBR04E16' WHERE id=75939;")
            cur.execute("UPDATE products SET ticker='F0GBR04K0C' WHERE id=75941;")
            cur.execute("UPDATE products SET ticker='F0GBR04PZJ' WHERE id=78538;")
            cur.execute("UPDATE products SET ticker='F0GBR04IT1' WHERE id=78878;")
            cur.execute("UPDATE products SET ticker='F0GBR04IT3' WHERE id=78879;")
            cur.execute("UPDATE products SET ticker='F0GBR04JWM' WHERE id=78884;")
            cur.execute("UPDATE products SET ticker='F0GBR04JSF' WHERE id=77050;")
            cur.execute("UPDATE products SET ticker='F0GBR04IT9' WHERE id=77060;")
            cur.execute("UPDATE products SET ticker='F0GBR053VD' WHERE id=77061;")
            cur.execute("UPDATE products SET ticker='F0GBR04PYP' WHERE id=77102;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8J' WHERE id=77118;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q99' WHERE id=77186;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8B' WHERE id=80638;")
            cur.execute("UPDATE products SET ticker='F0GBR05RJH' WHERE id=77195;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8F' WHERE id=76851;")
            cur.execute("UPDATE products SET ticker='F0GBR04F91' WHERE id=77199;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q98' WHERE id=75580;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8W' WHERE id=77203;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8C' WHERE id=75581;")
            cur.execute("UPDATE products SET ticker='F0GBR05UYB' WHERE id=76852;")
            cur.execute("UPDATE products SET ticker='F0GBR04D4J' WHERE id=75630;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6Z' WHERE id=75636;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9D' WHERE id=78747;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7L' WHERE id=75993;")
            cur.execute("UPDATE products SET ticker='F000002942' WHERE id=77856;")
            cur.execute("UPDATE products SET ticker='F0GBR04C9Z' WHERE id=80881;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9K' WHERE id=76916;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9G' WHERE id=76917;")
            cur.execute("UPDATE products SET ticker='F00000259E' WHERE id=77882;")
            cur.execute("UPDATE products SET ticker='F000000H7G' WHERE id=77240;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6X' WHERE id=75677;")
            cur.execute("UPDATE products SET ticker='F00000NO7O' WHERE id=74765;")
            cur.execute("UPDATE products SET ticker='F0GBR04H3Q' WHERE id=76049;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9C' WHERE id=80230;")
            cur.execute("UPDATE products SET ticker='F0GBR04CEW' WHERE id=76456;")
            cur.execute("UPDATE products SET ticker='F0GBR04CEY' WHERE id=76289;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9V' WHERE id=76892;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9Y' WHERE id=78969;")
            cur.execute("UPDATE products SET ticker='F000001WP9' WHERE id=78970;")
            cur.execute("UPDATE products SET ticker='F0GBR04QAD' WHERE id=76457;")
            cur.execute("UPDATE products SET ticker='F0GBR04QAF' WHERE id=76094;")
            cur.execute("UPDATE products SET ticker='F000005HCT' WHERE id=76061;")
            cur.execute("UPDATE products SET ticker='F0GBR04QAX' WHERE id=76133;")
            cur.execute("UPDATE products SET ticker='F0GBR04PTM' WHERE id=76417;")
            cur.execute("UPDATE products SET ticker='F0GBR04PTH' WHERE id=77282;")
            cur.execute("UPDATE products SET ticker='F0GBR04QAT' WHERE id=76249;")
            cur.execute("UPDATE products SET ticker='F0GBR04EJ4' WHERE id=76302;")
            cur.execute("UPDATE products SET ticker='F0GBR04OMM' WHERE id=76304;")
            cur.execute("UPDATE products SET ticker='F0GBR04OMI' WHERE id=76305;")
            cur.execute("UPDATE products SET ticker='F0GBR04OMO' WHERE id=77287;")
            cur.execute("UPDATE products SET ticker='F0GBR04J3X' WHERE id=77289;")
            cur.execute("UPDATE products SET ticker='F0GBR04QB5' WHERE id=76314;")
            cur.execute("UPDATE products SET ticker='F0GBR04JQB' WHERE id=76316;")
            cur.execute("UPDATE products SET ticker='F00000GX37' WHERE id=77244;")
            cur.execute("UPDATE products SET ticker='F0GBR04PS4' WHERE id=77245;")
            cur.execute("UPDATE products SET ticker='F0GBR04PS2' WHERE id=77260;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRY' WHERE id=77330;")
            cur.execute("UPDATE products SET ticker='F0GBR04PS0' WHERE id=77298;")
            cur.execute("UPDATE products SET ticker='F0GBR04PS1' WHERE id=77308;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRZ' WHERE id=77309;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSE' WHERE id=77310;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4T' WHERE id=77460;")
            cur.execute("UPDATE products SET ticker='F0GBR04VUC' WHERE id=77311;")
            cur.execute("UPDATE products SET ticker='F0GBR05XPV' WHERE id=77331;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSD' WHERE id=77333;")
            cur.execute("UPDATE products SET ticker='F0GBR04PS3' WHERE id=77336;")
            cur.execute("UPDATE products SET ticker='F000003Z6F' WHERE id=76470;")
            cur.execute("UPDATE products SET ticker='F0GBR04JPK' WHERE id=77404;")
            cur.execute("UPDATE products SET ticker='F0GBR04LS8' WHERE id=76506;")
            cur.execute("UPDATE products SET ticker='F000003VX7' WHERE id=76543;")
            cur.execute("UPDATE products SET ticker='F0GBR04OMU' WHERE id=76544;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRX' WHERE id=77406;")
            cur.execute("UPDATE products SET ticker='F0GBR04PS7' WHERE id=77441;")
            cur.execute("UPDATE products SET ticker='F0GBR04PS6' WHERE id=77459;")
            cur.execute("UPDATE products SET ticker='F00000GX38' WHERE id=77443;")
            cur.execute("UPDATE products SET ticker='F0GBR05XPU' WHERE id=77469;")
            cur.execute("UPDATE products SET ticker='F00000GX39' WHERE id=77523;")
            cur.execute("UPDATE products SET ticker='F0GBR05TU6' WHERE id=77526;")
            cur.execute("UPDATE products SET ticker='F000000H7H' WHERE id=77539;")
            cur.execute("UPDATE products SET ticker='F0GBR04GSO' WHERE id=77542;")
            cur.execute("UPDATE products SET ticker='F0GBR04D50' WHERE id=77575;")
            cur.execute("UPDATE products SET ticker='F0GBR04D6K' WHERE id=77592;")
            cur.execute("UPDATE products SET ticker='F0GBR04G3T' WHERE id=76050;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7F' WHERE id=76013;")
            cur.execute("UPDATE products SET ticker='F0GBR05T5Q' WHERE id=76021;")
            cur.execute("UPDATE products SET ticker='F000000JPZ' WHERE id=76023;")
            cur.execute("UPDATE products SET ticker='F0GBR04ZL1' WHERE id=77630;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7H' WHERE id=77631;")
            cur.execute("UPDATE products SET ticker='F0GBR04ZL6' WHERE id=77632;")
            cur.execute("UPDATE products SET ticker='F0GBR04CLX' WHERE id=77633;")
            cur.execute("UPDATE products SET ticker='F0GBR051Q4' WHERE id=77649;")
            cur.execute("UPDATE products SET ticker='F0GBR04G2L' WHERE id=76370;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8M' WHERE id=76374;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q83' WHERE id=77656;")
            cur.execute("UPDATE products SET ticker='F000000374' WHERE id=77658;")
            cur.execute("UPDATE products SET ticker='F0GBR04LEY' WHERE id=77663;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q76' WHERE id=77664;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q85' WHERE id=76026;")
            cur.execute("UPDATE products SET ticker='F0GBR04CU5' WHERE id=76377;")
            cur.execute("UPDATE products SET ticker='F00000H4VI' WHERE id=77677;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8O' WHERE id=77678;")
            cur.execute("UPDATE products SET ticker='F0GBR04ZKV' WHERE id=77683;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7A' WHERE id=77684;")
            cur.execute("UPDATE products SET ticker='F000000JX1' WHERE id=77686;")
            cur.execute("UPDATE products SET ticker='F0GBR04CLV' WHERE id=77691;")
            cur.execute("UPDATE products SET ticker='F000000AS3' WHERE id=77701;")
            cur.execute("UPDATE products SET ticker='F000002L66' WHERE id=77740;")
            cur.execute("UPDATE products SET ticker='F0GBR04EQ3' WHERE id=77770;")
            cur.execute("UPDATE products SET ticker='F0GBR05SLE' WHERE id=77772;")
            cur.execute("UPDATE products SET ticker='F00000GUYC' WHERE id=77785;")
            cur.execute("UPDATE products SET ticker='F0000026D1' WHERE id=77814;")
            cur.execute("UPDATE products SET ticker='F0GBR051T6' WHERE id=78888;")
            cur.execute("UPDATE products SET ticker='F0GBR04CP3' WHERE id=77815;")
            cur.execute("UPDATE products SET ticker='F0GBR04D5E' WHERE id=77905;")
            cur.execute("UPDATE products SET ticker='F0GBR04ZMK' WHERE id=77957;")
            cur.execute("UPDATE products SET ticker='F0GBR04MO2' WHERE id=76612;")
            cur.execute("UPDATE products SET ticker='F0GBR05T5R' WHERE id=76613;")
            cur.execute("UPDATE products SET ticker='F0GBR04O1K' WHERE id=76378;")
            cur.execute("UPDATE products SET ticker='F000000376' WHERE id=76614;")
            cur.execute("UPDATE products SET ticker='F000002L64' WHERE id=75760;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9N' WHERE id=75390;")
            cur.execute("UPDATE products SET ticker='F0GBR04EQB' WHERE id=76068;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q95' WHERE id=76072;")
            cur.execute("UPDATE products SET ticker='F0000021KT' WHERE id=76380;")
            cur.execute("UPDATE products SET ticker='F000000H6R' WHERE id=76137;")
            cur.execute("UPDATE products SET ticker='F000005OJQ' WHERE id=76145;")
            cur.execute("UPDATE products SET ticker='F00000H6L5' WHERE id=74858;")
            cur.execute("UPDATE products SET ticker='F0GBR04ZLI' WHERE id=77872;")
            cur.execute("UPDATE products SET ticker='F0GBR04LF0' WHERE id=78145;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8Y' WHERE id=76189;")
            cur.execute("UPDATE products SET ticker='F0000001TD' WHERE id=77357;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9H' WHERE id=76198;")
            cur.execute("UPDATE products SET ticker='F0000024PW' WHERE id=77358;")
            cur.execute("UPDATE products SET ticker='F0GBR04OMQ' WHERE id=76199;")
            cur.execute("UPDATE products SET ticker='F0GBR05WLU' WHERE id=78198;")
            cur.execute("UPDATE products SET ticker='F0GBR054LI' WHERE id=77912;")
            cur.execute("UPDATE products SET ticker='F0GBR055FL' WHERE id=77967;")
            cur.execute("UPDATE products SET ticker='F0GBR05SL1' WHERE id=77971;")
            cur.execute("UPDATE products SET ticker='F0000006Q9' WHERE id=76237;")
            cur.execute("UPDATE products SET ticker='F00000LYYC' WHERE id=78249;")
            cur.execute("UPDATE products SET ticker='F0GBR04CUP' WHERE id=78707;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q93' WHERE id=78242;")
            cur.execute("UPDATE products SET ticker='F0GBR04VUU' WHERE id=78250;")
            cur.execute("UPDATE products SET ticker='F0GBR051Q9' WHERE id=78288;")
            cur.execute("UPDATE products SET ticker='F000003WYP' WHERE id=76320;")
            cur.execute("UPDATE products SET ticker='F00000LZ24' WHERE id=76321;")
            cur.execute("UPDATE products SET ticker='F00000GWPE' WHERE id=76322;")
            cur.execute("UPDATE products SET ticker='F0GBR0526F' WHERE id=79406;")
            cur.execute("UPDATE products SET ticker='F00000MABH' WHERE id=78740;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSV' WHERE id=78323;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSZ' WHERE id=78324;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSY' WHERE id=78330;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSX' WHERE id=78719;")
            cur.execute("UPDATE products SET ticker='F0GBR04ISV' WHERE id=77461;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSW' WHERE id=78331;")
            cur.execute("UPDATE products SET ticker='F00000MABJ' WHERE id=78741;")
            cur.execute("UPDATE products SET ticker='F00000MABI' WHERE id=78263;")
            cur.execute("UPDATE products SET ticker='F0000001TO' WHERE id=78319;")
            cur.execute("UPDATE products SET ticker='F0GBR04CB7' WHERE id=76667;")
            cur.execute("UPDATE products SET ticker='F000000ASF' WHERE id=78355;")
            cur.execute("UPDATE products SET ticker='F0GBR04JVG' WHERE id=78004;")
            cur.execute("UPDATE products SET ticker='F00000JODJ' WHERE id=78720;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6N' WHERE id=78459;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6U' WHERE id=78493;")
            cur.execute("UPDATE products SET ticker='F0GBR04C9T' WHERE id=77880;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7I' WHERE id=76421;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8S' WHERE id=75063;")
            cur.execute("UPDATE products SET ticker='F0GBR04C9X' WHERE id=80877;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9A' WHERE id=80878;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9E' WHERE id=75417;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9I' WHERE id=76623;")
            cur.execute("UPDATE products SET ticker='F0GBR04D6A' WHERE id=78380;")
            cur.execute("UPDATE products SET ticker='F0GBR05VCL' WHERE id=78721;")
            cur.execute("UPDATE products SET ticker='F0GBR04BYV' WHERE id=78742;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6L' WHERE id=77477;")
            cur.execute("UPDATE products SET ticker='F0GBR05WO1' WHERE id=77482;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6Q' WHERE id=78754;")
            cur.execute("UPDATE products SET ticker='F0GBR04K3O' WHERE id=78577;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q90' WHERE id=75127;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6O' WHERE id=78579;")
            cur.execute("UPDATE products SET ticker='F000003YGO' WHERE id=76670;")
            cur.execute("UPDATE products SET ticker='F0GBR04CA1' WHERE id=76674;")
            cur.execute("UPDATE products SET ticker='F0GBR04IVX' WHERE id=79408;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2M' WHERE id=79444;")
            cur.execute("UPDATE products SET ticker='F0GBR04CXN' WHERE id=75128;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2P' WHERE id=76675;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2O' WHERE id=77556;")
            cur.execute("UPDATE products SET ticker='F0GBR04IW1' WHERE id=77557;")
            cur.execute("UPDATE products SET ticker='F0GBR04IW5' WHERE id=79449;")
            cur.execute("UPDATE products SET ticker='F0GBR04IVV' WHERE id=79420;")
            cur.execute("UPDATE products SET ticker='F0GBR04IWN' WHERE id=77558;")
            cur.execute("UPDATE products SET ticker='F0GBR04KWY' WHERE id=76676;")
            cur.execute("UPDATE products SET ticker='F0GBR04IWB' WHERE id=75131;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONL' WHERE id=76713;")
            cur.execute("UPDATE products SET ticker='F0GBR04IWF' WHERE id=76714;")
            cur.execute("UPDATE products SET ticker='F0GBR04IWP' WHERE id=78546;")
            cur.execute("UPDATE products SET ticker='F0GBR04IWL' WHERE id=76716;")
            cur.execute("UPDATE products SET ticker='F0GBR04DN6' WHERE id=76723;")
            cur.execute("UPDATE products SET ticker='F0GBR04DN8' WHERE id=76686;")
            cur.execute("UPDATE products SET ticker='F000000EBM' WHERE id=77609;")
            cur.execute("UPDATE products SET ticker='F000000H75' WHERE id=76688;")
            cur.execute("UPDATE products SET ticker='F000000H76' WHERE id=75144;")
            cur.execute("UPDATE products SET ticker='F00000HLG8' WHERE id=76795;")
            cur.execute("UPDATE products SET ticker='F0GBR04EOT' WHERE id=76692;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4J' WHERE id=78547;")
            cur.execute("UPDATE products SET ticker='F0GBR04DVJ' WHERE id=78624;")
            cur.execute("UPDATE products SET ticker='F0000003K6' WHERE id=78665;")
            cur.execute("UPDATE products SET ticker='F0GBR04DVT' WHERE id=76710;")
            cur.execute("UPDATE products SET ticker='F0GBR04HLW' WHERE id=79062;")
            cur.execute("UPDATE products SET ticker='F0GBR051OD' WHERE id=78007;")
            cur.execute("UPDATE products SET ticker='F0GBR04VY2' WHERE id=78009;")
            cur.execute("UPDATE products SET ticker='F0GBR051OG' WHERE id=78012;")
            cur.execute("UPDATE products SET ticker='F0000002NG' WHERE id=77088;")
            cur.execute("UPDATE products SET ticker='F0GBR04GIO' WHERE id=78807;")
            cur.execute("UPDATE products SET ticker='F0GBR04DW1' WHERE id=77262;")
            cur.execute("UPDATE products SET ticker='F000001GFB' WHERE id=78831;")
            cur.execute("UPDATE products SET ticker='F0000001U0' WHERE id=78843;")
            cur.execute("UPDATE products SET ticker='F0GBR04DW7' WHERE id=77266;")
            cur.execute("UPDATE products SET ticker='F000001BP2' WHERE id=75218;")
            cur.execute("UPDATE products SET ticker='FOGBR05KSA' WHERE id=78672;")
            cur.execute("UPDATE products SET ticker='FOGBR05KSB' WHERE id=78673;")
            cur.execute("UPDATE products SET ticker='F0GBR0553Y' WHERE id=78921;")
            cur.execute("UPDATE products SET ticker='F0GBR04VTA' WHERE id=79601;")
            cur.execute("UPDATE products SET ticker='F000002VED' WHERE id=75119;")
            cur.execute("UPDATE products SET ticker='F000005J8O' WHERE id=74868;")
            cur.execute("UPDATE products SET ticker='F0000044BL' WHERE id=74795;")
            cur.execute("UPDATE products SET ticker='F0GBR04K16' WHERE id=74961;")
            cur.execute("UPDATE products SET ticker='F0GBR055TB' WHERE id=78889;")
            cur.execute("UPDATE products SET ticker='F0GBR0563E' WHERE id=78890;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1A' WHERE id=74969;")
            cur.execute("UPDATE products SET ticker='F0GBR04VUB' WHERE id=78892;")
            cur.execute("UPDATE products SET ticker='F00000JZBB' WHERE id=74987;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1G' WHERE id=76030;")
            cur.execute("UPDATE products SET ticker='F0GBR0601C' WHERE id=74991;")
            cur.execute("UPDATE products SET ticker='F0GBR04GCH' WHERE id=78894;")
            cur.execute("UPDATE products SET ticker='F0GBR04K0O' WHERE id=78895;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGL' WHERE id=74995;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6F' WHERE id=74797;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGN' WHERE id=74799;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGO' WHERE id=75064;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGT' WHERE id=75191;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGV' WHERE id=75219;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGX' WHERE id=75220;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGZ' WHERE id=77008;")
            cur.execute("UPDATE products SET ticker='F0GBR04CH1' WHERE id=78666;")
            cur.execute("UPDATE products SET ticker='F0GBR04CH8' WHERE id=77009;")
            cur.execute("UPDATE products SET ticker='F0GBR04OND' WHERE id=77014;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q72' WHERE id=76509;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q73' WHERE id=76997;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONF' WHERE id=76508;")
            cur.execute("UPDATE products SET ticker='F0GBR04CHC' WHERE id=76510;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6K' WHERE id=76517;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6H' WHERE id=76998;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGQ' WHERE id=77001;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6G' WHERE id=77017;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6J' WHERE id=77021;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q75' WHERE id=77069;")
            cur.execute("UPDATE products SET ticker='F0GBR04CH4' WHERE id=79317;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONH' WHERE id=78667;")
            cur.execute("UPDATE products SET ticker='F0GBR04CGS' WHERE id=77075;")
            cur.execute("UPDATE products SET ticker='F0GBR04CH6' WHERE id=75222;")
            cur.execute("UPDATE products SET ticker='F0GBR04D4B' WHERE id=75120;")
            cur.execute("UPDATE products SET ticker='F0GBR06QXF' WHERE id=76552;")
            cur.execute("UPDATE products SET ticker='F0GBR06QXH' WHERE id=79363;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZW' WHERE id=77122;")
            cur.execute("UPDATE products SET ticker='F0GBR056L1' WHERE id=77123;")
            cur.execute("UPDATE products SET ticker='F0GBR05WO0' WHERE id=78938;")
            cur.execute("UPDATE products SET ticker='F0GBR064XT' WHERE id=77135;")
            cur.execute("UPDATE products SET ticker='F0GBR064XP' WHERE id=78710;")
            cur.execute("UPDATE products SET ticker='F0GBR06XID' WHERE id=75300;")
            cur.execute("UPDATE products SET ticker='F0GBR04IU7' WHERE id=79650;")
            cur.execute("UPDATE products SET ticker='F0GBR06U7O' WHERE id=79651;")
            cur.execute("UPDATE products SET ticker='F0GBR06U7E' WHERE id=74869;")
            cur.execute("UPDATE products SET ticker='F0GBR06U7F' WHERE id=79652;")
            cur.execute("UPDATE products SET ticker='F0GBR05SJK' WHERE id=79653;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITV' WHERE id=79665;")
            cur.execute("UPDATE products SET ticker='F00000J4AN' WHERE id=79666;")
            cur.execute("UPDATE products SET ticker='F0GBR04EJ6' WHERE id=79672;")
            cur.execute("UPDATE products SET ticker='F0GBR04PVB' WHERE id=77920;")
            cur.execute("UPDATE products SET ticker='F0GBR04PW1' WHERE id=77136;")
            cur.execute("UPDATE products SET ticker='F0GBR04J68' WHERE id=79757;")
            cur.execute("UPDATE products SET ticker='F0GBR04J5W' WHERE id=79791;")
            cur.execute("UPDATE products SET ticker='F000001V1S' WHERE id=81480;")
            cur.execute("UPDATE products SET ticker='F0GBR04GUI' WHERE id=81454;")
            cur.execute("UPDATE products SET ticker='F0GBR04F8H' WHERE id=75236;")
            cur.execute("UPDATE products SET ticker='F0GBR04F8J' WHERE id=81477;")
            cur.execute("UPDATE products SET ticker='F000001EWH' WHERE id=81452;")
            cur.execute("UPDATE products SET ticker='F00000MK7J' WHERE id=81460;")
            cur.execute("UPDATE products SET ticker='F00000MK7K' WHERE id=81461;")
            cur.execute("UPDATE products SET ticker='F0GBR04F8U' WHERE id=81476;")
            cur.execute("UPDATE products SET ticker='F0GBR04F8W' WHERE id=81463;")
            cur.execute("UPDATE products SET ticker='F000001EWI' WHERE id=81478;")
            cur.execute("UPDATE products SET ticker='F0GBR04NSH' WHERE id=81474;")
            cur.execute("UPDATE products SET ticker='F000000KBH' WHERE id=81475;")
            cur.execute("UPDATE products SET ticker='F0GBR04F8Y' WHERE id=81472;")
            cur.execute("UPDATE products SET ticker='FOGBR05K5G' WHERE id=81473;")
            cur.execute("UPDATE products SET ticker='F0GBR04F90' WHERE id=81458;")
            cur.execute("UPDATE products SET ticker='FOGBR05K5H' WHERE id=81459;")
            cur.execute("UPDATE products SET ticker='F0GBR04IC2' WHERE id=78066;")
            cur.execute("UPDATE products SET ticker='F0GBR04IC6' WHERE id=78788;")
            cur.execute("UPDATE products SET ticker='F0GBR04F92' WHERE id=78036;")
            cur.execute("UPDATE products SET ticker='F0GBR04F94' WHERE id=81479;")
            cur.execute("UPDATE products SET ticker='F0GBR04OQ3' WHERE id=79840;")
            cur.execute("UPDATE products SET ticker='F0GBR04OQ5' WHERE id=79841;")
            cur.execute("UPDATE products SET ticker='F0GBR04OQB' WHERE id=79858;")
            cur.execute("UPDATE products SET ticker='F0GBR04OQ9' WHERE id=79860;")
            cur.execute("UPDATE products SET ticker='F0GBR04KXK' WHERE id=79863;")
            cur.execute("UPDATE products SET ticker='F0GBR04O24' WHERE id=79870;")
            cur.execute("UPDATE products SET ticker='F0GBR04J64' WHERE id=79871;")
            cur.execute("UPDATE products SET ticker='F0GBR04VSW' WHERE id=77137;")
            cur.execute("UPDATE products SET ticker='F0GBR04VSJ' WHERE id=77139;")
            cur.execute("UPDATE products SET ticker='F0GBR04FD4' WHERE id=77140;")
            cur.execute("UPDATE products SET ticker='F00000064Z' WHERE id=77142;")
            cur.execute("UPDATE products SET ticker='F0GBR04FD6' WHERE id=77212;")
            cur.execute("UPDATE products SET ticker='F0GBR04FD8' WHERE id=78941;")
            cur.execute("UPDATE products SET ticker='F0GBR04VY1' WHERE id=78849;")
            cur.execute("UPDATE products SET ticker='F00000JZBD' WHERE id=76422;")
            cur.execute("UPDATE products SET ticker='F0GBR04IX2' WHERE id=76425;")
            cur.execute("UPDATE products SET ticker='F0GBR04IX6' WHERE id=78914;")
            cur.execute("UPDATE products SET ticker='F000000H6P' WHERE id=79880;")
            cur.execute("UPDATE products SET ticker='F0GBR04IZK' WHERE id=79904;")
            cur.execute("UPDATE products SET ticker='F0GBR06UBE' WHERE id=77214;")
            cur.execute("UPDATE products SET ticker='F0GBR04DNI' WHERE id=77217;")
            cur.execute("UPDATE products SET ticker='F000000KQ6' WHERE id=78940;")
            cur.execute("UPDATE products SET ticker='F000000KS9' WHERE id=78944;")
            cur.execute("UPDATE products SET ticker='F0GBR06014' WHERE id=75168;")
            cur.execute("UPDATE products SET ticker='F0GBR04IXW' WHERE id=79924;")
            cur.execute("UPDATE products SET ticker='F0GBR0557D' WHERE id=79930;")
            cur.execute("UPDATE products SET ticker='F0GBR04IY2' WHERE id=79942;")
            cur.execute("UPDATE products SET ticker='F0GBR05KOR' WHERE id=79973;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6E' WHERE id=79977;")
            cur.execute("UPDATE products SET ticker='F0GBR04IXY' WHERE id=79978;")
            cur.execute("UPDATE products SET ticker='F0GBR05WO7' WHERE id=79986;")
            cur.execute("UPDATE products SET ticker='F0GBR04IZE' WHERE id=79989;")
            cur.execute("UPDATE products SET ticker='F0GBR04IZ4' WHERE id=79993;")
            cur.execute("UPDATE products SET ticker='F0GBR04LEW' WHERE id=79994;")
            cur.execute("UPDATE products SET ticker='F0GBR04IZ6' WHERE id=78976;")
            cur.execute("UPDATE products SET ticker='F0GBR04IZO' WHERE id=76570;")
            cur.execute("UPDATE products SET ticker='F0GBR0601E' WHERE id=75439;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6I' WHERE id=76575;")
            cur.execute("UPDATE products SET ticker='F00000MEVI' WHERE id=79996;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6C' WHERE id=78851;")
            cur.execute("UPDATE products SET ticker='F0GBR04Y4K' WHERE id=78957;")
            cur.execute("UPDATE products SET ticker='F0GBR04J5M' WHERE id=78980;")
            cur.execute("UPDATE products SET ticker='F0GBR04CFD' WHERE id=78978;")
            cur.execute("UPDATE products SET ticker='F0GBR04PVT' WHERE id=78984;")
            cur.execute("UPDATE products SET ticker='F0GBR04J5O' WHERE id=80031;")
            cur.execute("UPDATE products SET ticker='F0GBR04J60' WHERE id=80032;")
            cur.execute("UPDATE products SET ticker='F0GBR04JRV' WHERE id=80033;")
            cur.execute("UPDATE products SET ticker='F00000HHOA' WHERE id=80034;")
            cur.execute("UPDATE products SET ticker='F000001W2M' WHERE id=80036;")
            cur.execute("UPDATE products SET ticker='F0GBR0603X' WHERE id=80037;")
            cur.execute("UPDATE products SET ticker='F0GBR0603W' WHERE id=80061;")
            cur.execute("UPDATE products SET ticker='F0GBR04PV0' WHERE id=80069;")
            cur.execute("UPDATE products SET ticker='F0GBR04K2N' WHERE id=80076;")
            cur.execute("UPDATE products SET ticker='F0GBR04PUE' WHERE id=80072;")
            cur.execute("UPDATE products SET ticker='F0GBR04K4O' WHERE id=80079;")
            cur.execute("UPDATE products SET ticker='F0GBR04K4Q' WHERE id=80080;")
            cur.execute("UPDATE products SET ticker='F0GBR04PUW' WHERE id=80081;")
            cur.execute("UPDATE products SET ticker='F0GBR04K2J' WHERE id=78985;")
            cur.execute("UPDATE products SET ticker='F0GBR04DHM' WHERE id=75174;")
            cur.execute("UPDATE products SET ticker='F000002115' WHERE id=78986;")
            cur.execute("UPDATE products SET ticker='F0GBR04DHO' WHERE id=75223;")
            cur.execute("UPDATE products SET ticker='F0GBR04DHQ' WHERE id=75501;")
            cur.execute("UPDATE products SET ticker='F0GBR04EPT' WHERE id=75473;")
            cur.execute("UPDATE products SET ticker='F0GBR04JSQ' WHERE id=78990;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4G' WHERE id=79026;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4I' WHERE id=79034;")
            cur.execute("UPDATE products SET ticker='F0GBR04J56' WHERE id=75480;")
            cur.execute("UPDATE products SET ticker='F0GBR04J50' WHERE id=79042;")
            cur.execute("UPDATE products SET ticker='F0GBR04J54' WHERE id=75270;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4Q' WHERE id=75273;")
            cur.execute("UPDATE products SET ticker='F000001LHE' WHERE id=77361;")
            cur.execute("UPDATE products SET ticker='F00000HHOB' WHERE id=79054;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4S' WHERE id=79059;")
            cur.execute("UPDATE products SET ticker='F0GBR04DJ1' WHERE id=77407;")
            cur.execute("UPDATE products SET ticker='F0GBR04J94' WHERE id=80107;")
            cur.execute("UPDATE products SET ticker='F0GBR04K40' WHERE id=80108;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRL' WHERE id=77408;")
            cur.execute("UPDATE products SET ticker='F000000E7J' WHERE id=79049;")
            cur.execute("UPDATE products SET ticker='F00000LJSI' WHERE id=80115;")
            cur.execute("UPDATE products SET ticker='F0GBR04PTY' WHERE id=80039;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRW' WHERE id=79074;")
            cur.execute("UPDATE products SET ticker='F0GBR04J8W' WHERE id=80117;")
            cur.execute("UPDATE products SET ticker='F00000410Q' WHERE id=80118;")
            cur.execute("UPDATE products SET ticker='F0GBR04JJT' WHERE id=79075;")
            cur.execute("UPDATE products SET ticker='F0GBR04PTZ' WHERE id=80120;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRV' WHERE id=78945;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRR' WHERE id=79068;")
            cur.execute("UPDATE products SET ticker='F0GBR04GVS' WHERE id=75610;")
            cur.execute("UPDATE products SET ticker='F0GBR04IYG' WHERE id=80131;")
            cur.execute("UPDATE products SET ticker='F0GBR04IYE' WHERE id=80134;")
            cur.execute("UPDATE products SET ticker='F0GBR04IYK' WHERE id=80135;")
            cur.execute("UPDATE products SET ticker='F000001LHC' WHERE id=80137;")
            cur.execute("UPDATE products SET ticker='F0GBR05XMD' WHERE id=80138;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7X' WHERE id=80139;")
            cur.execute("UPDATE products SET ticker='F00000M1EF' WHERE id=80182;")
            cur.execute("UPDATE products SET ticker='F0GBR04FQM' WHERE id=80183;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q79' WHERE id=80184;")
            cur.execute("UPDATE products SET ticker='F0GBR04MDA' WHERE id=80185;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q77' WHERE id=80186;")
            cur.execute("UPDATE products SET ticker='F0GBR06HEF' WHERE id=80189;")
            cur.execute("UPDATE products SET ticker='F0000044OL' WHERE id=80197;")
            cur.execute("UPDATE products SET ticker='F0GBR06HEG' WHERE id=80198;")
            cur.execute("UPDATE products SET ticker='F0GBR04LHQ' WHERE id=80199;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7T' WHERE id=75320;")
            cur.execute("UPDATE products SET ticker='F0GBR06015' WHERE id=79115;")
            cur.execute("UPDATE products SET ticker='F0GBR04OCH' WHERE id=79116;")
            cur.execute("UPDATE products SET ticker='F0GBR04OPX' WHERE id=79118;")
            cur.execute("UPDATE products SET ticker='F0GBR04OPZ' WHERE id=79119;")
            cur.execute("UPDATE products SET ticker='F0GBR04KX4' WHERE id=75613;")
            cur.execute("UPDATE products SET ticker='F000001WF5' WHERE id=75649;")
            cur.execute("UPDATE products SET ticker='F0GBR06UB2' WHERE id=80180;")
            cur.execute("UPDATE products SET ticker='F000002T5C' WHERE id=79106;")
            cur.execute("UPDATE products SET ticker='F0GBR04KX6' WHERE id=79120;")
            cur.execute("UPDATE products SET ticker='F0GBR04O1M' WHERE id=79092;")
            cur.execute("UPDATE products SET ticker='F0000001UD' WHERE id=75655;")
            cur.execute("UPDATE products SET ticker='F000000KSB' WHERE id=79123;")
            cur.execute("UPDATE products SET ticker='F0GBR06UAE' WHERE id=75656;")
            cur.execute("UPDATE products SET ticker='F000000R6V' WHERE id=79124;")
            cur.execute("UPDATE products SET ticker='F0GBR04KXA' WHERE id=75321;")
            cur.execute("UPDATE products SET ticker='F0GBR04KXC' WHERE id=79147;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7N' WHERE id=75710;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7B' WHERE id=79150;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7G' WHERE id=79151;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7J' WHERE id=79155;")
            cur.execute("UPDATE products SET ticker='F000005H38' WHERE id=77510;")
            cur.execute("UPDATE products SET ticker='F0GBR04KXG' WHERE id=79156;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7Q' WHERE id=75714;")
            cur.execute("UPDATE products SET ticker='F0GBR05XMS' WHERE id=79159;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7M' WHERE id=75761;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7Z' WHERE id=75767;")
            cur.execute("UPDATE products SET ticker='F0GBR069VW' WHERE id=77513;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7O' WHERE id=75768;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYC' WHERE id=75772;")
            cur.execute("UPDATE products SET ticker='F0000001T1' WHERE id=79161;")
            cur.execute("UPDATE products SET ticker='F000000E7H' WHERE id=79160;")
            cur.execute("UPDATE products SET ticker='F0GBR04JQP' WHERE id=77145;")
            cur.execute("UPDATE products SET ticker='F00000HLGA' WHERE id=79162;")
            cur.execute("UPDATE products SET ticker='F0GBR04IZA' WHERE id=79367;")
            cur.execute("UPDATE products SET ticker='F0GBR04JDU' WHERE id=79719;")
            cur.execute("UPDATE products SET ticker='F0GBR04J08' WHERE id=79731;")
            cur.execute("UPDATE products SET ticker='F0GBR04JCW' WHERE id=79759;")
            cur.execute("UPDATE products SET ticker='F0GBR04JD0' WHERE id=80220;")
            cur.execute("UPDATE products SET ticker='F0GBR04JD4' WHERE id=80221;")
            cur.execute("UPDATE products SET ticker='F0GBR04JDC' WHERE id=80222;")
            cur.execute("UPDATE products SET ticker='F0GBR04JD2' WHERE id=80223;")
            cur.execute("UPDATE products SET ticker='F0GBR04JD6' WHERE id=80224;")
            cur.execute("UPDATE products SET ticker='F0GBR04JD8' WHERE id=80225;")
            cur.execute("UPDATE products SET ticker='F0GBR04J1O' WHERE id=80240;")
            cur.execute("UPDATE products SET ticker='F0GBR04J1S' WHERE id=80226;")
            cur.execute("UPDATE products SET ticker='F0GBR04J1Q' WHERE id=80277;")
            cur.execute("UPDATE products SET ticker='F0GBR04J1U' WHERE id=75474;")
            cur.execute("UPDATE products SET ticker='F0GBR05V2B' WHERE id=79522;")
            cur.execute("UPDATE products SET ticker='F0GBR05V0T' WHERE id=79523;")
            cur.execute("UPDATE products SET ticker='F0GBR05TCE' WHERE id=79524;")
            cur.execute("UPDATE products SET ticker='F0GBR05U06' WHERE id=79525;")
            cur.execute("UPDATE products SET ticker='F0GBR06838' WHERE id=79528;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q3U' WHERE id=79198;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q0Y' WHERE id=79821;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q10' WHERE id=75861;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q0X' WHERE id=79820;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q0T' WHERE id=75862;")
            cur.execute("UPDATE products SET ticker='F0GBR04DPB' WHERE id=75864;")
            cur.execute("UPDATE products SET ticker='F0GBR04JUK' WHERE id=79255;")
            cur.execute("UPDATE products SET ticker='F0GBR04JUE' WHERE id=75865;")
            cur.execute("UPDATE products SET ticker='F0GBR04JUA' WHERE id=79257;")
            cur.execute("UPDATE products SET ticker='F0GBR04JUW' WHERE id=79260;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONP' WHERE id=79266;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONR' WHERE id=79541;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONT' WHERE id=79559;")
            cur.execute("UPDATE products SET ticker='F000002Q3S' WHERE id=79560;")
            cur.execute("UPDATE products SET ticker='F0GBR06HFU' WHERE id=79563;")
            cur.execute("UPDATE products SET ticker='FOGBR05KU9' WHERE id=75904;")
            cur.execute("UPDATE products SET ticker='F0GBR06HG5' WHERE id=79423;")
            cur.execute("UPDATE products SET ticker='F000000E7E' WHERE id=75906;")
            cur.execute("UPDATE products SET ticker='FOGBR05KUG' WHERE id=75909;")
            cur.execute("UPDATE products SET ticker='F0000006PY' WHERE id=79612;")
            cur.execute("UPDATE products SET ticker='F000000ASC' WHERE id=79658;")
            cur.execute("UPDATE products SET ticker='F00000LXRX' WHERE id=79683;")
            cur.execute("UPDATE products SET ticker='F0GBR04JO4' WHERE id=79687;")
            cur.execute("UPDATE products SET ticker='F0GBR04PXA' WHERE id=79733;")
            cur.execute("UPDATE products SET ticker='F0GBR04PXN' WHERE id=79946;")
            cur.execute("UPDATE products SET ticker='F0GBR04PX3' WHERE id=79949;")
            cur.execute("UPDATE products SET ticker='F0GBR04PXT' WHERE id=79951;")
            cur.execute("UPDATE products SET ticker='F0GBR06GYM' WHERE id=79739;")
            cur.execute("UPDATE products SET ticker='F0GBR04NXT' WHERE id=79740;")
            cur.execute("UPDATE products SET ticker='F0GBR04PX7' WHERE id=79732;")
            cur.execute("UPDATE products SET ticker='F0GBR06GH4' WHERE id=79743;")
            cur.execute("UPDATE products SET ticker='F0GBR052LJ' WHERE id=79745;")
            cur.execute("UPDATE products SET ticker='F0GBR04J5U' WHERE id=79775;")
            cur.execute("UPDATE products SET ticker='F000002IK8' WHERE id=79783;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYO' WHERE id=75366;")
            cur.execute("UPDATE products SET ticker='F0GBR04J1W' WHERE id=75370;")
            cur.execute("UPDATE products SET ticker='F0GBR04VV7' WHERE id=75408;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q51' WHERE id=79955;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q50' WHERE id=79956;")
            cur.execute("UPDATE products SET ticker='F0GBR04M4S' WHERE id=79511;")
            cur.execute("UPDATE products SET ticker='F0GBR04GX8' WHERE id=80257;")
            cur.execute("UPDATE products SET ticker='F0GBR04EPR' WHERE id=80258;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5F' WHERE id=80269;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q56' WHERE id=80260;")
            cur.execute("UPDATE products SET ticker='F0GBR04JTS' WHERE id=79245;")
            cur.execute("UPDATE products SET ticker='F0GBR04M4U' WHERE id=80266;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q54' WHERE id=80273;")
            cur.execute("UPDATE products SET ticker='F0000024NF' WHERE id=80292;")
            cur.execute("UPDATE products SET ticker='F0GBR05S6K' WHERE id=80314;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5G' WHERE id=80315;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5H' WHERE id=79207;")
            cur.execute("UPDATE products SET ticker='F0GBR04M4Y' WHERE id=80378;")
            cur.execute("UPDATE products SET ticker='F0GBR04CFF' WHERE id=79293;")
            cur.execute("UPDATE products SET ticker='F0GBR04DNS' WHERE id=79426;")
            cur.execute("UPDATE products SET ticker='F0GBR04DNQ' WHERE id=80023;")
            cur.execute("UPDATE products SET ticker='F0GBR04PTU' WHERE id=80038;")
            cur.execute("UPDATE products SET ticker='F0000021KQ' WHERE id=80044;")
            cur.execute("UPDATE products SET ticker='F0GBR04EPD' WHERE id=75409;")
            cur.execute("UPDATE products SET ticker='F0GBR04EPV' WHERE id=75410;")
            cur.execute("UPDATE products SET ticker='F0GBR04EPF' WHERE id=75413;")
            cur.execute("UPDATE products SET ticker='F0GBR04J98' WHERE id=75415;")
            cur.execute("UPDATE products SET ticker='F0GBR04J9W' WHERE id=79564;")
            cur.execute("UPDATE products SET ticker='F0GBR04OPF' WHERE id=79565;")
            cur.execute("UPDATE products SET ticker='F0GBR04J9M' WHERE id=75416;")
            cur.execute("UPDATE products SET ticker='F0GBR04JA6' WHERE id=80436;")
            cur.execute("UPDATE products SET ticker='F0GBR04JA8' WHERE id=80442;")
            cur.execute("UPDATE products SET ticker='F0GBR04JAC' WHERE id=80443;")
            cur.execute("UPDATE products SET ticker='F0GBR04JAE' WHERE id=80444;")
            cur.execute("UPDATE products SET ticker='F0GBR04J9G' WHERE id=75464;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1P' WHERE id=80140;")
            cur.execute("UPDATE products SET ticker='F0GBR04J9A' WHERE id=80141;")
            cur.execute("UPDATE products SET ticker='F000001VX2' WHERE id=80161;")
            cur.execute("UPDATE products SET ticker='F0GBR04J9K' WHERE id=80151;")
            cur.execute("UPDATE products SET ticker='F0GBR04J9O' WHERE id=80159;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4A' WHERE id=80165;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4C' WHERE id=79436;")
            cur.execute("UPDATE products SET ticker='F0GBR04J4E' WHERE id=80633;")
            cur.execute("UPDATE products SET ticker='F0GBR04JYQ' WHERE id=79452;")
            cur.execute("UPDATE products SET ticker='F0GBR06PPR' WHERE id=79454;")
            cur.execute("UPDATE products SET ticker='F0GBR04K3Q' WHERE id=80635;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6T' WHERE id=75815;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8T' WHERE id=75816;")
            cur.execute("UPDATE products SET ticker='F0GBR04EG7' WHERE id=79486;")
            cur.execute("UPDATE products SET ticker='F000002941' WHERE id=80637;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6V' WHERE id=79331;")
            cur.execute("UPDATE products SET ticker='F0000000S8' WHERE id=77853;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q6P' WHERE id=80348;")
            cur.execute("UPDATE products SET ticker='F000005IOJ' WHERE id=80361;")
            cur.execute("UPDATE products SET ticker='F0000045OB' WHERE id=79332;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8E' WHERE id=80876;")
            cur.execute("UPDATE products SET ticker='F0GBR04D4N' WHERE id=80879;")
            cur.execute("UPDATE products SET ticker='F00000M0NC' WHERE id=80880;")
            cur.execute("UPDATE products SET ticker='F00000H5PS' WHERE id=77978;")
            cur.execute("UPDATE products SET ticker='F0GBR04C9V' WHERE id=79690;")
            cur.execute("UPDATE products SET ticker='F00000021U' WHERE id=75866;")
            cur.execute("UPDATE products SET ticker='F0GBR04GRQ' WHERE id=75937;")
            cur.execute("UPDATE products SET ticker='F0GBR06XIQ' WHERE id=80882;")
            cur.execute("UPDATE products SET ticker='F0GBR051QM' WHERE id=80491;")
            cur.execute("UPDATE products SET ticker='F0GBR04DNW' WHERE id=75518;")
            cur.execute("UPDATE products SET ticker='F0GBR06UII' WHERE id=79912;")
            cur.execute("UPDATE products SET ticker='FOGBR05KRY' WHERE id=75465;")
            cur.execute("UPDATE products SET ticker='F0GBR053VC' WHERE id=79531;")
            cur.execute("UPDATE products SET ticker='F000001VLR' WHERE id=79913;")
            cur.execute("UPDATE products SET ticker='F000000371' WHERE id=79533;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q9J' WHERE id=79534;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4P' WHERE id=79746;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4R' WHERE id=75564;")
            cur.execute("UPDATE products SET ticker='F0GBR04OMR' WHERE id=79926;")
            cur.execute("UPDATE products SET ticker='F0GBR04K6C' WHERE id=79569;")
            cur.execute("UPDATE products SET ticker='F0GBR056U1' WHERE id=75486;")
            cur.execute("UPDATE products SET ticker='F0GBR04M9Z' WHERE id=75567;")
            cur.execute("UPDATE products SET ticker='F0GBR04GVA' WHERE id=76342;")
            cur.execute("UPDATE products SET ticker='F0GBR04J2K' WHERE id=79536;")
            cur.execute("UPDATE products SET ticker='F0GBR06156' WHERE id=76383;")
            cur.execute("UPDATE products SET ticker='F0GBR04J2E' WHERE id=75618;")
            cur.execute("UPDATE products SET ticker='F0GBR0557E' WHERE id=75623;")
            cur.execute("UPDATE products SET ticker='F0GBR04JWO' WHERE id=75667;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6S' WHERE id=75689;")
            cur.execute("UPDATE products SET ticker='F0GBR04K14' WHERE id=78274;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q49' WHERE id=79140;")
            cur.execute("UPDATE products SET ticker='F0GBR06UBQ' WHERE id=79188;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q48' WHERE id=79191;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4B' WHERE id=79193;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4E' WHERE id=77559;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q47' WHERE id=77561;")
            cur.execute("UPDATE products SET ticker='F000005K6I' WHERE id=75362;")
            cur.execute("UPDATE products SET ticker='F000005K6J' WHERE id=79682;")
            cur.execute("UPDATE products SET ticker='F00000J85F' WHERE id=79194;")
            cur.execute("UPDATE products SET ticker='F00000J85G' WHERE id=79195;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4G' WHERE id=79196;")
            cur.execute("UPDATE products SET ticker='F0GBR04JSY' WHERE id=79828;")
            cur.execute("UPDATE products SET ticker='F0GBR04J3Q' WHERE id=75716;")
            cur.execute("UPDATE products SET ticker='F0GBR04JAI' WHERE id=76427;")
            cur.execute("UPDATE products SET ticker='F0GBR04J5E' WHERE id=76429;")
            cur.execute("UPDATE products SET ticker='F0GBR04KWW' WHERE id=75718;")
            cur.execute("UPDATE products SET ticker='F0GBR04IUY' WHERE id=80367;")
            cur.execute("UPDATE products SET ticker='F0GBR04IV3' WHERE id=80417;")
            cur.execute("UPDATE products SET ticker='F0GBR04IV9' WHERE id=80452;")
            cur.execute("UPDATE products SET ticker='F0GBR04IVB' WHERE id=80992;")
            cur.execute("UPDATE products SET ticker='F0GBR04HJS' WHERE id=80456;")
            cur.execute("UPDATE products SET ticker='F0GBR04GDZ' WHERE id=80453;")
            cur.execute("UPDATE products SET ticker='F0GBR04IVD' WHERE id=80995;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONJ' WHERE id=75775;")
            cur.execute("UPDATE products SET ticker='F0GBR06XIK' WHERE id=80700;")
            cur.execute("UPDATE products SET ticker='F0GBR04IVL' WHERE id=80708;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2G' WHERE id=80711;")
            cur.execute("UPDATE products SET ticker='F0GBR04DO9' WHERE id=80713;")
            cur.execute("UPDATE products SET ticker='F0GBR04DNY' WHERE id=80714;")
            cur.execute("UPDATE products SET ticker='F0GBR04DYG' WHERE id=80720;")
            cur.execute("UPDATE products SET ticker='F000000AS4' WHERE id=80464;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1G' WHERE id=80465;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZ0' WHERE id=76032;")
            cur.execute("UPDATE products SET ticker='F0GBR04P65' WHERE id=75819;")
            cur.execute("UPDATE products SET ticker='F0GBR04DOB' WHERE id=79914;")
            cur.execute("UPDATE products SET ticker='F0GBR04DOD' WHERE id=80534;")
            cur.execute("UPDATE products SET ticker='F0GBR04DOF' WHERE id=80542;")
            cur.execute("UPDATE products SET ticker='F0GBR06FL7' WHERE id=80543;")
            cur.execute("UPDATE products SET ticker='F0GBR04DOH' WHERE id=80545;")
            cur.execute("UPDATE products SET ticker='F000000K5X' WHERE id=80551;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q38' WHERE id=80525;")
            cur.execute("UPDATE products SET ticker='F0GBR04DOJ' WHERE id=80552;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q39' WHERE id=80522;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q3S' WHERE id=80568;")
            cur.execute("UPDATE products SET ticker='F0GBR04JRT' WHERE id=80571;")
            cur.execute("UPDATE products SET ticker='F0GBR04DSP' WHERE id=80572;")
            cur.execute("UPDATE products SET ticker='F0GBR04DSL' WHERE id=80573;")
            cur.execute("UPDATE products SET ticker='F0GBR04DSR' WHERE id=80574;")
            cur.execute("UPDATE products SET ticker='F0GBR04DST' WHERE id=80570;")
            cur.execute("UPDATE products SET ticker='F0GBR05XQB' WHERE id=75868;")
            cur.execute("UPDATE products SET ticker='F0000006PZ' WHERE id=79915;")
            cur.execute("UPDATE products SET ticker='F0GBR054QR' WHERE id=77756;")
            cur.execute("UPDATE products SET ticker='F000001WF3' WHERE id=79958;")
            cur.execute("UPDATE products SET ticker='F0GBR04PTT' WHERE id=80601;")
            cur.execute("UPDATE products SET ticker='F0GBR04FM0' WHERE id=80602;")
            cur.execute("UPDATE products SET ticker='F0GBR04FM2' WHERE id=80605;")
            cur.execute("UPDATE products SET ticker='F0000001Y0' WHERE id=80606;")
            cur.execute("UPDATE products SET ticker='F0GBR04PTX' WHERE id=80609;")
            cur.execute("UPDATE products SET ticker='F000000R6X' WHERE id=77228;")
            cur.execute("UPDATE products SET ticker='F0000003WD' WHERE id=80669;")
            cur.execute("UPDATE products SET ticker='F0GBR05SJI' WHERE id=77758;")
            cur.execute("UPDATE products SET ticker='F0GBR06U6N' WHERE id=80740;")
            cur.execute("UPDATE products SET ticker='F0GBR04CAJ' WHERE id=80741;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3E' WHERE id=80743;")
            cur.execute("UPDATE products SET ticker='F0GBR054FN' WHERE id=80752;")
            cur.execute("UPDATE products SET ticker='F00000LP94' WHERE id=81040;")
            cur.execute("UPDATE products SET ticker='F000001VX1' WHERE id=81041;")
            cur.execute("UPDATE products SET ticker='F00000JTUE' WHERE id=81042;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3K' WHERE id=81043;")
            cur.execute("UPDATE products SET ticker='F00000JTUD' WHERE id=80773;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3G' WHERE id=81044;")
            cur.execute("UPDATE products SET ticker='F00000JYXY' WHERE id=81045;")
            cur.execute("UPDATE products SET ticker='F0GBR06UAD' WHERE id=80754;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3I' WHERE id=80770;")
            cur.execute("UPDATE products SET ticker='F0GBR04OTB' WHERE id=80771;")
            cur.execute("UPDATE products SET ticker='F00000LIAM' WHERE id=80772;")
            cur.execute("UPDATE products SET ticker='F00000JYY3' WHERE id=80775;")
            cur.execute("UPDATE products SET ticker='F000000OT1' WHERE id=80807;")
            cur.execute("UPDATE products SET ticker='F00000JZCS' WHERE id=80863;")
            cur.execute("UPDATE products SET ticker='F00000MABF' WHERE id=80836;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3M' WHERE id=80837;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3W' WHERE id=80838;")
            cur.execute("UPDATE products SET ticker='F0GBR04K2H' WHERE id=76578;")
            cur.execute("UPDATE products SET ticker='F000001VLP' WHERE id=79959;")
            cur.execute("UPDATE products SET ticker='F00000MIA1' WHERE id=79961;")
            cur.execute("UPDATE products SET ticker='F0GBR06XIS' WHERE id=80000;")
            cur.execute("UPDATE products SET ticker='F00000LP95' WHERE id=79999;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3Q' WHERE id=80001;")
            cur.execute("UPDATE products SET ticker='F000001VWZ' WHERE id=80002;")
            cur.execute("UPDATE products SET ticker='F00000JZCT' WHERE id=80003;")
            cur.execute("UPDATE products SET ticker='F0GBR06XIU' WHERE id=80004;")
            cur.execute("UPDATE products SET ticker='F00000LP97' WHERE id=80049;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4D' WHERE id=80087;")
            cur.execute("UPDATE products SET ticker='F0GBR04K2F' WHERE id=80088;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3O' WHERE id=75960;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3Y' WHERE id=76001;")
            cur.execute("UPDATE products SET ticker='F00000JTUF' WHERE id=76002;")
            cur.execute("UPDATE products SET ticker='F0000006QB' WHERE id=76003;")
            cur.execute("UPDATE products SET ticker='F000002T5A' WHERE id=76476;")
            cur.execute("UPDATE products SET ticker='F0GBR04GUG' WHERE id=76005;")
            cur.execute("UPDATE products SET ticker='F00000H16W' WHERE id=76483;")
            cur.execute("UPDATE products SET ticker='F0GBR04K2D' WHERE id=76034;")
            cur.execute("UPDATE products SET ticker='F00000LP96' WHERE id=76038;")
            cur.execute("UPDATE products SET ticker='F0GBR04E40' WHERE id=76051;")
            cur.execute("UPDATE products SET ticker='F0GBR04E49' WHERE id=76053;")
            cur.execute("UPDATE products SET ticker='F00000JYXX' WHERE id=76054;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4F' WHERE id=76522;")
            cur.execute("UPDATE products SET ticker='F00000JYXW' WHERE id=76055;")
            cur.execute("UPDATE products SET ticker='F00000GVAT' WHERE id=76057;")
            cur.execute("UPDATE products SET ticker='F0GBR04K29' WHERE id=76524;")
            cur.execute("UPDATE products SET ticker='F000002KOK' WHERE id=76075;")
            cur.execute("UPDATE products SET ticker='F00000JTVJ' WHERE id=76531;")
            cur.execute("UPDATE products SET ticker='F0GBR05UYO' WHERE id=76076;")
            cur.execute("UPDATE products SET ticker='F0GBR04K2A' WHERE id=76077;")
            cur.execute("UPDATE products SET ticker='F0GBR04G3L' WHERE id=76083;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4R' WHERE id=76102;")
            cur.execute("UPDATE products SET ticker='F0GBR04E3U' WHERE id=76103;")
            cur.execute("UPDATE products SET ticker='F000000RX7' WHERE id=76104;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4N' WHERE id=76110;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4P' WHERE id=76155;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4T' WHERE id=76156;")
            cur.execute("UPDATE products SET ticker='F0GBR04K26' WHERE id=76158;")
            cur.execute("UPDATE products SET ticker='F0GBR04ONX' WHERE id=81047;")
            cur.execute("UPDATE products SET ticker='F0GBR04OO1' WHERE id=81048;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4H' WHERE id=76159;")
            cur.execute("UPDATE products SET ticker='F0GBR04E47' WHERE id=81049;")
            cur.execute("UPDATE products SET ticker='F0GBR04VS8' WHERE id=76160;")
            cur.execute("UPDATE products SET ticker='F0GBR04E4V' WHERE id=76161;")
            cur.execute("UPDATE products SET ticker='F0GBR04K24' WHERE id=81094;")
            cur.execute("UPDATE products SET ticker='F0GBR04M5Y' WHERE id=81098;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2K' WHERE id=81099;")
            cur.execute("UPDATE products SET ticker='F0GBR06XIG' WHERE id=81100;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2L' WHERE id=81076;")
            cur.execute("UPDATE products SET ticker='F0GBR04J7I' WHERE id=81077;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4I' WHERE id=81079;")
            cur.execute("UPDATE products SET ticker='F0GBR0604J' WHERE id=76205;")
            cur.execute("UPDATE products SET ticker='F000000R6Y' WHERE id=81080;")
            cur.execute("UPDATE products SET ticker='F000000R6U' WHERE id=81081;")
            cur.execute("UPDATE products SET ticker='F0GBR04MYG' WHERE id=76206;")
            cur.execute("UPDATE products SET ticker='F000000R6T' WHERE id=76394;")
            cur.execute("UPDATE products SET ticker='F0GBR06Q1R' WHERE id=76398;")
            cur.execute("UPDATE products SET ticker='F0GBR04JO2' WHERE id=76204;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q7D' WHERE id=76381;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6A' WHERE id=76627;")
            cur.execute("UPDATE products SET ticker='F0GBR05POO' WHERE id=76774;")
            cur.execute("UPDATE products SET ticker='F0GBR04J7M' WHERE id=76805;")
            cur.execute("UPDATE products SET ticker='F0GBR04KFB' WHERE id=76816;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRH' WHERE id=80241;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRF' WHERE id=80242;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRG' WHERE id=80243;")
            cur.execute("UPDATE products SET ticker='F0GBR04PSF' WHERE id=76866;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2D' WHERE id=80244;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q06' WHERE id=80371;")
            cur.execute("UPDATE products SET ticker='F0GBR04J2W' WHERE id=76678;")
            cur.execute("UPDATE products SET ticker='F0GBR04J3S' WHERE id=81123;")
            cur.execute("UPDATE products SET ticker='F0GBR04J3U' WHERE id=81124;")
            cur.execute("UPDATE products SET ticker='F0000001TT' WHERE id=81126;")
            cur.execute("UPDATE products SET ticker='F0000001TU' WHERE id=81128;")
            cur.execute("UPDATE products SET ticker='F0GBR04JLH' WHERE id=80393;")
            cur.execute("UPDATE products SET ticker='F0GBR04J3O' WHERE id=81132;")
            cur.execute("UPDATE products SET ticker='F000005GXC' WHERE id=81133;")
            cur.execute("UPDATE products SET ticker='F0000024PU' WHERE id=81138;")
            cur.execute("UPDATE products SET ticker='F0GBR06XH2' WHERE id=81144;")
            cur.execute("UPDATE products SET ticker='F0GBR04JS3' WHERE id=80282;")
            cur.execute("UPDATE products SET ticker='F0GBR04E6M' WHERE id=76980;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZ8' WHERE id=81203;")
            cur.execute("UPDATE products SET ticker='F0GBR04LF4' WHERE id=81204;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1T' WHERE id=81206;")
            cur.execute("UPDATE products SET ticker='F0GBR04CB3' WHERE id=81205;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1V' WHERE id=81207;")
            cur.execute("UPDATE products SET ticker='F0GBR04J8I' WHERE id=81215;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWJ' WHERE id=81224;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWP' WHERE id=81225;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWK' WHERE id=81227;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWL' WHERE id=81228;")
            cur.execute("UPDATE products SET ticker='F0GBR04K06' WHERE id=81229;")
            cur.execute("UPDATE products SET ticker='F0GBR04PXI' WHERE id=81250;")
            cur.execute("UPDATE products SET ticker='F0GBR04GIW' WHERE id=81251;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZU' WHERE id=81260;")
            cur.execute("UPDATE products SET ticker='F0GBR04PVW' WHERE id=81268;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWM' WHERE id=81301;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWW' WHERE id=81306;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZS' WHERE id=77131;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZQ' WHERE id=77147;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZO' WHERE id=77150;")
            cur.execute("UPDATE products SET ticker='F0GBR04JZM' WHERE id=77169;")
            cur.execute("UPDATE products SET ticker='F0GBR04PXJ' WHERE id=77170;")
            cur.execute("UPDATE products SET ticker='F0GBR05U19' WHERE id=80466;")
            cur.execute("UPDATE products SET ticker='F0GBR04PW2' WHERE id=81231;")
            cur.execute("UPDATE products SET ticker='F0GBR04K12' WHERE id=81234;")
            cur.execute("UPDATE products SET ticker='F0GBR04PW4' WHERE id=81235;")
            cur.execute("UPDATE products SET ticker='F0GBR04EP9' WHERE id=80468;")
            cur.execute("UPDATE products SET ticker='F0GBR06XII' WHERE id=77221;")
            cur.execute("UPDATE products SET ticker='F00000H5PM' WHERE id=77317;")
            cur.execute("UPDATE products SET ticker='F0000044BJ' WHERE id=77410;")
            cur.execute("UPDATE products SET ticker='F000002ODD' WHERE id=76207;")
            cur.execute("UPDATE products SET ticker='F0GBR04MBB' WHERE id=76210;")
            cur.execute("UPDATE products SET ticker='F0GBR04J9C' WHERE id=77611;")
            cur.execute("UPDATE products SET ticker='F0GBR04JAM' WHERE id=77752;")
            cur.execute("UPDATE products SET ticker='F0000006PW' WHERE id=80496;")
            cur.execute("UPDATE products SET ticker='F000000E84' WHERE id=80500;")
            cur.execute("UPDATE products SET ticker='F0GBR04JAW' WHERE id=80501;")
            cur.execute("UPDATE products SET ticker='F0GBR05PON' WHERE id=80284;")
            cur.execute("UPDATE products SET ticker='F0GBR04GLR' WHERE id=80290;")
            cur.execute("UPDATE products SET ticker='F00000JZB9' WHERE id=76211;")
            cur.execute("UPDATE products SET ticker='F0GBR04JAS' WHERE id=80559;")
            cur.execute("UPDATE products SET ticker='F0GBR04DMW' WHERE id=81317;")
            cur.execute("UPDATE products SET ticker='F0GBR04DKT' WHERE id=81319;")
            cur.execute("UPDATE products SET ticker='F00000JYY1' WHERE id=81318;")
            cur.execute("UPDATE products SET ticker='F00000JYYR' WHERE id=81313;")
            cur.execute("UPDATE products SET ticker='F0GBR04DL6' WHERE id=81314;")
            cur.execute("UPDATE products SET ticker='F0GBR04DKX' WHERE id=81321;")
            cur.execute("UPDATE products SET ticker='F00000JYXZ' WHERE id=81320;")
            cur.execute("UPDATE products SET ticker='F00000JYXV' WHERE id=81322;")
            cur.execute("UPDATE products SET ticker='F0GBR04DM0' WHERE id=81323;")
            cur.execute("UPDATE products SET ticker='F0GBR04DMQ' WHERE id=81325;")
            cur.execute("UPDATE products SET ticker='F00000JYXU' WHERE id=81324;")
            cur.execute("UPDATE products SET ticker='F0GBR04DL8' WHERE id=81326;")
            cur.execute("UPDATE products SET ticker='F0GBR04DLA' WHERE id=81237;")
            cur.execute("UPDATE products SET ticker='F0GBR04DM2' WHERE id=81239;")
            cur.execute("UPDATE products SET ticker='F00000JYY2' WHERE id=81238;")
            cur.execute("UPDATE products SET ticker='F0GBR04DMI' WHERE id=81240;")
            cur.execute("UPDATE products SET ticker='F0GBR04DMK' WHERE id=81328;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1H' WHERE id=81335;")
            cur.execute("UPDATE products SET ticker='F0GBR0601M' WHERE id=81333;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1I' WHERE id=81336;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1J' WHERE id=81331;")
            cur.execute("UPDATE products SET ticker='F0GBR04HCF' WHERE id=81334;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1K' WHERE id=81337;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1L' WHERE id=81332;")
            cur.execute("UPDATE products SET ticker='0P0000VHLV' WHERE id=75042;")
            cur.execute("UPDATE products SET ticker='F0GBR04JBA' WHERE id=81338;")
            cur.execute("UPDATE products SET ticker='F0000006PS' WHERE id=81339;")
            cur.execute("UPDATE products SET ticker='F000000H7D' WHERE id=81340;")
            cur.execute("UPDATE products SET ticker='F0GBR04D5W' WHERE id=80575;")
            cur.execute("UPDATE products SET ticker='F0GBR0601F' WHERE id=80576;")
            cur.execute("UPDATE products SET ticker='F0GBR06U7K' WHERE id=80577;")
            cur.execute("UPDATE products SET ticker='FOGBR05KA1' WHERE id=80578;")
            cur.execute("UPDATE products SET ticker='F0GBR04MNW' WHERE id=80579;")
            cur.execute("UPDATE products SET ticker='F0GBR05V84' WHERE id=76256;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q4C' WHERE id=77763;")
            cur.execute("UPDATE products SET ticker='F0GBR06U7A' WHERE id=77764;")
            cur.execute("UPDATE products SET ticker='F0GBR04JBS' WHERE id=76443;")
            cur.execute("UPDATE products SET ticker='F0GBR04JBO' WHERE id=76347;")
            cur.execute("UPDATE products SET ticker='F0GBR04OPJ' WHERE id=81366;")
            cur.execute("UPDATE products SET ticker='F0GBR04M58' WHERE id=81365;")
            cur.execute("UPDATE products SET ticker='F0GBR04JBU' WHERE id=81341;")
            cur.execute("UPDATE products SET ticker='F0GBR04JBW' WHERE id=81343;")
            cur.execute("UPDATE products SET ticker='F0GBR04JBY' WHERE id=80307;")
            cur.execute("UPDATE products SET ticker='F0GBR04JC0' WHERE id=81373;")
            cur.execute("UPDATE products SET ticker='F0GBR04JC2' WHERE id=76400;")
            cur.execute("UPDATE products SET ticker='F0GBR04JC4' WHERE id=76440;")
            cur.execute("UPDATE products SET ticker='F0GBR04JBM' WHERE id=80308;")
            cur.execute("UPDATE products SET ticker='F0GBR04JC6' WHERE id=80309;")
            cur.execute("UPDATE products SET ticker='F000002JPO' WHERE id=80333;")
            cur.execute("UPDATE products SET ticker='F0GBR04IZI' WHERE id=80374;")
            cur.execute("UPDATE products SET ticker='F0GBR04PRS' WHERE id=76261;")
            cur.execute("UPDATE products SET ticker='F0GBR04JT0' WHERE id=76447;")
            cur.execute("UPDATE products SET ticker='F000005OE0' WHERE id=76448;")
            cur.execute("UPDATE products SET ticker='F0GBR0604K' WHERE id=77838;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1U' WHERE id=76309;")
            cur.execute("UPDATE products SET ticker='F0GBR04VRB' WHERE id=76310;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1N' WHERE id=76486;")
            cur.execute("UPDATE products SET ticker='F0GBR04JTA' WHERE id=80399;")
            cur.execute("UPDATE products SET ticker='F0GBR04IYW' WHERE id=80611;")
            cur.execute("UPDATE products SET ticker='F0GBR04JLB' WHERE id=80612;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6G' WHERE id=80613;")
            cur.execute("UPDATE products SET ticker='F0GBR04J7E' WHERE id=80614;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6M' WHERE id=80615;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6Y' WHERE id=80594;")
            cur.execute("UPDATE products SET ticker='F0GBR04J7A' WHERE id=76488;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6K' WHERE id=76489;")
            cur.execute("UPDATE products SET ticker='F0GBR04J74' WHERE id=76490;")
            cur.execute("UPDATE products SET ticker='F0GBR04J3Z' WHERE id=76491;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8G' WHERE id=76492;")
            cur.execute("UPDATE products SET ticker='F0GBR054SV' WHERE id=76533;")
            cur.execute("UPDATE products SET ticker='F0GBR06UB0' WHERE id=76534;")
            cur.execute("UPDATE products SET ticker='F0GBR04J6O' WHERE id=77883;")
            cur.execute("UPDATE products SET ticker='F0GBR0601N' WHERE id=80643;")
            cur.execute("UPDATE products SET ticker='F0GBR05WLZ' WHERE id=80645;")
            cur.execute("UPDATE products SET ticker='F0GBR04J76' WHERE id=80646;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWG' WHERE id=80587;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWB' WHERE id=76357;")
            cur.execute("UPDATE products SET ticker='F0GBR04PWE' WHERE id=76358;")
            cur.execute("UPDATE products SET ticker='F000005OM3' WHERE id=80657;")
            cur.execute("UPDATE products SET ticker='F0GBR04H41' WHERE id=80659;")
            cur.execute("UPDATE products SET ticker='F0GBR054JF' WHERE id=80660;")
            cur.execute("UPDATE products SET ticker='F0GBR04GEA' WHERE id=80661;")
            cur.execute("UPDATE products SET ticker='F0GBR04GE7' WHERE id=81397;")
            cur.execute("UPDATE products SET ticker='F0GBR0551T' WHERE id=81399;")
            cur.execute("UPDATE products SET ticker='F0GBR05XOO' WHERE id=81400;")
            cur.execute("UPDATE products SET ticker='F0GBR04CEC' WHERE id=81401;")
            cur.execute("UPDATE products SET ticker='F0GBR04GE3' WHERE id=81403;")
            cur.execute("UPDATE products SET ticker='F0GBR04CAN' WHERE id=81404;")
            cur.execute("UPDATE products SET ticker='F0GBR04ESG' WHERE id=81405;")
            cur.execute("UPDATE products SET ticker='F0GBR055T6' WHERE id=77832;")
            cur.execute("UPDATE products SET ticker='F0GBR055T9' WHERE id=77851;")
            cur.execute("UPDATE products SET ticker='F0GBR06UAB' WHERE id=81406;")
            cur.execute("UPDATE products SET ticker='F0GBR04JCQ' WHERE id=81407;")
            cur.execute("UPDATE products SET ticker='FOGBR05KRU' WHERE id=77892;")
            cur.execute("UPDATE products SET ticker='F0GBR05622' WHERE id=76535;")
            cur.execute("UPDATE products SET ticker='F0GBR04JCM' WHERE id=80676;")
            cur.execute("UPDATE products SET ticker='F0GBR04JCI' WHERE id=80679;")
            cur.execute("UPDATE products SET ticker='F0GBR04GTZ' WHERE id=80681;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2N' WHERE id=80682;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q37' WHERE id=80404;")
            cur.execute("UPDATE products SET ticker='F000000KQ7' WHERE id=80677;")
            cur.execute("UPDATE products SET ticker='F000000KQ8' WHERE id=80685;")
            cur.execute("UPDATE products SET ticker='F000000KQ9' WHERE id=80687;")
            cur.execute("UPDATE products SET ticker='F00000ISH4' WHERE id=81410;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q8H' WHERE id=81411;")
            cur.execute("UPDATE products SET ticker='F00000J78W' WHERE id=81412;")
            cur.execute("UPDATE products SET ticker='F0GBR051TA' WHERE id=81413;")
            cur.execute("UPDATE products SET ticker='F0GBR053T3' WHERE id=81415;")
            cur.execute("UPDATE products SET ticker='F000000PAC' WHERE id=81416;")
            cur.execute("UPDATE products SET ticker='F0GBR04CVD' WHERE id=81417;")
            cur.execute("UPDATE products SET ticker='F0GBR04DJ3' WHERE id=81418;")
            cur.execute("UPDATE products SET ticker='F0GBR04DJ5' WHERE id=81393;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q74' WHERE id=81395;")
            cur.execute("UPDATE products SET ticker='F0GBR04DJF' WHERE id=81396;")
            cur.execute("UPDATE products SET ticker='F0GBR04DJS' WHERE id=81409;")
            cur.execute("UPDATE products SET ticker='F0GBR04DJW' WHERE id=81419;")
            cur.execute("UPDATE products SET ticker='F0GBR04DK2' WHERE id=81421;")
            cur.execute("UPDATE products SET ticker='F0GBR04DK4' WHERE id=81432;")
            cur.execute("UPDATE products SET ticker='F0GBR04DK8' WHERE id=81433;")
            cur.execute("UPDATE products SET ticker='F0GBR04DKE' WHERE id=81434;")
            cur.execute("UPDATE products SET ticker='F0GBR04DKG' WHERE id=81435;")
            cur.execute("UPDATE products SET ticker='F00000410P' WHERE id=74788;")
            cur.execute("UPDATE products SET ticker='F000000F20' WHERE id=81436;")
            cur.execute("UPDATE products SET ticker='F0GBR04DKO' WHERE id=81437;")
            cur.execute("UPDATE products SET ticker='F0GBR04PVZ' WHERE id=81455;")
            cur.execute("UPDATE products SET ticker='F00000IT6V' WHERE id=81456;")
            cur.execute("UPDATE products SET ticker='F0GBR04DLU' WHERE id=81457;")
            cur.execute("UPDATE products SET ticker='F0GBR04DLW' WHERE id=81462;")
            cur.execute("UPDATE products SET ticker='F000003WC0' WHERE id=81483;")
            cur.execute("UPDATE products SET ticker='F000000AS7' WHERE id=81422;")
            cur.execute("UPDATE products SET ticker='F0GBR04K22' WHERE id=81485;")
            cur.execute("UPDATE products SET ticker='F000000KSA' WHERE id=81486;")
            cur.execute("UPDATE products SET ticker='F0GBR04GRS' WHERE id=80726;")
            cur.execute("UPDATE products SET ticker='FOGBR05KA4' WHERE id=76536;")
            cur.execute("UPDATE products SET ticker='F0GBR04OO5' WHERE id=77937;")
            cur.execute("UPDATE products SET ticker='F0GBR04OOB' WHERE id=80756;")
            cur.execute("UPDATE products SET ticker='F0GBR04CVZ' WHERE id=77982;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWV' WHERE id=77983;")
            cur.execute("UPDATE products SET ticker='F0GBR04CVP' WHERE id=77985;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWX' WHERE id=80779;")
            cur.execute("UPDATE products SET ticker='F0GBR04CW1' WHERE id=77984;")
            cur.execute("UPDATE products SET ticker='F0GBR0560M' WHERE id=80777;")
            cur.execute("UPDATE products SET ticker='F0GBR064LZ' WHERE id=80731;")
            cur.execute("UPDATE products SET ticker='F000000JPY' WHERE id=80762;")
            cur.execute("UPDATE products SET ticker='F0GBR04CX1' WHERE id=80780;")
            cur.execute("UPDATE products SET ticker='F0GBR04K20' WHERE id=80781;")
            cur.execute("UPDATE products SET ticker='F0GBR04CX4' WHERE id=80782;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1Y' WHERE id=80783;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWH' WHERE id=80785;")
            cur.execute("UPDATE products SET ticker='F0GBR04CW9' WHERE id=80786;")
            cur.execute("UPDATE products SET ticker='F0GBR04CVX' WHERE id=80787;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWJ' WHERE id=80788;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWN' WHERE id=80790;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1W' WHERE id=80792;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWZ' WHERE id=76449;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWR' WHERE id=76450;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWT' WHERE id=76493;")
            cur.execute("UPDATE products SET ticker='F0GBR04CW5' WHERE id=76537;")
            cur.execute("UPDATE products SET ticker='F0GBR04CW7' WHERE id=76580;")
            cur.execute("UPDATE products SET ticker='F0GBR04CWB' WHERE id=80723;")
            cur.execute("UPDATE products SET ticker='F0GBR04J5Q' WHERE id=81414;")
            cur.execute("UPDATE products SET ticker='F0GBR04WMI' WHERE id=76581;")
            cur.execute("UPDATE products SET ticker='F0GBR06UAF' WHERE id=76494;")
            cur.execute("UPDATE products SET ticker='F0GBR06UA8' WHERE id=76538;")
            cur.execute("UPDATE products SET ticker='F0GBR04JP2' WHERE id=80808;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1A' WHERE id=80809;")
            cur.execute("UPDATE products SET ticker='F000002IK5' WHERE id=80810;")
            cur.execute("UPDATE products SET ticker='F0GBR04CIE' WHERE id=80799;")
            cur.execute("UPDATE products SET ticker='F0GBR04OME' WHERE id=76628;")
            cur.execute("UPDATE products SET ticker='F0GBR04M4K' WHERE id=78133;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1Z' WHERE id=78156;")
            cur.execute("UPDATE products SET ticker='F0GBR056KE' WHERE id=78158;")
            cur.execute("UPDATE products SET ticker='F0GBR04JOY' WHERE id=76630;")
            cur.execute("UPDATE products SET ticker='F0GBR06UB1' WHERE id=76632;")
            cur.execute("UPDATE products SET ticker='F0GBR06UB3' WHERE id=76680;")
            cur.execute("UPDATE products SET ticker='F000001AXZ' WHERE id=80801;")
            cur.execute("UPDATE products SET ticker='F0GBR04CIQ' WHERE id=80815;")
            cur.execute("UPDATE products SET ticker='F0GBR04HU9' WHERE id=80848;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q3H' WHERE id=80851;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q22' WHERE id=76779;")
            cur.execute("UPDATE products SET ticker='F000002VEE' WHERE id=76832;")
            cur.execute("UPDATE products SET ticker='F0GBR04CTJ' WHERE id=80507;")
            cur.execute("UPDATE products SET ticker='F0GBR04CSE' WHERE id=80509;")
            cur.execute("UPDATE products SET ticker='F00000MJZ6' WHERE id=81423;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2T' WHERE id=76875;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q30' WHERE id=76922;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q2Y' WHERE id=80519;")
            cur.execute("UPDATE products SET ticker='F0GBR05PPS' WHERE id=76931;")
            cur.execute("UPDATE products SET ticker='F0GBR04CV3' WHERE id=76932;")
            cur.execute("UPDATE products SET ticker='F000004672' WHERE id=76933;")
            cur.execute("UPDATE products SET ticker='F0GBR04PZG' WHERE id=80335;")
            cur.execute("UPDATE products SET ticker='F0GBR04PYY' WHERE id=80336;")
            cur.execute("UPDATE products SET ticker='F0GBR04PYX' WHERE id=81547;")
            cur.execute("UPDATE products SET ticker='F0GBR04JXU' WHERE id=81549;")
            cur.execute("UPDATE products SET ticker='F0GBR04J69' WHERE id=81553;")
            cur.execute("UPDATE products SET ticker='F0000044PM' WHERE id=81554;")
            cur.execute("UPDATE products SET ticker='F0000044PN' WHERE id=81555;")
            cur.execute("UPDATE products SET ticker='F0GBR060US' WHERE id=81557;")
            cur.execute("UPDATE products SET ticker='F0GBR04K0Y' WHERE id=81559;")
            cur.execute("UPDATE products SET ticker='F0GBR04CV1' WHERE id=77084;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q0A' WHERE id=77318;")
            cur.execute("UPDATE products SET ticker='F0GBR04FJC' WHERE id=77363;")
            cur.execute("UPDATE products SET ticker='F000003XI5' WHERE id=80617;")
            cur.execute("UPDATE products SET ticker='F0000040IY' WHERE id=80692;")
            cur.execute("UPDATE products SET ticker='F000005HJR' WHERE id=77173;")
            cur.execute("UPDATE products SET ticker='F0GBR04CUE' WHERE id=80814;")
            cur.execute("UPDATE products SET ticker='F0GBR04K1E' WHERE id=80826;")
            cur.execute("UPDATE products SET ticker='F0GBR04GEM' WHERE id=80827;")
            cur.execute("UPDATE products SET ticker='F0GBR04JVK' WHERE id=80828;")
            cur.execute("UPDATE products SET ticker='F0GBR04ITF' WHERE id=80618;")
            cur.execute("UPDATE products SET ticker='F0GBR04JY6' WHERE id=80616;")
            cur.execute("UPDATE products SET ticker='F000002XSJ' WHERE id=81052;")
            cur.execute("UPDATE products SET ticker='F0GBR04VS4' WHERE id=81055;")
            cur.execute("UPDATE products SET ticker='F0GBR04JV2' WHERE id=81056;")
            cur.execute("UPDATE products SET ticker='F0GBR04JY4' WHERE id=81054;")
            cur.execute("UPDATE products SET ticker='F0GBR05SK9' WHERE id=81057;")
            cur.execute("UPDATE products SET ticker='F0GBR04JSI' WHERE id=81061;")
            cur.execute("UPDATE products SET ticker='F0GBR04CUV' WHERE id=77562;")
            cur.execute("UPDATE products SET ticker='F000003Y1N' WHERE id=77612;")
            cur.execute("UPDATE products SET ticker='F000003Y1O' WHERE id=80620;")
            cur.execute("UPDATE products SET ticker='F000003Y1P' WHERE id=80622;")
            cur.execute("UPDATE products SET ticker='F0GBR04G5S' WHERE id=77174;")
            cur.execute("UPDATE products SET ticker='F0GBR04K2X' WHERE id=77175;")
            cur.execute("UPDATE products SET ticker='F0GBR04J7S' WHERE id=81179;")
            cur.execute("UPDATE products SET ticker='F00000M9JF' WHERE id=81211;")
            cur.execute("UPDATE products SET ticker='F0GBR04J80' WHERE id=81212;")
            cur.execute("UPDATE products SET ticker='F0GBR05V86' WHERE id=77226;")
            cur.execute("UPDATE products SET ticker='F0GBR04JLF' WHERE id=77227;")
            cur.execute("UPDATE products SET ticker='F0GBR04JEK' WHERE id=77714;")
            cur.execute("UPDATE products SET ticker='F0GBR04JEI' WHERE id=81180;")
            cur.execute("UPDATE products SET ticker='F0GBR05T2M' WHERE id=81181;")
            cur.execute("UPDATE products SET ticker='F000002IK6' WHERE id=81182;")
            cur.execute("UPDATE products SET ticker='F0GBR0526G' WHERE id=81183;")
            cur.execute("UPDATE products SET ticker='F0GBR054ES' WHERE id=81315;")
            cur.execute("UPDATE products SET ticker='F000002661' WHERE id=81316;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q66' WHERE id=77276;")
            cur.execute("UPDATE products SET ticker='F00000GZW1' WHERE id=77277;")
            cur.execute("UPDATE products SET ticker='F0000020CW' WHERE id=77278;")
            cur.execute("UPDATE products SET ticker='F0GBR05620' WHERE id=77414;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5R' WHERE id=81379;")
            cur.execute("UPDATE products SET ticker='F0GBR05S6N' WHERE id=77366;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5Y' WHERE id=77320;")
            cur.execute("UPDATE products SET ticker='F0GBR04JRD' WHERE id=77321;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q64' WHERE id=77322;")
            cur.execute("UPDATE products SET ticker='F0GBR05TU4' WHERE id=77324;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5U' WHERE id=77325;")
            cur.execute("UPDATE products SET ticker='F0GBR05TC4' WHERE id=77326;")
            cur.execute("UPDATE products SET ticker='F0GBR04JR4' WHERE id=77365;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5V' WHERE id=81344;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5S' WHERE id=81345;")
            cur.execute("UPDATE products SET ticker='F00000LMU1' WHERE id=77367;")
            cur.execute("UPDATE products SET ticker='F00000MEE5' WHERE id=81563;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5Q' WHERE id=77412;")
            cur.execute("UPDATE products SET ticker='F0GBR05S6O' WHERE id=81377;")
            cur.execute("UPDATE products SET ticker='F00000NO7Q' WHERE id=81375;")
            cur.execute("UPDATE products SET ticker='F0GBR04JR2' WHERE id=81378;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q61' WHERE id=81381;")
            cur.execute("UPDATE products SET ticker='F000000ASA' WHERE id=81382;")
            cur.execute("UPDATE products SET ticker='F000002ODB' WHERE id=77319;")
            cur.execute("UPDATE products SET ticker='F00000LM91' WHERE id=81384;")
            cur.execute("UPDATE products SET ticker='F0000024NE' WHERE id=81385;")
            cur.execute("UPDATE products SET ticker='F0GBR04ZKG' WHERE id=81386;")
            cur.execute("UPDATE products SET ticker='F0GBR04VSI' WHERE id=81387;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q5O' WHERE id=81389;")
            cur.execute("UPDATE products SET ticker='F0GBR05WM1' WHERE id=77413;")
            cur.execute("UPDATE products SET ticker='F0GBR05UYP' WHERE id=81570;")
            cur.execute("UPDATE products SET ticker='F00000H0CQ' WHERE id=81577;")
            cur.execute("UPDATE products SET ticker='F0GBR04EZ6' WHERE id=81581;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q26' WHERE id=81582;")
            cur.execute("UPDATE products SET ticker='F0GBR04Q1R' WHERE id=81583;")
            cur.execute("UPDATE products SET ticker='FOUSA06PHG' WHERE id=81586;")
            cur.execute("UPDATE products SET ticker='F000000K6F' WHERE id=77415;")
            cur.execute("UPDATE products SET ticker='F0GBR04LQ6' WHERE id=77514;")
            cur.execute("UPDATE products SET ticker='F0GBR04LQ2' WHERE id=77516;")
            cur.execute("UPDATE products SET ticker='F0GBR04JE8' WHERE id=77617;")
            cur.execute("UPDATE products SET ticker='F000000K65' WHERE id=81585;")
            cur.execute("UPDATE products SET ticker='F00000064T' WHERE id=77667;")
            cur.execute("UPDATE products SET ticker='F000000E7L' WHERE id=77668;")
            cur.execute("UPDATE products SET ticker='F0GBR06PPM' WHERE id=77669;")
            cur.execute("UPDATE products SET ticker='F0GBR0604M' WHERE id=77670;")
            cur.execute("UPDATE products SET ticker='F0GBR0604N' WHERE id=77671;")
            cur.execute("UPDATE products SET ticker='F0GBR06PPO' WHERE id=80829;")
            cur.execute("UPDATE products SET ticker='F0GBR0604O' WHERE id=80852;")
            cur.execute("UPDATE products SET ticker='F0GBR04KMC' WHERE id=80857;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201701140716)      
            
        if self.dbversion<201703140608:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=%s where id=%s;", (True, 80262))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76250))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81127))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81129))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 80245))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 80246))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 80392))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81221))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 80201))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 79076))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77462))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75659))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201703140608)         
            
            
        if self.dbversion<201703310608:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81715, 'Deutsche Floating Rate Notes LC', 'LU0034353002 ', 'EUR', 2, '|f_cat_money|', '', None, None, None, 0, 'c', 1, 5, 'F0GBR04NQN', None,[8, ], "", False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81716, 'Aviva Investors Sterling Liquidity Fund 1 GBP Inc', 'IE0031619269', 'GBP', 2, '|f_cat_money|', '', None, None, None, 0, 'c', 1, 4, 'F0GBR06KUK', None,[8, ], "", False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81717, 'Amundi Cash Corporate IC', 'FR0010251660', 'EUR', 2, '|f_cat_money|', '', None, None, None, 0, 'c', 1, 3, 'F0GBR06QIE', None,[8, ], "", False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201703310608)         
                        
        if self.dbversion<201705052007:
            cur=self.mem.con.cursor()
            cur.execute("update products set percentage=%s where id=%s;", (0, 77408))
            cur.execute("update products set leveraged=%s where id=%s;", (0, 81715))
            cur.execute("update products set leveraged=%s where id=%s;", (0, 81716))
            cur.execute("update products set leveraged=%s where id=%s;", (0, 81717))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201705052007)         
        if self.dbversion<201705052014:
            cur=self.mem.con.cursor()
            cur.execute("update products set percentage=%s where id=%s;", (0, 81479))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201705052014)         
            
        if self.dbversion<201706221141:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, ticker, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81718, 'Renta 4 Renta Fija Corto PLazo FI', 'ES0176954008 ', 'EUR', 2, '|f_cat_money|', '', None, None, None, 0, 'c', 1, 1, 'F00000PUJZ', None,[8, ], "", False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201706221141)         
        if self.dbversion<201706231332:
            cur=self.mem.con.cursor()
            cur.execute("update products set ticker=%s where id=%s;", ('A3M.MC', 78384))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201706231332)         
        if self.dbversion<201708030922:
            cur=self.mem.con.cursor()
            cur.execute("DROP FUNCTION historic(text)")
            cur.execute("DROP FUNCTION intraday(text, date)")
            cur.execute("DROP FUNCTION inversion_acciones(integer,date)")
            cur.execute("DROP FUNCTION inversion_acciones_saldo(integer,date,numeric)")
            cur.execute("DROP FUNCTION inversion_saldo_segun_tpcvariable()")
            cur.execute("DROP FUNCTION inversion_type(text)")
            cur.execute("DROP FUNCTION multiout_simple_setof(integer)")
            cur.execute("DROP FUNCTION quote2(integer[], timestamptz)")
            cur.execute("DROP FUNCTION quote_endmonth(text)")          
            cur.execute("DROP FUNCTION quote(integer, date)") 
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201708030922)         
        if self.dbversion<201708031821:
            cur=self.mem.con.cursor()
            cur.execute("DROP FUNCTION penultimate(integer)")         
            cur.execute("DROP FUNCTION penultimate(integer,date)")          
            cur.execute("""CREATE OR REPLACE FUNCTION penultimate(INOUT id integer, IN date date, OUT quote numeric (100,6), OUT datetime timestamptz, OUT searched timestamptz )
    LANGUAGE plpgsql
    AS $$
BEGIN
    searched := format( '%s 23:59:59.999999', penultimate.date-integer '1')::timestamptz;
    SELECT quotes.quote, quotes.datetime  INTO penultimate.quote, penultimate.datetime FROM quotes where quotes.id= penultimate.id and quotes.datetime <= searched order by quotes.datetime desc limit 1;
END;
$$;""")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201708031821)        
        if self.dbversion<201708031837:
            cur=self.mem.con.cursor()
            cur.execute("DROP FUNCTION quote(integer,timestamptz)")         
            cur.execute("DROP FUNCTION quote(integer[],timestamptz)")          
            cur.execute("""CREATE OR REPLACE FUNCTION quote(INOUT id integer, INOUT datetime timestamptz, OUT quote numeric (100,6),  OUT searched timestamptz )
    LANGUAGE plpgsql
    AS $$
BEGIN
    searched := quote.datetime;
    SELECT quotes.quote, quotes.datetime  INTO quote.quote, quote.datetime FROM quotes where quotes.id= quote.id and quotes.datetime <= quote.datetime order by quotes.datetime desc limit 1;
END;
$$;""")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201708031837)        
            
        if self.dbversion<201708031858:
            cur=self.mem.con.cursor()
            cur.execute("DROP PROCEDURAL LANGUAGE plpythonu")
            cur.execute("DROP TYPE dblink_pkey_results")
            cur.execute("DROP TYPE quote")
            cur.execute("DROP TYPE quote_type")
            cur.execute("DROP TYPE quotehistoric_type")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201708031858)         
            
        if self.dbversion<201708040648:
            cur=self.mem.con.cursor()
            cur.execute("""
CREATE OR REPLACE FUNCTION penultimate(INOUT id integer, date date, OUT quote numeric, OUT datetime timestamp with time zone, OUT searched timestamp with time zone) RETURNS record
    LANGUAGE plpgsql
    AS $$
DECLARE
    last_datetime timestamptz;
BEGIN
    searched := format( '%s 23:59:59.999999', penultimate.date)::timestamptz;
    select quotes.datetime INTO last_datetime from quote(penultimate.id, searched) quotes;
    searched := format( '%s 23:59:59.999999', last_datetime::date-integer '1')::timestamptz;
    SELECT quotes.quote, quotes.datetime  INTO penultimate.quote, penultimate.datetime FROM quotes where quotes.id= penultimate.id and quotes.datetime <= searched order by quotes.datetime desc limit 1;
END;
$$;""")
            cur.execute("""
CREATE OR REPLACE FUNCTION last_penultimate_lastyear(INOUT id integer, OUT last_datetime timestamptz, OUT last numeric(100,6), OUT penultimate_datetime timestamptz, OUT penultimate numeric(100,6),OUT lastyear_datetime timestamptz, OUT lastyear numeric(100,6) )
    LANGUAGE plpgsql
    AS $$
DECLARE
    ly timestamptz;
BEGIN
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.last, last_penultimate_lastyear.last_datetime FROM quote(id,now()) quotes;
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.penultimate, last_penultimate_lastyear.penultimate_datetime FROM penultimate(id,now()::date) quotes;
    ly := format( '%s-12-31 23:59:59.999999', EXTRACT(YEAR FROM TIMESTAMP 'now()')-1);
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.lastyear, last_penultimate_lastyear.lastyear_datetime FROM quote(id,ly) quotes;
END;
$$;

""")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201708040648)         
            

        if self.dbversion<201708040826:
            cur=self.mem.con.cursor()
            cur.execute("""
CREATE OR REPLACE FUNCTION penultimate(INOUT id integer, IN date date, OUT quote numeric, OUT datetime timestamp with time zone, OUT searched timestamp with time zone) RETURNS record
    LANGUAGE plpgsql
    AS $$
DECLARE
    last_datetime timestamptz;
    minus date;
BEGIN
    searched:=make_timestamptz(EXTRACT(YEAR FROM penultimate.date)::integer,EXTRACT(MONTH FROM penultimate.date)::integer, EXTRACT(DAY FROM penultimate.date)::integer, 23, 59, 59.999999::double precision) ;
    select quotes.datetime INTO last_datetime from quote(penultimate.id, searched) quotes;
    minus:=last_datetime::date - integer '1';
    searched:=make_timestamptz(EXTRACT(YEAR FROM minus)::integer,EXTRACT(MONTH FROM minus)::integer, EXTRACT(DAY FROM minus)::integer, 23, 59, 59.999999::double precision) ;
    SELECT quotes.quote, quotes.datetime  INTO penultimate.quote, penultimate.datetime FROM quotes where quotes.id= penultimate.id and quotes.datetime <= searched order by quotes.datetime desc limit 1;
END;
$$;
""")
            cur.execute("""
CREATE OR REPLACE FUNCTION last_penultimate_lastyear(INOUT id integer, OUT last_datetime timestamptz, OUT last numeric(100,6), OUT penultimate_datetime timestamptz, OUT penultimate numeric(100,6),OUT lastyear_datetime timestamptz, OUT lastyear numeric(100,6) )
    LANGUAGE plpgsql
    AS $$
DECLARE
    ly timestamptz;
BEGIN
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.last, last_penultimate_lastyear.last_datetime FROM quote(id,now()) quotes;
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.penultimate, last_penultimate_lastyear.penultimate_datetime FROM penultimate(id,now()::date) quotes;
    ly:=make_timestamptz((EXTRACT(YEAR FROM  now())-1)::integer, 12, 31, 23, 59, 59.999999::double precision) ;
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.lastyear, last_penultimate_lastyear.lastyear_datetime FROM quote(id,ly) quotes;
END;
$$;
""")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201708040826)        
        if self.dbversion<201708120552:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81691 ))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75290 ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201708120552)       
        if self.dbversion<201709220607:
            cur=self.mem.con.cursor()
            cur.execute("update products set leveraged=%s where id=%s;", (0, 81718))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201709220607)       
        if self.dbversion<201711281815:
            cur=self.mem.con.cursor()
            cur2=self.mem.con.cursor()
            cur.execute("alter table products add column tickers text[]")
            cur.execute("select id, ticker, type from products where ticker is not null")
            for row in cur.fetchall():
                if row['ticker']==None or row['ticker']=="":
                    cur2.execute('update products set tickers=array[Null, Null,Null,Null] where id=%s', (row['id'], ))
                elif row['type']==2:
                    cur2.execute('update products set tickers=array[Null, %s,Null,Null] where id=%s', (row['ticker'], row['id']))
                elif row['type']==8:
                    cur2.execute('update products set tickers=array[Null, Null,Null,%s] where id=%s', (row['ticker'], row['id']))
                else:
                    cur2.execute('update products set tickers=array[%s, Null,Null,Null] where id=%s', (row['ticker'], row['id']))
            cur2.execute("update products set tickers=array[Null, Null, Null, Null] where ticker is null")
            cur2.execute("alter table products drop column ticker")
            self.mem.con.commit()
            cur2.close()
            cur.close()
            self.set_database_version(201711281815)       
            
        if self.dbversion<201711281932:
            cur=self.mem.con.cursor()
            cur.execute("update products set isin=Null where  length(isin)<3")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201711281932)       
            
        if self.dbversion<201711300735:
            cur=self.mem.con.cursor()
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81716))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 75814))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 78538))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76094))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77282))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76302))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 76543))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77523))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 79200))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 77072))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81359))
            cur.execute("update products set isin=%s where id=%s", ('LU1598757687', 81101))
            cur.execute("update products set tickers[%s]=%s where id=%s", (eTickerPosition.Google.postgresql(),"INDEXCBOE:SPX", 81083))
            cur.execute("update products set tickers[%s]=%s where id=%s", (eTickerPosition.Google.postgresql(),"INDEXCBOE:VIX", 81090))
            cur.execute("update products set tickers[%s]=%s where id=%s", (eTickerPosition.Google.postgresql(),"INDEXNASDAQ:NDX", 79788))
            cur.execute("update products set tickers[%s]=%s where id=%s", (eTickerPosition.Google.postgresql(),"INDEXNIKKEI:NI225", 79834))
            cur.execute("update products set tickers[%s]=%s where id=%s", (eTickerPosition.Google.postgresql(),"INDEXSTOXX:SX5E", 75540))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201711300735)          
               
        if self.dbversion<201801230313:
            cur=self.mem.con.cursor()
            cur.execute("""
CREATE  OR REPLACE FUNCTION is_price_variation_in_time(p_id_products integer, p_percentage double precision, p_datetime timestamp with time zone) RETURNS boolean
    LANGUAGE plpgsql
    AS $$DECLARE
    result boolean;
    initial numeric(18,6);
    final numeric(18,6);
        variation numeric(18,6);
BEGIN
    result := False;
    SELECT quotes.quote  INTO final FROM quotes where quotes.id= p_id_products and quotes.datetime <= now() order by quotes.datetime desc limit 1;
    SELECT quotes.quote  INTO initial FROM quotes where quotes.id= p_id_products and quotes.datetime <= p_datetime order by quotes.datetime desc limit 1;
    IF initial=0 THEN
            return False;
        END IF;
        
        variation:=100*(final-initial)/initial;
        --Raise Notice 'hello world % %: % (%)', initial, final, variation, p_percentage;
    -- PERCENTAGE POSITIVE
    IF p_percentage>0 AND variation > p_percentage THEN
        return True;
    END IF;
    -- PERCENTAGE NEGATIVE
    IF p_percentage<0 AND variation < p_percentage THEN
        return True;
    END IF;
    RETURN result;
END;
$$;""")
            cur.execute("""COMMENT ON FUNCTION is_price_variation_in_time(p_id_products integer, p_percentage double precision, p_datetime timestamp with time zone) IS 'Returns True, if percentage is negative and variation between timestamp price and current product price is less than percentage
Returns True, if percentage is positive and variation between timestamp price and current product price is bigger than percentage
Return False, in other cases';""")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201801230313)                
            
            
        if self.dbversion<201801250516:
            cur=self.mem.con.cursor()
            cur.execute("CREATE TABLE splits (id integer NOT NULL, datetime timestamp with time zone NOT NULL, products_id integer NOT NULL, before integer NOT NULL, after integer NOT NULL, comment text)")
            cur.execute("COMMENT ON TABLE splits IS 'Split and contrasplit product operations'")
            cur.execute("CREATE SEQUENCE splits_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1")
            cur.execute("ALTER TABLE ONLY splits ALTER COLUMN id SET DEFAULT nextval('splits_id_seq'::regclass)")
            cur.execute("ALTER TABLE ONLY splits ADD CONSTRAINT splits_pk PRIMARY KEY (id)")
            cur.execute("CREATE INDEX splits_index_products_id ON splits USING btree (products_id)")
            cur.execute("ALTER TABLE ONLY splits ADD CONSTRAINT splits_fk_products_id FOREIGN KEY (products_id) REFERENCES products(id)")
            cur.execute("GRANT ALL ON SEQUENCE splits_id_seq TO xulpymoney_user;")
            cur.execute("GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE splits TO xulpymoney_user")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201801250516)       

            
        if self.dbversion<201803270802:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, tickers, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, array[Null, %s,Null,Null], %s, %s, %s, %s)",
                    (81719, 'Renta 4 Valor Relativo FI', 'ES0128522002 ', 'EUR', 2, '', '', None, None, None, 50, 'c', 1, 1, 'F00000H5PN', None, [8, ], "", False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, tickers, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, array[Null, %s,Null,Null], %s, %s, %s, %s)",
                    (81720, 'Renta 4 Nexus FI', 'ES0173268006 ', 'EUR', 2, '', '', None, None, None, 10, 'c', 1, 1, 'F00000LXSB', None, [8, ], "", False ))
            cur.execute("insert into products (id, name,  isin,  currency,  type,  agrupations,   web, address,  phone, mail, percentage, pci,  leveraged, stockmarkets_id, tickers, priority, priorityhistorical , comment,  obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, array[Null, %s,Null,Null], %s, %s, %s, %s)",
                    (81721, 'Renta 4 Foncuenta Ahorro FI', 'ES0173222003 ', 'EUR', 2, '', '', None, None, None, 10, 'c', 1, 1, 'F00000YGE9', None, [8, ], "", False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201803270802)         

        if self.dbversion<201805130811:
            cur=self.mem.con.cursor()
            cur.execute("CREATE SEQUENCE opportunities_seq  INCREMENT 1  MINVALUE 1  MAXVALUE 9223372036854775807  START 1  CACHE 1;")
            cur.execute("""
                CREATE TABLE opportunities (
                    id integer NOT NULL DEFAULT nextval('opportunities_seq'::regclass),  
                    date date NOT NULL,  
                    removed date,
                    execute date,
                    price numeric(100,2) NOT NULL,  
                    products_id integer NOT NULL,
                    CONSTRAINT opportunities_pk PRIMARY KEY (id),
                    CONSTRAINT opportunities_products_id_fk_products_id FOREIGN KEY (products_id) REFERENCES public.products (id) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT
                ) WITH (  OIDS=FALSE);
            """)
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805130811)            
            

        if self.dbversion<201805130938:
            cur=self.mem.con.cursor()
            cur.execute("alter table opportunities rename execute to executed;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805130938)
            
        if self.dbversion<201805241024:
            cur=self.mem.con.cursor()
            cur1=self.mem.con.cursor()
            cur.execute("select * from products where tickers[1] like '%.MC'")
            for row in cur:
                name=row['tickers'][0].split(".MC")[0]
                cur1.execute("update products set tickers[3]=%s where tickers[1]=%s", ("BME:"+name, row['tickers'][0]))
            cur1.close()
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805241024)
        if self.dbversion<201805241027:
            cur=self.mem.con.cursor()
            cur1=self.mem.con.cursor()
            cur.execute("select * from products where tickers[1] like '%.PA'")
            for row in cur:
                name=row['tickers'][0].split(".PA")[0]
                cur1.execute("update products set tickers[3]=%s where tickers[1]=%s", ("EPA:"+name, row['tickers'][0]))
            cur1.close()
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805241027)

        if self.dbversion<201805241028:
            cur=self.mem.con.cursor()
            cur1=self.mem.con.cursor()
            cur.execute("select * from products where tickers[1] like '%.DE'")
            for row in cur:
                name=row['tickers'][0].split(".DE")[0]
                cur1.execute("update products set tickers[3]=%s where tickers[1]=%s", ("ETR:"+name, row['tickers'][0]))
            cur1.close()
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805241028)
            
        if self.dbversion<201805241250:
            cur=self.mem.con.cursor()
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", ("AMS:INGA", "INGA.AS"))
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", ("INDEXBME:IB", "^IBEX"))
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", ("INDEXEURO:PX1 ", "^FCHI"))
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", ("INDEXDB:DAX", "^GDAXI"))
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", ("INDEXDJX:.DJI", "^DJI"))
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", ("INDEXFTSE:UKX", "^FTSE"))
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", ("INDEXFTSE:FTSEMIB", "FTSEMIB.MI"))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805241250)
        if self.dbversion<201805241335:
            cur=self.mem.con.cursor()
            cur.execute("update products set tickers[3]=%s where tickers[1]=%s", (None, "IBEXA.MC"))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805241335)
        if self.dbversion<201805250445:
            cur=self.mem.con.cursor()
            cur.execute("update products set tickers[3]=%s where id=%s", ("INDEXHANGSENG:HSI", 81091))
            cur.execute("update products set tickers[3]=%s where id=%s", ("INDEXNASDAQ:.IXIC", 81088))
            cur.execute("update products set tickers[3]=%s where id=%s", ("INDEXEURO:PSI20", 78127))
            cur.execute("update products set obsolete=%s where id=%s;", (True, 81103))
            cur.execute("update products set agrupations=%s where id=%s", ('|MERCADOCONTINUO|', 81103))
            cur.execute("update products set agrupations=%s where id=%s", ('|MERCADOCONTINUO|', 78269))
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, priority, priorityhistorical, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81722, 'Cellnex Telecomm', 'ES0105066007', 'EUR', 1, '|IBEX|MERCADOCONTINUO|', 'https://www.cellnextelecom.com/', None, None, None, 100, 'c', 0, 1, ["CLNX.MC", None, "BME:CLNX", None], [9, ],[3, ], None, False ))
            cur.execute("update products set agrupations=%s where id=%s", ('|MERCADOCONTINUO|', 78907))
            cur.execute("update products set agrupations=%s where id=%s", ('|MERCADOCONTINUO|', 79037))
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, priority, priorityhistorical, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81723, 'Inmobiliaria Colonial', 'ES0139140174', 'EUR', 1, '|IBEX|MERCADOCONTINUO|', 'https://www.inmocolonial.com/', None, None, None, 100, 'c', 0, 1, ["COL.MC", None, "BME:COL", None], [9, ],[3, ], None, False ))
            cur.execute("update products set agrupations=%s where id=%s", ('|IBEX|MERCADOCONTINUO|', 79277))
            cur.execute("update products set agrupations=%s where id=%s", ('|MERCADOCONTINUO|', 79299))
            cur.execute("update products set name=%s where id=%s", ('SIEMENS GAMESA RENEWABLE ENERGY', 79037))
            cur.execute("update products set agrupations=%s where id=%s", ('|IBEX|MERCADOCONTINUO|', 79397))
            cur.execute("update products set agrupations=%s where id=%s", ('|MERCADOCONTINUO|', 81534))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201805250445)
        if self.dbversion<201806090913:
            cur=self.mem.con.cursor()
            cur.execute("update products set name=%s where id=%s", ('Lyxor Ibex 35 Inverso Diario UCITS ETF Acc', 79230))
            cur.execute("update products set name=%s,leveraged=%s where id=%s", ('Lyxor Ibex 35 Doble Inverso Diario UCITS ETF Acc', eLeverageType.X2,  79217))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201806090913)
        if self.dbversion<201806111657:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, priority, priorityhistorical, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81724, 'Pictet-Multi Asset Global Opportunities R EUR', 'LU0941349275', 'EUR', 2, '', None, None, None, None, 100, 'c', 1, 3, [None, 'F00000QGX8', None, None], None ,[8, ], None, False ))
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, priority, priorityhistorical, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81725, 'Old Mutual Glb Eq Abs Rt A Eur Hdg Acc', 'IE00BLP5S460', 'EUR', 2, '', None, None, None, None, 100, 'c', 1, 3, [None, 'F00000TG3D', None, None], None ,[8, ], None, False ))
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, priority, priorityhistorical, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81726, 'Amundi Fds Ii Multi-Strat Gr A Eur Nd', 'LU0363629790', 'EUR', 2, '', None, None, None, None, 100, 'c', 1, 3, [None, 'F0000022V6', None, None], None ,[8, ], None, False ))
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, priority, priorityhistorical, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81727, 'BlackRock Strategic Funds BSF Americas Diversified Equity Absolute Return Fund A2 EUR Hedged', 'LU0725892466', 'EUR', 2, '', None, None, None, None, 100, 'c', 1, 3, [None, 'F00000NR69', None, None], None ,[8, ], None, False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201806111657)
        if self.dbversion<201806260819:
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE products DROP CONSTRAINT products_fk_stockmarkets_id")
            cur.execute("DROP TABLE stockmarkets")
            cur.close()
            self.mem.con.commit() 
            self.set_database_version(201806260819)     
        if self.dbversion<201806270926:
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE products DROP COLUMN priority")
            cur.execute("ALTER TABLE products DROP COLUMN priorityhistorical")
            cur.close()
            self.mem.con.commit() 
            self.set_database_version(201806270926)
        if self.dbversion<201806281028:
            cur=self.mem.con.cursor()
            cur.execute("update products set percentage=0 where id in (81724,81725,81726,81727)")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201806281028)
        if self.dbversion<201808300607:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81728, 'BONO ESTADO ESPAÑOL 3,45 30072066', 'ES00000128E2', 'EUR', 7, '', None, None, None, None, 0, 'c', 1, 1, [None, None, None, None], None, False ))
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81729, 'BONO ESTADO ESPAÑOL 1,4 30072028', 'ES0000012B88', 'EUR', 7, '', None, None, None, None, 0, 'c', 1, 1, [None, None, None, None], None, False ))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201808300607)
        if self.dbversion<201809191828:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81730, 'PROSHARES ULTRA GOLD', 'US74347W6012', 'EUR', int(eProductType.ETF), '', 'http://www.proshares.com', None, None, None, 100, 'c', int(eLeverageType.X2), 2, ['UGL', None, 'NYSEARCA: UGL', None], None, False))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201809191828)
        if self.dbversion<201809191900:
            cur=self.mem.con.cursor()
            cur.execute("UPDATE products SET currency='USD' WHERE ID=81730")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201809191900)
        if self.dbversion<201809250501:
            cur=self.mem.con.cursor()
            cur.execute("insert into products (id, name, isin, currency, type, agrupations, web, address, phone, mail, percentage, pci, leveraged, stockmarkets_id, tickers, comment, obsolete) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    (81731, 'MULTI X5 IBEX35 INVERSO 20181221', 'LU1731826605', 'EUR', int(eProductType.Warrant), '', 'https://bolsa.societegenerale.es/', None, None, None, 100, 'p', int(eLeverageType.X5), 3, [None, None, None, None], None, False))
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201809250501)
        if self.dbversion<201810272132:
            cur=self.mem.con.cursor()
            cur.execute("update products set leveraged=-1 where leveraged=1 and id<81719")
            cur.execute("update products set leveraged=1 where leveraged=0")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201810272132)
        if self.dbversion<201812070558:
            cur=self.mem.con.cursor()
            cur.execute("alter table products add column high_low boolean")
            cur.execute("CREATE SEQUENCE high_low_contract_seq  INCREMENT 1  MINVALUE 1  MAXVALUE 9223372036854775807  START 1  CACHE 1;")
            cur.execute("""
CREATE TABLE high_low_contract (
    id integer NOT NULL DEFAULT nextval('high_low_contract_seq'::regclass), 
    products_id integer NOT NULL,  
    datetime timestamp with time zone NOT NULL,  
    guarantee numeric(100,2) NOT NULL,
    adjustment numeric(100,2) NOT NULL,
    commission numeric(100,2) NOT NULL,
    interest numeric(100,2) NOT NULL,
    CONSTRAINT high_low_contract_pk PRIMARY KEY (id),
    CONSTRAINT high_low_contract_fk_products_id FOREIGN KEY (products_id) REFERENCES products (id) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT
) WITH (  OIDS=FALSE);
            """)
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812070558)
        if self.dbversion<201812070708:#Update user products high_low=false
            cur=self.mem.con.cursor()
            cur.execute("update products set high_low=false where id<0")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812070708)
        if self.dbversion<201812071223:#Update user products high_low=false
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE high_low_contract DROP CONSTRAINT high_low_contract_fk_products_id")
            cur.execute("ALTER TABLE high_low_contract RENAME products_id TO investments_id")           
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_investments_id FOREIGN KEY (investments_id) REFERENCES inversiones (id_inversiones) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812071223)
        if self.dbversion<201812071303:#Update user products high_low=false
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE high_low_contract ADD COLUMN guarantee_ao integer")
            cur.execute("ALTER TABLE high_low_contract ADD COLUMN adjustment_ao integer")
            cur.execute("ALTER TABLE high_low_contract ADD COLUMN comission_ao integer")
            cur.execute("ALTER TABLE high_low_contract ADD COLUMN interest_ao integer")  
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_guarantee_ao FOREIGN KEY (guarantee_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_adjustment_ao FOREIGN KEY (adjustment_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_comission_ao FOREIGN KEY (comission_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_interest_ao FOREIGN KEY (interest_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE RESTRICT")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812071303)
        if self.dbversion<201812071715:
            cur=self.mem.con.cursor()            
            cur.execute("insert into conceptos values(68,%s,%s,false)",(QApplication.translate("Core","HL adjustment income"), eOperationType.Income))    
            cur.execute("insert into conceptos values(69,%s,%s,false)",(QApplication.translate("Core","HL adjustment expense"), eOperationType.Expense))  
            cur.execute("insert into conceptos values(70,%s,%s,false)",(QApplication.translate("Core","HL Guarantee payment"), eOperationType.Expense))  
            cur.execute("insert into conceptos values(71,%s,%s,false)",(QApplication.translate("Core","HL Guarantee return"), eOperationType.Income))     
            cur.execute("insert into conceptos values(72,%s,%s,false)",(QApplication.translate("Core","HL Operation commission"), eOperationType.Expense))     
            cur.execute("insert into conceptos values(73,%s,%s,false)",(QApplication.translate("Core","HL Paid interest"), eOperationType.Expense))     
            cur.execute("insert into conceptos values(74,%s,%s,false)",(QApplication.translate("Core","HL Received interest"), eOperationType.Income))     
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812071715)     
        if self.dbversion<201812080918:
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE high_low_contract RENAME comission_ao TO commission_ao")
            cur.execute("ALTER TABLE high_low_contract ADD COLUMN currency_conversion numeric(10,6) NOT NULL DEFAULT 1")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812080918)
        if self.dbversion<201812110601:
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE opportunities RENAME price TO entry")
            cur.execute("ALTER TABLE opportunities ADD COLUMN target numeric(100,2)")
            cur.execute("ALTER TABLE opportunities ADD COLUMN stoploss numeric(100,2)")
            cur.execute("ALTER TABLE opportunities ADD COLUMN pci character(1) default 'c'::bpchar")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812110601)
        if self.dbversion<201812110755:
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE opportunities DROP COLUMN pci")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812110755)
        if self.dbversion<201812141037:
            cur=self.mem.con.cursor()
            cur.execute("ALTER TABLE high_low_contract DROP CONSTRAINT high_low_contract_fk_guarantee_ao")
            cur.execute("ALTER TABLE high_low_contract DROP CONSTRAINT high_low_contract_fk_adjustment_ao")
            cur.execute("ALTER TABLE high_low_contract DROP CONSTRAINT high_low_contract_fk_comission_ao")
            cur.execute("ALTER TABLE high_low_contract DROP CONSTRAINT high_low_contract_fk_interest_ao")
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_guarantee_ao FOREIGN KEY (guarantee_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE NO ACTION")
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_adjustment_ao FOREIGN KEY (adjustment_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE NO ACTION")
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_comission_ao FOREIGN KEY (commission_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE NO ACTION")
            cur.execute("ALTER TABLE high_low_contract ADD CONSTRAINT high_low_contract_fk_interest_ao FOREIGN KEY (interest_ao) REFERENCES opercuentas (id_opercuentas) MATCH SIMPLE  ON UPDATE NO ACTION ON DELETE NO ACTION")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812141037)
        if self.dbversion<201812141325:#Update user products high_low=false
            cur=self.mem.con.cursor()
            cur.execute("update conceptos set id_tiposoperaciones=11 where id_conceptos in (68,69,70,71)")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201812141325)
        if self.dbversion<201901200612:#Add global to control products.xlsx update. Added short field to opportunities
            cur=self.mem.con.cursor()
            cur.execute("INSERT INTO globals (id_globals,global, value) values (2, 'Version of products.xlsx', NULL)")
            cur.execute("ALTER TABLE opportunities ADD COLUMN short BOOLEAN DEFAULT FALSE NOT NULL")
            cur.execute("COMMENT ON COLUMN opportunities.short IS 'If true is a short investment strategy. If false is a long one'")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201901200612)
        if self.dbversion<201902140545:#Add global to control products.xlsx update. Added short field to opportunities
            cur=self.mem.con.cursor()
            
            cur.execute("drop FUNCTION public.last_penultimate_lastyear(INOUT id integer, OUT last_datetime timestamp with time zone, OUT last numeric, OUT penultimate_datetime timestamp with time zone, OUT penultimate numeric, OUT lastyear_datetime timestamp with time zone, OUT lastyear numeric)")
            cur.execute("""
CREATE FUNCTION public.last_penultimate_lastyear(INOUT id integer, IN at_datetime timestamp with time zone, OUT last_datetime timestamp with time zone, OUT last numeric, OUT penultimate_datetime timestamp with time zone, OUT penultimate numeric, OUT lastyear_datetime timestamp with time zone, OUT lastyear numeric) RETURNS record
    LANGUAGE plpgsql
    AS $$
DECLARE
    ly timestamptz;
BEGIN
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.last, last_penultimate_lastyear.last_datetime FROM quote(id, at_datetime) quotes;
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.penultimate, last_penultimate_lastyear.penultimate_datetime FROM penultimate(id, at_datetime::date) quotes;
    ly:=make_timestamptz((EXTRACT(YEAR FROM  at_datetime)-1)::integer, 12, 31, 23, 59, 59.999999::double precision) ;
    SELECT quotes.quote, quotes.datetime  INTO last_penultimate_lastyear.lastyear, last_penultimate_lastyear.lastyear_datetime FROM quote(id,ly) quotes;
END;
$$;""")
            cur.execute("ALTER FUNCTION public.last_penultimate_lastyear(INOUT id integer, IN at_datetime timestamp with time zone, OUT last_datetime timestamp with time zone, OUT last numeric, OUT penultimate_datetime timestamp with time zone, OUT penultimate numeric, OUT lastyear_datetime timestamp with time zone, OUT lastyear numeric) OWNER TO postgres;")
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201902140545)
        if self.dbversion<201905162140:
            cur=self.mem.con.cursor()
            cur.execute("insert into conceptos values(75,%s,%s,false)",(QApplication.translate("Core","Rollover Paid"), eOperationType.Expense))  
            cur.execute("insert into conceptos values(76,%s,%s,false)",(QApplication.translate("Core","Rollover Received"), eOperationType.Income))     
            cur.close()
            self.mem.con.commit()
            self.set_database_version(201905162140)
        """       WARNING                    ADD ALWAYS LAST UPDATE CODE                         WARNING
        AFTER EXECUTING I MUST RUN SQL UPDATE SCRIPT TO UPDATE FUTURE INSTALLATIONS
    OJO EN LOS REEMPLAZOS MASIVOS PORQUE UN ACTIVE DE PRODUCTS LUEGO PASA A LLAMARSE AUTOUPDATE PERO DEBERA MANTENERSSE EN SU MOMENTO TEMPORAL"""  
        print ("**** Database already updated")
