From dce017fbf2c380bb2da41b97821c6f7a9a90d472 Mon Sep 17 00:00:00 2001 From: fish Date: Fri, 24 Jul 2026 22:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E7=BA=A6=E8=AF=A6=E6=83=85=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E6=AC=A1=E6=97=A5=E9=A2=84=E6=B5=8B=E6=8C=AF=E5=B9=85?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=9C=80=E8=BF=915=E6=97=A5=E6=B3=A2?= =?UTF-8?q?=E5=B9=85=E5=9D=87=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ft-app/app/routers/contracts.py | 6 ++++++ ft-app/app/templates/contract.html | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ft-app/app/routers/contracts.py b/ft-app/app/routers/contracts.py index 38759a2..9f1a5b0 100644 --- a/ft-app/app/routers/contracts.py +++ b/ft-app/app/routers/contracts.py @@ -79,6 +79,11 @@ def contract_detail(request: Request, contract: str, db: Session = Depends(get_d latest = bars[0] if bars else None + # Predict next trading day amplitude: mean of latest 5 diffs + next_amp = None + if len(bars) >= 5: + next_amp = round(sum(b.diff for b in bars[:5]) / 5) + template = request.app.state.templates.get_template("contract.html") return HTMLResponse( template.render( @@ -88,6 +93,7 @@ def contract_detail(request: Request, contract: str, db: Session = Depends(get_d contracts=active_contracts, rows=rows, latest=latest, + next_amp=next_amp, row_count=len(rows), ) ) diff --git a/ft-app/app/templates/contract.html b/ft-app/app/templates/contract.html index c94584a..a256ae9 100644 --- a/ft-app/app/templates/contract.html +++ b/ft-app/app/templates/contract.html @@ -12,13 +12,14 @@
日期 {{ latest.date }}
-
当日振幅
-
{{ latest.amp_5d|int if latest.amp_5d else '—' }}
-
日波幅 {{ latest.diff|int }} 点
+
次日预测振幅
+
{{ next_amp if next_amp else '—' }}
+
近5日均波幅
-
数据条数
-
{{ row_count }}
+
最新波幅
+
{{ latest.diff|int }} 点
+
{{ latest.date }}
{% endif %}