diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/ctm_allocation.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/python/ctm_allocation.py b/python/ctm_allocation.py new file mode 100644 index 00000000..b39bab24 --- /dev/null +++ b/python/ctm_allocation.py @@ -0,0 +1,41 @@ +from serenitas.utils.db import dawn_engine, dbconn +from serenitas.utils.exchange import ExchangeMessage, FileAttachment +from exchangelib import HTMLBody +import pandas as pd +from io import StringIO +import datetime +import argparse +from pandas.tseries.offsets import BDay +import sys + +sys.path.append("/home/flint/projects/") +from ops.serenitas.ops.trade_dataclasses import BondDeal +from ops.serenitas.ops.funds import CTM + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "trade_date", + type=datetime.date.fromisoformat, + default=(datetime.date.today() - BDay(1)).date(), + ) + args = parser.parse_args() + dawndb = dbconn("dawndb") + + alert = { + "SERCGMAST": "Serenitas Credit Gamma Master Fund", + "BOWDST": "Bowdoin St. (ALERT acronym: LMUNDER, Account: SER003)", + "BRINKER": "Brinker Destinations Multi-Strategy Alternatives - LMCG", + "ISOSEL": "ISO Selene (ALERT acronym: LMUNDER, Account: SER004)", + } + + df = pd.read_sql_query( + "SELECT ba.id, allocated, emailed FROM bonds LEFT JOIN bond_allocation ba ON bonds.id=ba.tradeid WHERE trade_date=%s;", + con=dawn_engine, + params=(args.trade_date,), + ) + with dawndb.cursor() as d: + for row in df.itertuples(): + CTM.stage(BondDeal.from_allocationid(row.id)) + buf, dest = CTM.build_buffer() |
