diff options
Diffstat (limited to 'python/reallocate_iam.py')
| -rw-r--r-- | python/reallocate_iam.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/python/reallocate_iam.py b/python/reallocate_iam.py index 02db04a4..3fdd4959 100644 --- a/python/reallocate_iam.py +++ b/python/reallocate_iam.py @@ -30,7 +30,7 @@ def gen_new_iam(fund, cob, conn): ), ) for row in c: - d = row._asdict() + d = row._asdict() | {"trade_date": cob} yield IAMDeal.from_dict(**d) @@ -38,15 +38,19 @@ def gen_new_iam_offsets(fund, cob, conn): """'Generates offsets if the sma has already updated these iam deals""" with conn.cursor() as c: c.execute( - "SELECT trade_date, broker, currency, fund, sum(start_money) AS start_money " - "FROM list_iam(%s, %s) GROUP BY (trade_date, broker, currency, fund);", + "SELECT broker, currency, fund, sum(start_money) AS start_money " + "FROM list_iam(%s, %s) GROUP BY (broker, currency, fund);", ( cob, fund, ), ) for row in c: - d = row._asdict() | {"is_offset": True, "folder": "M_CSH_CASH"} + d = row._asdict() | { + "is_offset": True, + "folder": "M_CSH_CASH", + "trade_date": cob, + } yield IAMDeal.from_dict(**d) @@ -58,6 +62,7 @@ def gen_matured_iam(fund, cob, conn): (cob, prev_business_day(cob), fund), ) for row in c: + d = row._asdict() yield IAMDeal.from_dict(**d) @@ -70,12 +75,12 @@ def build_iam(fund, cob, conn, upload): if fund in ("BOWDST"): for new_iam_offset in gen_new_iam_offsets(fund, cob, conn): new_iam_offset.stage() + conn.commit() for iam in IAMDeal.commit(returning=True): service.push_trade(iam, "NEW") for update_iam in gen_matured_iam(fund, cob, conn): service.push_trade(update_iam, "UPDATE") - conn.commit() - buf, dest = service.build_buffer() + buf, dest = service.build_buffer(trade_type="iam") if upload: pass # service.upload(buf, dest.name) |
