fix: family_key repair, reentry guard, legacy_incomplete, trades status filter
CI/CD / build-and-push (push) Successful in 1m54s

- db: update_family_key() persists corrected family slugs for open trades
- db: get_recently_closed_inverted() returns markets closed for inversion
  within N hours; used as reentry guard in the trading loop
- db: get_recent_trades() accepts status=open|closed|None and adds a
  computed "status" field to every row
- bot/main.py: legacy scan now computes family_key from stored question
  alone (dummy Market) when a position's market is no longer active —
  fixes NULL family_key on legacy trades like Ken Paxton (562186)
- bot/main.py: legacy scan (Step 2.5) persists corrected family_keys in
  DB so family conflict guards work correctly on next restart
- bot/main.py: positions with NULL edge_net and no live market are tagged
  legacy_incomplete instead of OK; counted separately in scan summary
- bot/main.py: reentry_guard blocks re-entering any market closed for
  inversion bug within 24h; logs reentry_guard_triggered per skip
- api/main.py: /api/trades now accepts ?status=open|closed|all (default
  open) and includes status_filter in response

DB fix (applied directly): 629558 family_key politics-2026 →
ohio-gubernatorial-2026; 562186 family_key NULL → texas-republican-2026

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chemavx
2026-04-21 09:37:45 +00:00
parent d698544f30
commit e2fb697c0c
3 changed files with 100 additions and 16 deletions
+10 -3
View File
@@ -42,9 +42,16 @@ async def get_metrics():
@app.get("/api/trades")
async def get_trades(limit: int = 50):
trades = await db.get_recent_trades(limit=limit)
return {"trades": trades, "count": len(trades)}
async def get_trades(limit: int = 50, status: str = "open"):
"""
status: "open" (default) | "closed" | "all"
Each trade includes a computed "status" field.
"""
if status not in ("open", "closed", "all"):
status = "open"
filter_status = None if status == "all" else status
trades = await db.get_recent_trades(limit=limit, status=filter_status)
return {"trades": trades, "count": len(trades), "status_filter": status}
@app.get("/api/summary")