From 8fb3949fac2d68584092f714df737f0aa2e1c713 Mon Sep 17 00:00:00 2001 From: fish Date: Fri, 24 Jul 2026 22:28:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E7=BA=BF=E8=A1=A8=E6=A0=BC=E6=9C=AB?= =?UTF-8?q?=E5=B0=BE=E8=BF=BD=E5=8A=A0=E6=AC=A1=E6=97=A5=E9=A2=84=E6=B5=8B?= =?UTF-8?q?=E8=A1=8C=EF=BC=8C=E5=B1=95=E7=A4=BA=E6=8C=AF=E5=B9=85=E9=98=88?= =?UTF-8?q?=E5=80=BC=E4=BE=9B=E4=BA=A4=E6=98=93=E5=8F=82=E8=80=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ft-app/app/routers/contracts.py | 11 +++++++++-- ft-app/app/templates/contract.html | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ft-app/app/routers/contracts.py b/ft-app/app/routers/contracts.py index 9f1a5b0..43f5a5f 100644 --- a/ft-app/app/routers/contracts.py +++ b/ft-app/app/routers/contracts.py @@ -1,4 +1,4 @@ -from datetime import date +from datetime import date, timedelta from fastapi import APIRouter, Depends, Request from fastapi.responses import HTMLResponse from sqlalchemy.orm import Session @@ -80,10 +80,15 @@ 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 + # Compute next trading date + next_date = latest.date + timedelta(days=1) if latest else None + if next_date and next_date.weekday() >= 5: + next_date += timedelta(days=7 - next_date.weekday()) + + # Predict next trading day amplitude 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( @@ -94,6 +99,8 @@ def contract_detail(request: Request, contract: str, db: Session = Depends(get_d rows=rows, latest=latest, 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 "", row_count=len(rows), ) ) diff --git a/ft-app/app/templates/contract.html b/ft-app/app/templates/contract.html index a256ae9..fefe097 100644 --- a/ft-app/app/templates/contract.html +++ b/ft-app/app/templates/contract.html @@ -52,9 +52,19 @@ {% else %} {% endif %} - - {% endfor %} + {% if next_date %} + + {{ next_date }} + {{ next_weekday }} + — + — + — + — + — + {{ next_amp }} + + {% endif %}