feat: personal user edition v1.0.0-user on release branch

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-30 20:22:42 +08:00
parent e5f264b774
commit ec1c9873b7
20 changed files with 324 additions and 294 deletions
+17 -8
View File
@@ -15,6 +15,8 @@ from typing import Any, Callable, Optional
from flask import flash, jsonify, redirect, render_template, request, url_for, Response, stream_with_context
from edition import USER_EDITION
from contract_specs import calc_position_metrics, get_contract_spec
from fee_specs import calc_fee_breakdown
from kline_stream import sse_format
@@ -1858,12 +1860,13 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
try:
payload = _refresh_trading_live_snapshot(fast=fast)
position_hub.broadcast("positions", payload)
conn = get_db()
try:
rec = _recommend_payload(conn)
recommend_hub.broadcast("recommend", {"ok": True, **rec})
finally:
conn.close()
if not USER_EDITION:
conn = get_db()
try:
rec = _recommend_payload(conn)
recommend_hub.broadcast("recommend", {"ok": True, **rec})
finally:
conn.close()
except Exception as exc:
logger.debug("push position snapshot: %s", exc)
@@ -2070,8 +2073,8 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
max_margin_pct=get_max_margin_pct(get_setting),
pending_order_timeout_min=get_pending_order_timeout_min(get_setting),
ctp_auto_connect=is_ctp_auto_connect_enabled(get_setting),
recommend_rows=rec_cache.get("rows") or [],
recommend_updated_at=rec_cache.get("updated_at"),
recommend_rows=[] if USER_EDITION else (rec_cache.get("rows") or []),
recommend_updated_at=None if USER_EDITION else rec_cache.get("updated_at"),
night_session=is_night_trading_session(),
small_account_scope=should_apply_small_account_scope(
capital, ctp_connected=ctp_connected,
@@ -2090,6 +2093,8 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
@app.route("/recommend")
@login_required
def recommend_page():
if USER_EDITION:
return redirect(url_for("positions"))
return redirect(url_for("positions") + "#recommend")
@app.route("/api/trading/live")
@@ -2992,6 +2997,8 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
@app.route("/api/recommend/stream")
@login_required
def api_recommend_stream():
if USER_EDITION:
return jsonify({"ok": False, "error": "个人用户版不含可开仓品种表"}), 403
from queue import Empty
def generate():
@@ -3026,6 +3033,8 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
@login_required
def api_recommend_refresh():
"""手动触发一次后台刷新(仍写入数据库)。"""
if USER_EDITION:
return jsonify({"ok": False, "error": "个人用户版不含可开仓品种表"}), 403
conn = get_db()
try:
init_strategy_tables(conn)