diff --git a/ft-app/app/routers/positions.py b/ft-app/app/routers/positions.py index 1f54211..9cfd502 100644 --- a/ft-app/app/routers/positions.py +++ b/ft-app/app/routers/positions.py @@ -37,6 +37,22 @@ def positions_page(request: Request, db: Session = Depends(get_db)): .all() ) + # Compute stop-profit threshold: latest position A × point_value per round + round_thresholds: dict[int, dict] = {} + for r in active_rounds: + if r.positions: + latest_a = r.positions[-1].amp_threshold + else: + latest_a = 0 + contract = db.query(Contract).filter(Contract.code == r.contract_code).first() + pv = contract.product.point_value if contract and contract.product else 20 + round_thresholds[r.id] = { + "amp": latest_a, + "point_value": pv, + "daily_hands": r.daily_hands, + "threshold": latest_a * pv * r.daily_hands, + } + template = request.app.state.templates.get_template("positions.html") return HTMLResponse( template.render( @@ -45,6 +61,7 @@ def positions_page(request: Request, db: Session = Depends(get_db)): contracts=get_active_contracts(db), product_contracts=get_product_contracts(db), active_rounds=active_rounds, + round_thresholds=round_thresholds, ) ) diff --git a/ft-app/app/templates/positions.html b/ft-app/app/templates/positions.html index 5bdcd6e..8e1b187 100644 --- a/ft-app/app/templates/positions.html +++ b/ft-app/app/templates/positions.html @@ -81,12 +81,14 @@ {# ── 止盈阈值 ── #} {% if round.positions %} - {% set latest = round.positions[-1] %} + {% set th = round_thresholds.get(round.id, {}) %}