rebuild(stage-7): deliver ladder and sector rotation
This commit is contained in:
@@ -188,6 +188,52 @@ class MarketRepository:
|
||||
(through,),
|
||||
).fetchone()
|
||||
|
||||
def sector_members(
|
||||
self, connection: sqlite3.Connection, trade_date: str, sector_name: str
|
||||
) -> sqlite3.Row | None:
|
||||
return connection.execute(
|
||||
"""
|
||||
SELECT * FROM sector_member_snapshots
|
||||
WHERE trade_date = ? AND sector_name = ?
|
||||
""",
|
||||
(trade_date, sector_name),
|
||||
).fetchone()
|
||||
|
||||
def save_sector_members(
|
||||
self,
|
||||
connection: sqlite3.Connection,
|
||||
*,
|
||||
trade_date: str,
|
||||
sector_name: str,
|
||||
sector_code: str,
|
||||
observed_at: str,
|
||||
source: str,
|
||||
coverage: float,
|
||||
payload: dict[str, Any],
|
||||
) -> None:
|
||||
connection.execute(
|
||||
"""
|
||||
INSERT INTO sector_member_snapshots (
|
||||
trade_date, sector_name, sector_code, observed_at, source, coverage, payload_json
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(trade_date, sector_name) DO UPDATE SET
|
||||
sector_code = excluded.sector_code,
|
||||
observed_at = excluded.observed_at,
|
||||
source = excluded.source,
|
||||
coverage = excluded.coverage,
|
||||
payload_json = excluded.payload_json
|
||||
""",
|
||||
(
|
||||
trade_date,
|
||||
sector_name,
|
||||
sector_code,
|
||||
observed_at,
|
||||
source,
|
||||
coverage,
|
||||
json.dumps(payload, ensure_ascii=False, separators=(",", ":")),
|
||||
),
|
||||
)
|
||||
|
||||
def save_chart(
|
||||
self,
|
||||
connection: sqlite3.Connection,
|
||||
|
||||
Reference in New Issue
Block a user