ui: 顶栏透明、设置两列、下单与持仓监控优化

导航栏与页面背景一致;系统设置双列布局;下单三行表单与开仓状态反馈;持仓卡片增加平仓与止盈止损挂单展示。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-24 12:46:23 +08:00
parent 528d9811e3
commit 67683f5562
8 changed files with 304 additions and 75 deletions
+45
View File
@@ -324,6 +324,45 @@ class CtpBridge:
})
return out
def list_active_orders(self) -> list[dict[str, Any]]:
if not self._engine:
return []
out: list[dict[str, Any]] = []
try:
orders = self._engine.get_all_active_orders()
except Exception:
return []
for order in orders or []:
status = getattr(order, "status", None)
status_s = str(status)
if status_s and not any(x in status_s for x in ("NOTTRADED", "PARTTRADED", "SUBMITTING")):
continue
vol = int(getattr(order, "volume", 0) or 0)
traded = int(getattr(order, "traded", 0) or 0)
remain = max(0, vol - traded)
if remain <= 0:
continue
direction = getattr(order, "direction", None)
d = "long"
if direction is not None and str(direction).endswith("SHORT"):
d = "short"
offset = getattr(order, "offset", None)
offset_s = str(offset or "")
sym = getattr(order, "symbol", "") or ""
exchange = getattr(order, "exchange", None)
ex_name = str(exchange.value if hasattr(exchange, "value") else exchange or "")
out.append({
"symbol": sym,
"exchange": ex_name,
"direction": d,
"lots": remain,
"price": float(getattr(order, "price", 0) or 0),
"offset": offset_s,
"order_id": str(getattr(order, "orderid", "") or ""),
"status": status_s,
})
return out
def send_order(
self,
*,
@@ -433,6 +472,12 @@ def ctp_list_positions(mode: str) -> list[dict[str, Any]]:
return b.list_positions()
def ctp_list_active_orders(mode: str) -> list[dict[str, Any]]:
b = get_bridge()
b.ensure_connected(mode)
return b.list_active_orders()
def get_ctp_balance(mode: str) -> Optional[float]:
try:
acc = ctp_get_account(mode)