diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/bondallocation_email.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/python/bondallocation_email.py b/python/bondallocation_email.py index b05964ea..96be205f 100644 --- a/python/bondallocation_email.py +++ b/python/bondallocation_email.py @@ -8,7 +8,7 @@ import argparse if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( - "trade_date", type=datetime.date.fromisoformat, default=datetime.date.today() + "--trade_date", type=datetime.date.fromisoformat, default=datetime.date.today() ) args = parser.parse_args() dawndb = dbconn("dawndb") @@ -20,7 +20,7 @@ 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 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 FROM bonds LEFT JOIN counterparties on cp_code=code where id=2014 and trade_date = %s", con=dawndb, params=(args.trade_date,), ) @@ -30,7 +30,9 @@ if __name__ == "__main__": f"SELECT tradeid, notional, fund FROM bond_allocation LEFT JOIN accounts a USING (code) WHERE account_type='Cash' AND active AND tradeid={row.tradeid};" ) em = ExchangeMessage() - subject = f"LMCG - Trade Allocations - TD {row.trade_date} - {row.name}" + subject = ( + f"LMCG - Trade Allocations - TD {row.trade_date} - {row.counterparty}" + ) recipients = ("fyu@lmcg.com",) cc_recipients = ("fyu@lmcg.com",) allocations = "\n\t".join( @@ -39,6 +41,7 @@ if __name__ == "__main__": body = ( f"For {row.identifier} please allocate :\n\n\t" + allocations + + "\n\nTrade Details are attached." + "\n\n\nThanks,\nFlint" ) buf = StringIO() @@ -50,7 +53,7 @@ if __name__ == "__main__": body=body, attach=[ FileAttachment( - name=f"{row.trade_date}-{row.name}-{row.identifier}.csv", + name=f"{row.trade_date}-{row.counterparty}-{row.identifier}.csv", content=buf.getvalue().encode(), ) ], |
