aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/Dawn/utils.py3
-rw-r--r--python/Dawn/views.py10
-rw-r--r--python/process_queue.py5
3 files changed, 15 insertions, 3 deletions
diff --git a/python/Dawn/utils.py b/python/Dawn/utils.py
index 9a2cf37f..731d6dbb 100644
--- a/python/Dawn/utils.py
+++ b/python/Dawn/utils.py
@@ -9,11 +9,12 @@ def bump_rev(filename):
return f"{begin} rev{rev_number}.pdf"
-def simple_serialize(obj):
+def simple_serialize(obj, **kwargs):
d = {c.name: getattr(obj, c.name) for c in obj.__table__.columns}
# add data from foreign relationship
if obj.__table__.name == 'wires':
d.update({'Counterparty': obj.account.counterparty,
'cashaccount': obj.account.cash_account,
'custodian': obj.account.custodian})
+ d.update(kwargs)
return dumps(d)
diff --git a/python/Dawn/views.py b/python/Dawn/views.py
index 086d7d99..1bda06e1 100644
--- a/python/Dawn/views.py
+++ b/python/Dawn/views.py
@@ -365,8 +365,16 @@ def trade_manage(tradeid, kind):
trade.cashaccount = trade.fcm_account.cash_account
session.commit()
if form.upload_globeop.data:
+ if kind == "bond":
+ buf = simple_serialize(trade, upload=True)
+ else:
+ buf = simple_serialize(trade)
q = get_queue()
- q.rpush(f'{kind}_trades', simple_serialize(trade))
+ q.rpush(f"{kind}_trades", buf)
+ else:
+ if kind == "bond":
+ q = get_queue()
+ q.rpush(f"{kind}_trades", simple_serialize(trade))
return redirect(url_for('list_trades', kind=kind))
else:
if form.errors:
diff --git a/python/process_queue.py b/python/process_queue.py
index c5dc819d..e0ebec24 100644
--- a/python/process_queue.py
+++ b/python/process_queue.py
@@ -378,6 +378,7 @@ def bond_trade_process(conn, session, trade):
logging.error('We already have a mark')
conn.rollback()
+def send_email(trade):
# send out email with trade content
email = GmailMessage()
email.set_content(print_trade(trade))
@@ -478,11 +479,13 @@ if __name__ == "__main__":
with init_bbg_session(BBG_IP) as session:
for trade in list_trades:
bond_trade_process(dawndb, session, trade)
+ list_trades = [t for t in list_trades if t.get("upload", False)]
+ for trade in list_trades:
+ send_email(trade)
elif queue_name == 'cds_trades':
with init_bbg_session(BBG_IP) as session:
for trade in list_trades:
cds_trade_process(serenitasdb, dawndb, session, trade)
-
buf = generate_csv(list_trades, queue_name)
file_path = write_buffer(buf, DAILY_DIR, queue_name)
if not args.no_upload: