Enhance dashboard with exchange labels, split SL/TP columns, and daily risk limits.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+27
-7
@@ -1564,7 +1564,11 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
rows = _apply_account_margin_to_rows(rows, mode, capital)
|
||||
_persist_ctp_snapshot_to_monitors(conn, rows, mode)
|
||||
pending_orders = _build_pending_orders(conn, mode)
|
||||
risk = get_risk_status(conn, active_count=_effective_active_position_count(conn, mode))
|
||||
risk = get_risk_status(
|
||||
conn,
|
||||
active_count=_effective_active_position_count(conn, mode),
|
||||
equity=capital,
|
||||
)
|
||||
return {
|
||||
"ok": True,
|
||||
"rows": rows,
|
||||
@@ -1753,7 +1757,11 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
ctp_st = ctp_status(mode)
|
||||
capital = _capital(conn)
|
||||
recommend_capital = _recommend_capital(conn)
|
||||
risk = get_risk_status(conn, active_count=_effective_active_position_count(conn, mode))
|
||||
risk = get_risk_status(
|
||||
conn,
|
||||
active_count=_effective_active_position_count(conn, mode),
|
||||
equity=capital,
|
||||
)
|
||||
ctp_acc = _ctp_account(mode) if ctp_st.get("connected") else {}
|
||||
active_trend = conn.execute(
|
||||
"SELECT * FROM trend_pullback_plans WHERE status='active' ORDER BY id DESC LIMIT 1"
|
||||
@@ -2387,7 +2395,11 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
if d.get("trailing_be") and not d.get("stop_loss"):
|
||||
conn.close()
|
||||
return jsonify({"ok": False, "error": "开启移动保本须填写止损价"}), 400
|
||||
err = assert_can_open(conn, active_count=_effective_active_position_count(conn, mode))
|
||||
err = assert_can_open(
|
||||
conn,
|
||||
active_count=_effective_active_position_count(conn, mode),
|
||||
equity=_capital(conn),
|
||||
)
|
||||
if err:
|
||||
conn.close()
|
||||
return jsonify({"ok": False, "error": err}), 403
|
||||
@@ -2675,7 +2687,11 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
mode = get_trading_mode(get_setting)
|
||||
ctp_st = ctp_status(mode)
|
||||
capital = _capital(conn)
|
||||
risk = get_risk_status(conn, active_count=_effective_active_position_count(conn, mode))
|
||||
risk = get_risk_status(
|
||||
conn,
|
||||
active_count=_effective_active_position_count(conn, mode),
|
||||
equity=capital,
|
||||
)
|
||||
conn.commit()
|
||||
ctp_acc = _ctp_account(mode) if ctp_st.get("connected") else {}
|
||||
positions = _ctp_positions(mode) if ctp_st.get("connected") else []
|
||||
@@ -2800,11 +2816,11 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
sym = (d.get("symbol") or "").strip()
|
||||
conn = get_db()
|
||||
init_strategy_tables(conn)
|
||||
err = assert_can_open(conn)
|
||||
capital = _capital(conn)
|
||||
err = assert_can_open(conn, equity=capital)
|
||||
if err:
|
||||
conn.close()
|
||||
return jsonify({"ok": False, "error": err}), 403
|
||||
capital = _capital(conn)
|
||||
scope_err = assert_product_allowed_for_capital(
|
||||
sym, capital, ctp_connected=is_ctp_connected(get_setting),
|
||||
)
|
||||
@@ -3405,7 +3421,11 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
sl, tp = calc_breakout_sl_tp(
|
||||
sym=sym, direction=direction, entry=entry, bar=bar, risk_reward=rr,
|
||||
)
|
||||
err = assert_can_open(conn, active_count=_effective_active_position_count(conn, mode))
|
||||
err = assert_can_open(
|
||||
conn,
|
||||
active_count=_effective_active_position_count(conn, mode),
|
||||
equity=_capital(conn),
|
||||
)
|
||||
if err:
|
||||
_notify(False, err, entry=entry, sl=sl, tp=tp, lots=0)
|
||||
return False, err
|
||||
|
||||
Reference in New Issue
Block a user