From 2bcae303783c9bdd9587cecea91eaec1bf225bf1 Mon Sep 17 00:00:00 2001 From: fish Date: Fri, 24 Jul 2026 22:45:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=95=B0=E6=8D=AE=E5=BD=95?= =?UTF-8?q?=E5=85=A5=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=8C=81=E4=BB=93=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=B7=9F=E9=9A=8F=E7=A7=8D=E5=AD=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ft-app/app/main.py | 3 +- ft-app/app/routers/data_input.py | 71 -------------------------------- ft-app/app/templates/base.html | 3 -- ft-app/app/templates/input.html | 45 -------------------- 4 files changed, 1 insertion(+), 121 deletions(-) delete mode 100644 ft-app/app/routers/data_input.py delete mode 100644 ft-app/app/templates/input.html diff --git a/ft-app/app/main.py b/ft-app/app/main.py index fa69e9d..343fc13 100644 --- a/ft-app/app/main.py +++ b/ft-app/app/main.py @@ -7,7 +7,7 @@ from starlette.middleware.base import BaseHTTPMiddleware from app.database import engine, Base, SessionLocal from app.models import User from app.seed import seed -from app.routers import contracts, analysis, data_input, admin, auth +from app.routers import contracts, analysis, admin, auth TEMPLATES_DIR = Path(__file__).parent / "templates" @@ -56,7 +56,6 @@ app.add_middleware(AuthMiddleware) app.include_router(auth.router) app.include_router(contracts.router) app.include_router(analysis.router) -app.include_router(data_input.router) app.include_router(admin.router) diff --git a/ft-app/app/routers/data_input.py b/ft-app/app/routers/data_input.py deleted file mode 100644 index b98c0a3..0000000 --- a/ft-app/app/routers/data_input.py +++ /dev/null @@ -1,71 +0,0 @@ -from datetime import date -from fastapi import APIRouter, Depends, Form, Request -from fastapi.responses import HTMLResponse, RedirectResponse -from sqlalchemy.orm import Session -from app.database import get_db -from app.models import PositionSnapshot - -router = APIRouter(prefix="/input", tags=["input"]) - -INSTITUTIONS = ["中信期货", "高盛期货", "国泰君安期货", "华泰期货", "东证期货", "银河期货"] - - -@router.get("/", response_class=HTMLResponse) -def input_page(request: Request): - template = request.app.state.templates.get_template("input.html") - return HTMLResponse( - template.render(request=request, active_nav="input", institutions=INSTITUTIONS) - ) - - -@router.post("/") -def submit_position( - request: Request, - institution: str = Form(...), - direction: str = Form(...), - date_str: str = Form(...), - position: int = Form(...), - avg_cost: float = Form(...), - db: Session = Depends(get_db), -): - d = date.fromisoformat(date_str) - - prev = ( - db.query(PositionSnapshot) - .filter( - PositionSnapshot.institution == institution, - PositionSnapshot.direction == direction, - PositionSnapshot.date < d, - ) - .order_by(PositionSnapshot.date.desc()) - .first() - ) - delta = position - prev.position if prev else 0 - - existing = ( - db.query(PositionSnapshot) - .filter( - PositionSnapshot.institution == institution, - PositionSnapshot.direction == direction, - PositionSnapshot.date == d, - ) - .first() - ) - - if existing: - existing.position = position - existing.delta = delta - existing.avg_cost = avg_cost - else: - snap = PositionSnapshot( - institution=institution, - direction=direction, - date=d, - position=position, - delta=delta, - avg_cost=avg_cost, - ) - db.add(snap) - - db.commit() - return RedirectResponse("/analysis", status_code=303) diff --git a/ft-app/app/templates/base.html b/ft-app/app/templates/base.html index 646b753..192afff 100644 --- a/ft-app/app/templates/base.html +++ b/ft-app/app/templates/base.html @@ -198,9 +198,6 @@ ⚔️ 博弈分析 - - 📝 数据录入 - ⚙️ 系统管理 diff --git a/ft-app/app/templates/input.html b/ft-app/app/templates/input.html deleted file mode 100644 index 449363b..0000000 --- a/ft-app/app/templates/input.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "base.html" %} -{% block title %}数据录入{% endblock %} -{% block heading %}数据录入{% endblock %} -{% block breadcrumb %}机构持仓录入{% endblock %} - -{% block content %} -
-
持仓快照
-
-
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- - -
-
-{% endblock %}