From 6c54a8ae952ee99ed59cc0dbd24f712a1eb6b8b5 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 26 Jul 2026 15:06:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=81=E4=BB=93=E6=8E=92=E5=90=8D=E5=A4=9A?= =?UTF-8?q?=E7=A9=BA=E5=A2=9E=E5=8A=A0=E5=A2=9E=E5=87=8F=E5=90=88=E8=AE=A1?= =?UTF-8?q?=E8=A1=8C?= 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/contracts.py | 8 ++++++++ ft-app/app/templates/contract.html | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/ft-app/app/routers/contracts.py b/ft-app/app/routers/contracts.py index e927ac0..ccd5b63 100644 --- a/ft-app/app/routers/contracts.py +++ b/ft-app/app/routers/contracts.py @@ -164,6 +164,13 @@ def contract_detail( "change": r.change, }) + pos_totals = { + "long": sum(r.change for r in rankings if r.data_type == "long"), + "short": sum(r.change for r in rankings if r.data_type == "short"), + } + else: + pos_totals = {"long": 0, "short": 0} + # Predict next trading day amplitude: mean of latest 5 diffs # Compute next trading date next_date = latest.date + timedelta(days=1) if latest else None @@ -186,6 +193,7 @@ def contract_detail( pos_dates=pos_dates, selected_pos_date=selected_date, pos_data=pos_data, + pos_totals=pos_totals, next_amp=next_amp, next_date=next_date.strftime("%Y/%-m/%-d") if next_date else None, next_weekday=WEEKDAY_ZH.get(next_date.weekday(), "") if next_date else "", diff --git a/ft-app/app/templates/contract.html b/ft-app/app/templates/contract.html index 48224ad..f6ed68e 100644 --- a/ft-app/app/templates/contract.html +++ b/ft-app/app/templates/contract.html @@ -92,6 +92,15 @@ {% endfor %} + {% if dtype != 'volume' %} + + 增减合计 + + + {% if pos_totals[dtype] > 0 %}+{% endif %}{{ pos_totals[dtype] }} + + + {% endif %} {% endfor %}