Files
fxhnt/scripts/dev_cockpit_local.py
jgrusewski 375cd108bc feat(0b): remove the vestigial dual-venue PaperRepo abstraction (Task 7f)
Task 7e only renamed venue="binance" -> "legacy" to pass the substring guard;
the dual-venue repo machinery was left in place even though bybit is the ONLY
live venue. PaperRepo now hardcodes every discriminated read/write to a
_BYBIT_VENUE = "bybit" module constant instead of a constructor venue param
(removed) -- reads/writes ONLY the bybit rows, so the orphaned legacy/binance
rows from the retired combined-crypto book (Task 7d) are never touched.
nav_summary's venue arg is dropped the same way (every caller always passed
"bybit"). cockpit_models keeps the venue column (dropping it from the PK is a
separate prod schema migration, documented in the report for the merge
runbook) with reworded comments reflecting the single-venue reality.

Test fallout: deleted test_paper_repo_venue.py (tested the now-removed
dual-venue isolation) and 3 "does-not-touch-binance" tests that constructed
PaperRepo(venue="binance"); mechanically dropped the venue kwarg everywhere
else. Added a guard assertion that PaperRepo.__init__ has no venue param.
Full suite green (1853 passed); binance substring guard still 0 hits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-14 15:20:57 +02:00

30 lines
1.2 KiB
Python

"""Serve the REAL cockpit locally against whatever FXHNT_OPERATIONAL_DSN points to, READ-ONLY.
For fast local UI testing against REAL prod data without a 9-minute Argo deploy. Deliberately constructs the
repos WITHOUT calling .migrate(), so it never writes DDL to the (possibly production) DB — the cockpit pages
it serves are read-only. Driven by scripts/dev-cockpit-local.sh, which sets up the port-forward + DSN.
Env:
FXHNT_OPERATIONAL_DSN required — e.g. postgresql+psycopg://foxhunt:<pw>@127.0.0.1:15432/fxhnt
FXHNT_DEV_PORT local port to serve on (default 8801)
"""
import os
import uvicorn
from fxhnt.adapters.persistence.forward_nav import ForwardNavRepo
from fxhnt.adapters.persistence.paper_repo import PaperRepo
from fxhnt.adapters.web.app import create_app
dsn = os.environ["FXHNT_OPERATIONAL_DSN"]
port = int(os.environ.get("FXHNT_DEV_PORT", "8801"))
# READ-ONLY: no .migrate() — never write DDL to a prod DB we're only browsing.
app = create_app(
ForwardNavRepo(dsn),
paper_repo=PaperRepo(dsn),
bybit_paper_repo=PaperRepo(dsn),
)
print(f"cockpit (read-only) on http://127.0.0.1:{port}/paper/sim?book=bybit_4edge")
uvicorn.run(app, host="127.0.0.1", port=port, log_level="warning")