Fix float P/L when using OpenCost entry and clear CTP hint on connect.

Recalculate position quotes from resolved entry instead of stale CTP PositionProfit, and hide the auto-connect disabled banner once CTP is connected.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-02 21:24:48 +08:00
parent dca773d6be
commit 075fae37ec
2 changed files with 10 additions and 7 deletions
+6 -5
View File
@@ -2337,19 +2337,20 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
mark = ctp_get_tick_price(mode, ths)
if not mark or mark <= 0:
continue
entry, _ = _resolve_ctp_entry_price(
entry, entry_src = _resolve_ctp_entry_price(
mode, ths, direction, p,
)
if entry <= 0:
continue
mult = float(get_contract_spec(ths).get("mult") or 10)
ctp_pnl = float(p.get("pnl") or 0)
if ctp_pnl != 0:
float_pnl = round(ctp_pnl, 2)
elif direction == "long":
if direction == "long":
float_pnl = round((mark - entry) * mult * lots, 2)
else:
float_pnl = round((entry - mark) * mult * lots, 2)
if entry_src == "position_cost":
ctp_pnl = float(p.get("pnl") or 0)
if ctp_pnl != 0:
float_pnl = round(ctp_pnl, 2)
row_key = _canonical_position_key(
ths, direction, (p.get("exchange") or ""),
)