blob: 95f35715259bf277ad341d59596875da3ff52a6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import datetime
from itertools import groupby
from serenitas.ops.trade_dataclasses import SpotDeal
from report_ops.services import get_service
fund = "BOWDST"
trade_date = datetime.date(2023, 3, 14)
conn = SpotDeal._conn
with conn.cursor() as c:
c.execute(
"SELECT ft.*, accounts2.cp_code as account_counterparty FROM forward_trades ft LEFT JOIN accounts2 USING (cash_account) WHERE ft.fund=%s AND ft.trade_date=%s;",
(fund, trade_date),
)
trades = [t._asdict() for t in c]
for account_counterparty, trades in groupby(
trades, lambda x: x["account_counterparty"]
):
if account_counterparty not in ("BONY",):
continue
service = get_service(account_counterparty)
for t in trades:
trade = SpotDeal.from_dict(**t)
service.push_trade(trade, "NEW")
service.build_buffer("spot")
|