aboutsummaryrefslogtreecommitdiffstats
path: root/python/admin_bond_upload.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/admin_bond_upload.py')
-rw-r--r--python/admin_bond_upload.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/python/admin_bond_upload.py b/python/admin_bond_upload.py
index 240fd451..02dcfba6 100644
--- a/python/admin_bond_upload.py
+++ b/python/admin_bond_upload.py
@@ -7,10 +7,8 @@ from serenitas.ops.trade_dataclasses import BondDeal
from report_ops.services import get_service
-conn = dbconn("dawndb")
-
-def upload_to_custodian(fund, trade_date):
+def upload_to_custodian(conn, fund, trade_date, upload):
with conn.cursor() as c:
c.execute(
"SELECT bt.*, accounts.counterparty AS account_counterparty FROM bond_trades bt LEFT JOIN accounts ON bt.account=accounts.code WHERE bt.fund=%s AND bt.trade_date=%s;",
@@ -23,13 +21,15 @@ def upload_to_custodian(fund, trade_date):
for account_counterparty, trades in groupby(
trades, lambda x: x["account_counterparty"]
):
- if account_counterparty == "NT":
+ if account_counterparty == "NT": # No uploads to NT yet
continue
service = get_service(account_counterparty)
for t in trades:
trade = BondDeal.from_dict(**t, scaled=True)
service.push_trade(trade, "NEW")
- service.build_buffer("bond")
+ buf, dest = service.build_buffer("bond")
+ if upload:
+ service.upload(buf, dest.name)
if __name__ == "__main__":
@@ -44,5 +44,6 @@ if __name__ == "__main__":
"-n", "--no-upload", action="store_true", help="do not upload to CTM"
)
args = parser.parse_args()
+ conn = BondDeal._conn
for fund in ("SERCGMAST", "BOWDST", "BRINKER", "ISOSEL"):
- upload_to_custodian(fund, args.trade_date)
+ upload_to_custodian(conn, fund, args.trade_date, not args.no_upload)