持仓监控页整合期货下单、持仓与品种推荐三卡片。
程序报单状态与推荐表内嵌同一页面,/recommend 跳转至 #recommend。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+24
-8
@@ -288,7 +288,18 @@ def install_trading(app, *, login_required, get_db, get_setting, set_setting, fe
|
||||
capital = _capital(conn)
|
||||
risk = get_risk_status(conn)
|
||||
ctp_acc = _ctp_account(mode) if ctp_st.get("connected") else {}
|
||||
recommend_rows = list_product_recommendations(capital, _main_price)
|
||||
active_trend = conn.execute(
|
||||
"SELECT * FROM trend_pullback_plans WHERE status='active' ORDER BY id DESC LIMIT 1"
|
||||
).fetchone()
|
||||
monitor_count = conn.execute(
|
||||
"SELECT COUNT(*) AS n FROM trade_order_monitors WHERE status='active'"
|
||||
).fetchone()["n"]
|
||||
roll_count = conn.execute(
|
||||
"SELECT COUNT(*) AS n FROM roll_groups WHERE status='active'"
|
||||
).fetchone()["n"]
|
||||
conn.close()
|
||||
sizing = get_sizing_mode(get_setting)
|
||||
return render_template(
|
||||
"trade.html",
|
||||
trading_mode=mode,
|
||||
@@ -297,8 +308,20 @@ def install_trading(app, *, login_required, get_db, get_setting, set_setting, fe
|
||||
risk_status=risk,
|
||||
ctp_status=ctp_st,
|
||||
ctp_account=ctp_acc,
|
||||
recommend_rows=recommend_rows,
|
||||
active_trend=dict(active_trend) if active_trend else None,
|
||||
monitor_count=monitor_count,
|
||||
roll_count=roll_count,
|
||||
sizing_mode=sizing,
|
||||
sizing_mode_label="以损定仓" if sizing == MODE_RISK else "固定张数",
|
||||
risk_percent=get_risk_percent(get_setting),
|
||||
)
|
||||
|
||||
@app.route("/recommend")
|
||||
@login_required
|
||||
def recommend_page():
|
||||
return redirect(url_for("positions") + "#recommend")
|
||||
|
||||
@app.route("/api/trading/live")
|
||||
@login_required
|
||||
def api_trading_live():
|
||||
@@ -313,6 +336,7 @@ def install_trading(app, *, login_required, get_db, get_setting, set_setting, fe
|
||||
"capital": _capital(get_db()),
|
||||
"ctp_status": ctp_st,
|
||||
"trading_mode_label": trading_mode_label(get_setting),
|
||||
"risk_status": get_risk_status(get_db()),
|
||||
})
|
||||
|
||||
@app.route("/api/trading/close", methods=["POST"])
|
||||
@@ -357,14 +381,6 @@ def install_trading(app, *, login_required, get_db, get_setting, set_setting, fe
|
||||
conn.close()
|
||||
return jsonify({"ok": False, "error": str(exc)}), 400
|
||||
|
||||
@app.route("/recommend")
|
||||
@login_required
|
||||
def recommend_page():
|
||||
conn = get_db()
|
||||
capital = _capital(conn)
|
||||
conn.close()
|
||||
rows = list_product_recommendations(capital, _main_price)
|
||||
return render_template("recommend.html", capital=capital, rows=rows, trading_mode_label=trading_mode_label(get_setting))
|
||||
|
||||
@app.route("/strategy")
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user