Files
fxhnt/scripts/dev_cockpit_local.py
jgrusewski ce464f82f4 fix(cockpit): IBKR paper card was falsely "not connected" — it is live via UCITS
The IBKR paper account (DU9600528) IS connected and trading: the armed
fxhnt-ucits-rebalancer (0 9 * * 1-5) books the multi-strat ETF leg through
UCITS lines (EU KID/PRIIPs blocks the US-ETF leg, whose rebalancer is
correctly suspended). Prod already rendered it ($1,029,621, 5 holdings).

Two self-inflicted "not connected" artifacts fixed:
- scripts/dev_cockpit_local.py did NOT wire ibkr_account_repo, so the LOCAL
  dev cockpit always showed the IBKR card empty regardless of real data —
  a misleading local-verification artifact. Now wires every repo prod wires.
- paper.html's new orientation banner hardcoded "not connected yet" (written
  from that stale local view). Made it data-aware (keyed on ibkr_view) so it
  states the live NLV + holdings when trading, "not connected yet" only when
  genuinely empty — it can't drift from the card beneath it.

Adds a regression assertion: connected account => banner says "live now,
trading through UCITS" and never "not connected yet".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 16:11:41 +02:00

35 lines
1.6 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.ibkr_account_repo import IbkrAccountRepo
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.
# Wire EVERY repo prod wires (create_app_from_settings), or a page silently degrades to an empty state that
# does NOT match prod — the IBKR paper-account card in particular reads through ibkr_account_repo; without it
# the /paper card renders "not connected yet" even when the real account is live (a misleading local artifact).
app = create_app(
ForwardNavRepo(dsn),
paper_repo=PaperRepo(dsn),
bybit_paper_repo=PaperRepo(dsn),
ibkr_account_repo=IbkrAccountRepo(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")