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' %}