合并期货下单与持仓监控为统一界面,移除手工录入。
策略与 CTP 自动同步持仓,新增 /api/trading/live 聚合展示与平仓接口。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -886,16 +886,6 @@ def keys():
|
||||
return render_template("keys.html", keys=key_list, history=history)
|
||||
|
||||
|
||||
@app.route("/positions")
|
||||
@login_required
|
||||
def positions():
|
||||
conn = get_db()
|
||||
pos_list = conn.execute(
|
||||
"SELECT * FROM position_monitors WHERE status='active' ORDER BY id DESC"
|
||||
).fetchall()
|
||||
conn.close()
|
||||
return render_template("positions.html", positions=pos_list)
|
||||
|
||||
|
||||
@app.route("/add_key", methods=["POST"])
|
||||
@login_required
|
||||
@@ -928,36 +918,7 @@ def add_key():
|
||||
@app.route("/add_position", methods=["POST"])
|
||||
@login_required
|
||||
def add_position():
|
||||
d = request.form
|
||||
symbol = d.get("symbol", "").strip()
|
||||
symbol_name = d.get("symbol_name", "").strip()
|
||||
market_code = d.get("market_code", "").strip()
|
||||
sina_code = d.get("sina_code", "").strip()
|
||||
if not symbol or not market_code:
|
||||
flash("请从下拉列表选择品种")
|
||||
return redirect(url_for("positions"))
|
||||
entry = float(d["entry_price"])
|
||||
sl = float(d["stop_loss"])
|
||||
tp = float(d["take_profit"])
|
||||
direction = d.get("direction", "").strip()
|
||||
if not direction:
|
||||
direction = "long" if sl < entry else "short"
|
||||
open_time = d.get("open_time", "").strip()
|
||||
lots = float(d.get("lots") or 1)
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
"""INSERT INTO position_monitors
|
||||
(symbol, symbol_name, market_code, sina_code, direction,
|
||||
lots, entry_price, stop_loss, take_profit, open_time)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?)""",
|
||||
(
|
||||
symbol, symbol_name, market_code, sina_code, direction,
|
||||
lots, entry, sl, tp, open_time,
|
||||
),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
flash("持仓已添加")
|
||||
flash("持仓由策略交易或 CTP 自动同步,无需手工录入")
|
||||
return redirect(url_for("positions"))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user