diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/reallocate_iam.py | 17 | ||||
| -rw-r--r-- | python/report_ops/cash.py | 7 |
2 files changed, 15 insertions, 9 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) diff --git a/python/report_ops/cash.py b/python/report_ops/cash.py index 30795850..641ba8aa 100644 --- a/python/report_ops/cash.py +++ b/python/report_ops/cash.py @@ -55,12 +55,12 @@ def get_custodian_account(fund, iam_broker): @dataclass class IAMDeal(Deal, deal_type=DealType.IAM, table_name="iams"): - trade_date: datetime.date = field(metadata={"globeop": "SettlementDate"}) + trade_date: datetime.date = field(metadata={"globeop": "Trade Date"}) folder: str = field(metadata={"globeop": "Folder"}) broker: str start_money: float = field(metadata={"globeop": "StartMoney"}) currency: str = field(metadata={"globeop": "Currency"}) - fund: Fund + fund: Fund = field(metadata={"globeop": "Fund"}) maturity: datetime.date = None uploaded: bool = False is_offset: bool = False @@ -83,11 +83,12 @@ class IAMDeal(Deal, deal_type=DealType.IAM, table_name="iams"): obj["Deal Type"] = "IamDeal" obj["ExpirationDate"] = self.trade_date if action == "UPDATE" else None obj["CallNoticeIndicator"] = "24H" if action == "NEW" else None - obj["TransactionIndicator"] = ("DEPOSIT" if obj["StartMoney"] > 0 else "LOAN",) + obj["TransactionIndicator"] = "DEPOSIT" if obj["StartMoney"] > 0 else "LOAN" obj["StartMoney"] = abs(obj["StartMoney"]) obj["DealFunction"] = "OTC" obj["MarginType"] = "Variation" obj["Basis"] = "ACT/360" + obj["SettlementDate"] = self.trade_date (custodian, cash_account) = get_custodian_account(self.fund, self.broker) obj = obj | { "Custodian": custodian, |
