aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/position_file_bowdst.py36
1 files changed, 28 insertions, 8 deletions
diff --git a/python/position_file_bowdst.py b/python/position_file_bowdst.py
index c8a8424f..6b34b8b4 100644
--- a/python/position_file_bowdst.py
+++ b/python/position_file_bowdst.py
@@ -6,16 +6,36 @@ from report_ops.misc import _recipients, _cc_recipients
import datetime
from serenitas.analytics.dates import prev_business_day
+asset_splits = {
+ "OTC": [
+ "future",
+ "tranche",
+ "ir_swaption",
+ "cdx_swaption",
+ "irs",
+ "cdx",
+ ],
+ "BOND": ["bond"],
+}
+
+
+def gen_positions_and_fnames(cob, fund):
+ for split, asset_classes in asset_splits.items():
+ buf, _ = build_position_file(cob, fund, asset_classes)
+ timestamp = datetime.datetime.now()
+ dest = f"HEDGEMARK.POSITION.BOS_PAT_BOWDOIN.{timestamp:%Y%m%d.%H%M%S}.{split}Deal.{cob}.csv"
+ yield buf, dest
+
def main(cob, fund, upload):
- buf, dest = build_position_file(
- cob,
- fund,
- )
+ client = Client.from_creds("hm_globeop", folder="incoming")
+ attachments = []
+ for buf, dest in gen_positions_and_fnames(cob, fund):
+ if upload:
+ client.put(buf, dest)
+ attachments.append(FileAttachment(name=dest, content=buf))
- if upload:
- client = Client.from_creds("hm_globeop")
- client.put(buf, dest.name)
+ if attachments:
em = ExchangeMessage()
em.send_email(
subject=f"Position_files for Bowdoin Street as of {cob}",
@@ -23,7 +43,7 @@ def main(cob, fund, upload):
to_recipients=_recipients[fund],
cc_recipients=_cc_recipients[fund],
reply_to=_cc_recipients[fund],
- attach=[FileAttachment(name=dest.name, content=buf)],
+ attach=attachments,
)