From 5670e5138c3350354b9183536cd5f23694e91b49 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 26 Jul 2026 10:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E7=BA=A6=E5=88=97=E8=A1=A8=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=AC=A1=E6=97=A5=E6=8C=AF=E5=B9=85=E5=AD=97=E6=AE=B5?= 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 | 15 +++++++++++++++ ft-app/app/templates/index.html | 11 +++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ft-app/app/routers/contracts.py b/ft-app/app/routers/contracts.py index 05d6e02..e927ac0 100644 --- a/ft-app/app/routers/contracts.py +++ b/ft-app/app/routers/contracts.py @@ -59,6 +59,20 @@ def contract_index(request: Request, db: Session = Depends(get_db)): if bar.contract not in contract_bars: contract_bars[bar.contract] = bar + # Next-day amplitude: mean of latest 5 diffs per contract + contract_next_amp = {} + for code in all_codes: + diffs = [ + r[0] for r in + db.query(DailyBar.high - DailyBar.low) + .filter(DailyBar.contract == code) + .order_by(DailyBar.date.desc()) + .limit(5) + .all() + ] + if len(diffs) >= 5: + contract_next_amp[code] = round(sum(diffs) / 5) + template = request.app.state.templates.get_template("index.html") return HTMLResponse( template.render( @@ -66,6 +80,7 @@ def contract_index(request: Request, db: Session = Depends(get_db)): active_nav="contracts", product_groups=product_groups, contract_bars=contract_bars, + contract_next_amp=contract_next_amp, ) ) diff --git a/ft-app/app/templates/index.html b/ft-app/app/templates/index.html index f491b92..42ec499 100644 --- a/ft-app/app/templates/index.html +++ b/ft-app/app/templates/index.html @@ -17,7 +17,7 @@
- + {% for c in pg.contracts %} @@ -34,8 +34,15 @@ {% endif %} + {% else %} - + {% endif %}
合约日期开盘收盘最高最低振幅操作
合约日期开盘收盘最高最低振幅次日振幅操作
{{ c }} + {% if c in contract_next_amp %} + {{ contract_next_amp[c] }} + {% else %} + + {% endif %} + 暂无数据暂无数据详情 →