engine.execute("CREATE INDEX ON comp.io_qbuysell (gvkey, datadate)") updated = wrds_update("wrds_segmerged", "comp", engine, wrds_id) if updated: engine.execute("CREATE INDEX ON comp.wrds_segmerged (gvkey, datadate);") updated = wrds_update("names", "comp", engine, wrds_id) if updated: engine.execute("CREATE INDEX ON comp.names (gvkey)") secm_updated = wrds_update("secm", "comp", engine, wrds_id) if secm_updated: engine.execute("CREATE INDEX ON comp.secm (gvkey, datadate)") if secm_updated or company_updated: run_file_sql("comp/create_ciks.sql", engine) updated = wrds_update("secd", "comp", engine, wrds_id) if updated: engine.execute("CREATE INDEX ON comp.secd (gvkey, datadate)") updated = wrds_update("spind_mth", "comp", engine, wrds_id) if updated: engine.execute("CREATE INDEX ON comp.spind_mth (gvkey, datadate)") updated = wrds_update("funda", "comp", engine, wrds_id, fix_missing=True, rename="do=do_")
sql_ermport = """ CREATE TABLE crsp.ermport ( date date, capn bigint, decret double precision ); """ res = engine.execute("DROP TABLE IF EXISTS crsp.ermport CASCADE") res = engine.execute(sql_ermport) p = get_process(sas_code, wrds_id) res = wrds_process_to_pg("ermport", "crsp", engine, p) run_file_sql("crsp/crsp_make_ermport1.sql", engine) if msi: engine.execute("CREATE INDEX ON crsp.msi (date)") if mport or msf or msi or msedelist: run_file_sql("crsp/crsp_make_mrets.sql", engine) # Update daily data dsf = wrds_update("dsf", "crsp", engine, wrds_id, fix_missing=True) if dsf: engine.execute("ALTER TABLE crsp.dsf ALTER permno TYPE integer") engine.execute("SET maintenance_work_mem='1999MB'") engine.execute("CREATE INDEX ON crsp.dsf (permno, date)") dsi = wrds_update("dsi", "crsp", engine, wrds_id)