diff --git a/install_trading.py b/install_trading.py index 2e350d5..827b07d 100644 --- a/install_trading.py +++ b/install_trading.py @@ -430,9 +430,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se trailing_be = int(existing.get("trailing_be") or 0) open_time_val = existing.get("open_time") or now_s if ctp_open_time: - prev = (open_time_val or "")[:19] - if not prev or ctp_open_time < prev: - open_time_val = ctp_open_time + open_time_val = ctp_open_time conn.execute( """UPDATE trade_order_monitors SET symbol=?, symbol_name=?, market_code=?, lots=?, entry_price=?, @@ -495,12 +493,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se "SELECT open_time FROM trade_order_monitors WHERE id=?", (mid,), ).fetchone() db_open = (row["open_time"] or "").strip() if row else "" - open_time_val = db_open or ctp_open - if ctp_open and db_open: - if ctp_open < db_open[:19]: - open_time_val = ctp_open - elif ctp_open: - open_time_val = ctp_open + open_time_val = ctp_open or db_open execute_retry( conn, """UPDATE trade_order_monitors SET lots=?, entry_price=?, @@ -552,7 +545,12 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se sl = float(mon["stop_loss"]) if mon and mon.get("stop_loss") is not None else None tp = float(mon["take_profit"]) if mon and mon.get("take_profit") is not None else None ctp_open = (ctp.get("open_time") or "").strip() if ctp else "" - open_time = ctp_open or ((mon.get("open_time") or "") if mon else "") + if ctp and ctp_open: + open_time = ctp_open + open_time_source = "ctp" + else: + open_time = ((mon.get("open_time") or "") if mon else "") + open_time_source = "local" if open_time else "" holding = _holding_duration(open_time, now_iso) if open_time else "" mark = None @@ -630,6 +628,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se "stop_loss": sl, "take_profit": tp, "open_time": open_time or None, + "open_time_source": open_time_source or None, "holding_duration": holding or None, "mark_price": mark, "current_price": mark, @@ -637,6 +636,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se "margin_source": margin_source, "position_pct": position_pct, "risk_amount": pos_metrics.get("risk_amount") if sl is not None else None, + "reward_amount": pos_metrics.get("reward_amount") if tp is not None else None, "risk_pct": pos_metrics.get("risk_pct") if sl is not None else None, "rr_ratio": pos_metrics.get("rr_ratio") if sl is not None and tp is not None else None, "float_pnl": float_pnl, diff --git a/static/js/trade.js b/static/js/trade.js index 315c178..ec391af 100644 --- a/static/js/trade.js +++ b/static/js/trade.js @@ -683,14 +683,17 @@ var metaLine = '来源 ' + (row.source_label || 'CTP') + '' + (row.rr_ratio != null ? ' · 盈亏比 ' + row.rr_ratio + ':1' : '') + - ' · 止损 ' + (row.stop_loss != null ? fmtNum(row.stop_loss) : '--') + '' + - ' · 止盈 ' + (row.take_profit != null ? fmtNum(row.take_profit) : '--') + '' + + ' · 止损金额 ' + + (row.risk_amount != null ? fmtNum(row.risk_amount) + ' 元' : '--') + '' + + ' · 盈利金额 ' + + (row.reward_amount != null ? fmtNum(row.reward_amount) + ' 元' : '--') + '' + ' · ' + slTpStatusHtml(row) + ' · 移动保本 ' + trailingStatusHtml(row) + (slTpBtn ? ' · ' + slTpBtn : '') + (row.sync_pending ? ' · 同步柜台中…' : ''); var feeLabel = row.fee_source === 'ctp' ? '手续费(柜台)' : '手续费'; var marginLabel = row.margin_source === 'ctp' ? '占用保证金(柜台)' : '占用保证金'; + var openLabel = row.open_time_source === 'ctp' ? '开仓(柜台)' : '开仓'; return ( '