diff options
Diffstat (limited to 'python/reallocate_cash.py')
| -rw-r--r-- | python/reallocate_cash.py | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/python/reallocate_cash.py b/python/reallocate_cash.py index 8140874d..5d3a2cbf 100644 --- a/python/reallocate_cash.py +++ b/python/reallocate_cash.py @@ -8,6 +8,7 @@ from serenitas.utils.remote import SftpClient from psycopg2.errors import UniqueViolation from serenitas.analytics.dates import bus_day from csv_headers.globeop_upload import HEADERS +from ops.funds import Fund _iam_brokers = { "BAML_ISDA": "BOANNY", @@ -141,22 +142,11 @@ def gen_iam_deals(conn, trade_date): def process_upload(conn, trade_date, iam_deals): - buf = StringIO() - csvwriter = csv.writer(buf) - csvwriter.writerow(HEADERS["iam"]) - csvwriter.writerows( - [[obj.get(h, None) for h in HEADERS["iam"]] for obj in iam_deals] - ) - buf = buf.getvalue().encode() - dest = ( - DAILY_DIR - / str(datetime.date.today()) - / f"Bowdst.ALL.{datetime.datetime.now():%Y%m%d.%H%M%S}.IamDeal.csv" - ) - dest.write_bytes(buf) - sftp = SftpClient.from_creds("hm_globeop") - sftp.client.chdir("incoming") - sftp.put(buf, dest.name) + bowdst = Fund["BOWDST"]() + bowdst.staging_queue.extend(iam_deals) + if bowdst.staging_queue: + buf, dest = bowdst.build_buffer("wire") + bowdst.upload(buf, dest) if __name__ == "__main__": |
