diff options
Diffstat (limited to 'python/bondallocation_email.py')
| -rw-r--r-- | python/bondallocation_email.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/python/bondallocation_email.py b/python/bondallocation_email.py index 96be205f..5ae8902e 100644 --- a/python/bondallocation_email.py +++ b/python/bondallocation_email.py @@ -20,35 +20,36 @@ if __name__ == "__main__": } df = pd.read_sql_query( - "SELECT bonds.id as tradeid, trade_date, settle_date, CASE WHEN buysell THEN 'Buy' ELSE 'Sell' end as buysell, identifier, description , faceamount AS notional, price, accrued, principal_payment + accrued_payment as net_amount, name as counterparty FROM bonds LEFT JOIN counterparties on cp_code=code where id=2014 and trade_date = %s", + "SELECT bonds.id as tradeid, trade_date, settle_date, CASE WHEN buysell THEN 'Buy' ELSE 'Sell' end as buysell, identifier, description , faceamount AS notional, price, accrued, principal_payment + accrued_payment as net_amount, name as counterparty, allocation_contacts FROM bonds LEFT JOIN counterparties on cp_code=code where id=2014 and trade_date = %s", con=dawndb, params=(args.trade_date,), ) for row in df.itertuples(): with dawndb.cursor() as d: d.execute( - f"SELECT tradeid, notional, fund FROM bond_allocation LEFT JOIN accounts a USING (code) WHERE account_type='Cash' AND active AND tradeid={row.tradeid};" + f"SELECT tradeid, notional, fund FROM bond_allocation LEFT JOIN accounts a USING (code) WHERE account_type='Cash' AND active AND trade_date={row.trade_date};" ) em = ExchangeMessage() subject = ( f"LMCG - Trade Allocations - TD {row.trade_date} - {row.counterparty}" ) - recipients = ("fyu@lmcg.com",) - cc_recipients = ("fyu@lmcg.com",) + cc_recipients = ("fyu@lmcg.com", "NYOPs") allocations = "\n\t".join( [f"- {row.notional:,.0f} to {alert[row.fund]}" for row in d] ) body = ( f"For {row.identifier} please allocate :\n\n\t" + allocations - + "\n\nTrade Details are attached." + + "\n\nTrade Details are attached in csv." + "\n\n\nThanks,\nFlint" ) buf = StringIO() df[df["tradeid"] == row.tradeid].to_csv(buf) em.send_email( subject=subject, - to_recipients=recipients, + to_recipients=row.allocation_contacts + if row.allocation_contacts + else ("fyu@lmcg.com,"), cc_recipients=cc_recipients, body=body, attach=[ |
