fix: CTP报单校验连接与tick价,市价改限价,郑商所平今平昨
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+9
-2
@@ -53,6 +53,7 @@ from vnpy_bridge import (
|
||||
ctp_list_positions,
|
||||
ctp_status,
|
||||
execute_order,
|
||||
get_bridge,
|
||||
)
|
||||
|
||||
|
||||
@@ -527,6 +528,12 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
conn.close()
|
||||
return jsonify({"ok": False, "error": err}), 403
|
||||
mode = get_trading_mode(get_setting)
|
||||
ctp_st = ctp_status(mode)
|
||||
if not ctp_st.get("connected"):
|
||||
conn.close()
|
||||
if get_bridge().connect_in_progress():
|
||||
return jsonify({"ok": False, "error": "CTP 连接中,请稍候再下单"}), 400
|
||||
return jsonify({"ok": False, "error": "请先连接 CTP"}), 400
|
||||
sizing = get_sizing_mode(get_setting)
|
||||
if offset.startswith("open") and sizing == MODE_RISK:
|
||||
sl = float(d.get("stop_loss") or 0)
|
||||
@@ -575,8 +582,8 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
conn.commit()
|
||||
send_wechat_msg(f"{trading_mode_label(get_setting)} {offset} {sym} {direction} {lots}手 @{price}")
|
||||
conn.close()
|
||||
return jsonify({"ok": True, "result": result, "lots": lots})
|
||||
except ValueError as exc:
|
||||
return jsonify({"ok": True, "result": result, "lots": lots, "message": "委托已提交柜台,限价单需成交后才会显示持仓"})
|
||||
except (ValueError, RuntimeError) as exc:
|
||||
conn.close()
|
||||
return jsonify({"ok": False, "error": str(exc)}), 400
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user