diff options
Diffstat (limited to 'python/ack_checker.py')
| -rw-r--r-- | python/ack_checker.py | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/python/ack_checker.py b/python/ack_checker.py index 4b8ac068..a516ff9d 100644 --- a/python/ack_checker.py +++ b/python/ack_checker.py @@ -11,28 +11,32 @@ ftp.client.cwd("outgoing") date = datetime.date.today() files = [f for f in ftp.client.nlst() if f.startswith(f"Serenitas.ALL.{date:%Y%m%d}")] for f in files: - if "CreditDefaultSwapDeal" in f: - buf = BytesIO() - ftp.client.retrbinary("RETR " + f, buf.write) - buf.seek(0) - csv = reader(codecs.iterdecode(buf, "utf-8")) - for serenitas_id, action, dealtype, result, globeop_id, _, _ in csv: - if dealtype != "CreditDefaultSwapDeal": - continue + buf = BytesIO() + ftp.client.retrbinary("RETR " + f, buf.write) + buf.seek(0) + csv = reader(codecs.iterdecode(buf, "utf-8")) + for serenitas_id, action, dealtype, result, globeop_id, _, _ in csv: + if action == "NEW" and result == "Loaded": + globeop_id = int(globeop_id) + serenitas_id = int(serenitas_id[5:]) + if dealtype == "CreditDefaultSwapDeal": + with dawndb.cursor() as c: + c.execute( + "SELECT orig_attach FROM cds WHERE dealid=%s", (serenitas_id,) + ) + (attach,) = c.fetchone() + if attach is None: + continue - with dawndb.cursor() as c: - c.execute( - "SELECT orig_attach FROM cds WHERE dealid=%s", (serenitas_id,) - ) - (attach,) = c.fetchone() - if attach is None: - continue - if action == "NEW" and result == "Loaded": - globeop_id = int(globeop_id) - serenitas_id = int(serenitas_id[5:]) with dawndb.cursor() as c: c.execute( "INSERT INTO id_mapping VALUES(%s, %s, %s, %s)", (date, "CDS", serenitas_id, globeop_id), ) -dawndb.commit() + if dealtype == "SwaptionDeal": + with dawndb.cursor() as c: + c.execute( + "UPDATE swaptions SET globeop_id=%s WHERE dealid=%s", + (globeop_id, serenitas_id), + ) + dawndb.commit() |
