diff options
Diffstat (limited to 'python/report_ops')
| -rw-r--r-- | python/report_ops/custodians.py | 29 | ||||
| -rw-r--r-- | python/report_ops/misc.py | 1 |
2 files changed, 22 insertions, 8 deletions
diff --git a/python/report_ops/custodians.py b/python/report_ops/custodians.py index e225bb4d..cbf5c274 100644 --- a/python/report_ops/custodians.py +++ b/python/report_ops/custodians.py @@ -31,12 +31,14 @@ def upload_to_custodian(account, trade_date, upload, em): if any( [ old_row.identifier != row.identifier, - abs(old_row.principal_payment - row.principal_payment) > 1e-2, - abs(old_row.accrued_payment, row.accrued_payment) > 1e-2, + abs(float(old_row.principal_payment) - row.principal_payment) + > 1e-2, + abs(float(old_row.accrued_payment) - row.accrued_payment) + > 1e-2, ] ): old_trade = BondDeal.from_dict( - row._asdict() | old_row._asdict(), scaled=True + **(row._asdict() | old_row._asdict()), scaled=True ) custodian.push_trade(old_trade, "CANCEL") d.execute( @@ -50,8 +52,18 @@ def upload_to_custodian(account, trade_date, upload, em): ) else: continue - trade = BondDeal.from_dict(row._asdict(), scaled=True) - custodian.push_trade(trade, "NEW") + else: + d.execute( + "INSERT INTO bond_csv_upload (allocationid, identifier, principal_payment, accrued_payment) VALUES (%s, %s, %s, %s)", + ( + row.id, + row.identifier, + row.principal_payment, + row.accrued_payment, + ), + ) + trade = BondDeal.from_dict(**row._asdict(), scaled=True) + custodian.push_trade(trade, "NEW") if not custodian.staging_queue: return buf, dest = custodian.build_buffer("bond") @@ -59,12 +71,13 @@ def upload_to_custodian(account, trade_date, upload, em): conn.commit() if upload: custodian.upload(buf, dest.name, confirm=account != "UMB") + cc = _cc_recipients.get(custodian.name, ("NYOPS@lmcg.com",)) em.send_email( f"{account}: Bond Positions Uploaded for {trade_date}", "Hi, \nWe've just uploaded the positions via SFTP. File receipt attached to this email", - _recipients.get(account, _cc_recipients[custodian.name]), - cc_recipients=_cc_recipients[custodian.name], - reply_to=_cc_recipients[custodian.name], + _recipients.get(account, cc), + cc_recipients=cc, + reply_to=cc, attach=(FileAttachment(name=dest.name, content=buf),), ) diff --git a/python/report_ops/misc.py b/python/report_ops/misc.py index da7d61ac..6449a45c 100644 --- a/python/report_ops/misc.py +++ b/python/report_ops/misc.py @@ -46,6 +46,7 @@ _cc_recipients = { "BOWDST": ("bowdoin-ops@lmcg.com",), "SERCGMAST": ("nyops@lmcg.com",), "BRINKER": ("nyops@lmcg.com",), + "SERCGMAST": ("nyops@lmcg.com",), } |
