From e3f288083c3a36011225f3b2dc6358c207df5d80 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 26 Jul 2026 11:37:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E5=86=B2=E7=AE=A1=E7=90=86=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=93=81=E7=A7=8D=E7=AD=9B=E9=80=89=EF=BC=8C=E5=90=88?= =?UTF-8?q?=E7=BA=A6=E4=B8=8B=E6=8B=89=E5=8E=BB=E6=8E=89=E5=93=81=E7=A7=8D?= =?UTF-8?q?=E5=89=8D=E7=BC=80?= 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/positions.py | 13 +++++++++++- ft-app/app/templates/positions.html | 33 +++++++++++++++++++++++------ ft-app/app/templates/trades.html | 3 ++- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/ft-app/app/routers/positions.py b/ft-app/app/routers/positions.py index 0df0beb..3893d2f 100644 --- a/ft-app/app/routers/positions.py +++ b/ft-app/app/routers/positions.py @@ -3,7 +3,7 @@ from fastapi import APIRouter, Depends, Form, Request from fastapi.responses import HTMLResponse, RedirectResponse from sqlalchemy.orm import Session from app.database import get_db -from app.models import Round, Position, Contract +from app.models import Round, Position, Contract, Product router = APIRouter(prefix="/positions", tags=["positions"]) @@ -18,6 +18,16 @@ def get_active_contracts(db: Session) -> list[str]: return [c[0] for c in contracts] +def get_product_contracts(db: Session) -> dict: + 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 + + @router.get("/", response_class=HTMLResponse) def positions_page(request: Request, db: Session = Depends(get_db)): active_rounds = ( @@ -33,6 +43,7 @@ def positions_page(request: Request, db: Session = Depends(get_db)): request=request, active_nav="positions", contracts=get_active_contracts(db), + product_contracts=get_product_contracts(db), active_rounds=active_rounds, ) ) diff --git a/ft-app/app/templates/positions.html b/ft-app/app/templates/positions.html index 5689c1f..6596452 100644 --- a/ft-app/app/templates/positions.html +++ b/ft-app/app/templates/positions.html @@ -16,15 +16,21 @@
-
- - + + {% for pcode in product_contracts %} + {% endfor %}
+
+ + +
@@ -161,4 +167,19 @@
{% endfor %} + {% endblock %} diff --git a/ft-app/app/templates/trades.html b/ft-app/app/templates/trades.html index 1af6961..31115df 100644 --- a/ft-app/app/templates/trades.html +++ b/ft-app/app/templates/trades.html @@ -211,7 +211,8 @@ function filterContracts() { sel.disabled = !prod; if (prod && productContracts[prod]) { productContracts[prod].forEach(function(c) { - sel.innerHTML += ''; + var display = c.startsWith(prod) ? c.substring(prod.length) : c; + sel.innerHTML += ''; }); } }