From d44e93dd4f09147c27de1e5fc30ac36b53c72db2 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 26 Jul 2026 11:34:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E6=98=93=E8=AE=B0=E5=BD=95=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=BC=80=E4=BB=93=E6=94=B9=E4=B8=BA=E5=85=88=E9=80=89?= =?UTF-8?q?=E5=93=81=E7=A7=8D=E5=86=8D=E9=80=89=E5=90=88=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- ft-app/app/routers/trades.py | 12 ++++++++++++ ft-app/app/templates/trades.html | 28 +++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ft-app/app/routers/trades.py b/ft-app/app/routers/trades.py index 3113c05..862a03b 100644 --- a/ft-app/app/routers/trades.py +++ b/ft-app/app/routers/trades.py @@ -20,6 +20,17 @@ def get_active_contracts(db: Session) -> list[str]: return [c[0] for c in contracts] +def get_product_contracts(db: Session) -> dict: + """Return {product_code: [contract_codes]} for active contracts.""" + result: dict[str, list[str]] = {} + products = db.query(Product).order_by(Product.code).all() + for p in products: + codes = [c.code for c in p.contracts if c.is_active] + if codes: + result[p.code] = codes + return result + + def today_str() -> str: return date.today().isoformat() @@ -41,6 +52,7 @@ def trades_page(request: Request, db: Session = Depends(get_db)): request=request, active_nav="trades", contracts=get_active_contracts(db), + product_contracts=get_product_contracts(db), directions=DIRECTIONS, open_trades=open_trades, closed_trades=closed_trades, diff --git a/ft-app/app/templates/trades.html b/ft-app/app/templates/trades.html index de84136..1af6961 100644 --- a/ft-app/app/templates/trades.html +++ b/ft-app/app/templates/trades.html @@ -34,13 +34,19 @@
+
+ + +
- +
@@ -197,6 +203,18 @@ {% if view != 'closed' %}