remove: 全面移除「错过机会」功能与文案

删除手动记录表单与 /add_miss;停止自动生成错过类交易记录;列表/统计/顶栏不再展示;复盘卡片改为整行。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-05 22:21:30 +08:00
parent 88fe4bbe56
commit 7bb6ee1154
11 changed files with 87 additions and 313 deletions
+10 -78
View File
@@ -220,7 +220,11 @@ from lib.common.history_window_lib import (
utc_window_to_bj_sql_strings,
utc_window_to_utc_sql_strings,
)
from lib.trade.trade_result_lib import count_winning_trades, normalize_result_with_pnl
from lib.trade.trade_result_lib import (
count_winning_trades,
filter_trade_records_excluding_miss,
normalize_result_with_pnl,
)
from lib.trade.trade_exchange_stats_lib import attach_exchange_stats_to_trade, filter_position_lifecycle_fills
@@ -6899,27 +6903,20 @@ def render_main_page(page="trade", embed_mode=None):
f"SELECT * FROM trade_records WHERE {tr_ts} >= ? AND {tr_ts} <= ? ORDER BY id DESC LIMIT 1000",
(start_bj, end_bj),
).fetchall()
records = [to_effective_trade_dict(r) for r in raw_records]
total = len(records)
miss_count = sum(1 for r in records if (r.get("effective_result") or "") == "错过")
win = count_winning_trades(records)
occupied_miss_total = sum(
1
for r in records
if (r.get("effective_result") or "") == "错过"
and ("持仓占用" in str(r.get("effective_miss_reason") or ""))
records = filter_trade_records_excluding_miss(
[to_effective_trade_dict(r) for r in raw_records]
)
total = len(records)
win = count_winning_trades(records)
rate = round(win / total * 100, 2) if total else 0
elif plan.records_summary:
summary = trade_records_summary(conn, start_bj, end_bj, tr_ts)
records = summary["records"]
total = summary["total"]
miss_count = summary["miss_count"]
rate = summary["rate"]
occupied_miss_total = summary["occupied_miss_total"]
else:
records = []
total = miss_count = rate = occupied_miss_total = 0
total = rate = 0
active_count = len(order_list)
from lib.strategy.strategy_trade_labels import count_position_limit_active_monitors
@@ -6972,7 +6969,6 @@ def render_main_page(page="trade", embed_mode=None):
order=order_list,
record=records,
total=total,
miss_count=miss_count,
rate=rate,
trading_day=trading_day,
funding_usdt=funding_usdt,
@@ -7016,7 +7012,6 @@ def render_main_page(page="trade", embed_mode=None):
),
breakeven_rr_trigger=BREAKEVEN_RR_TRIGGER,
breakeven_offset_pct=BREAKEVEN_OFFSET_PCT,
occupied_miss_total=occupied_miss_total,
price_fmt=format_price_for_symbol,
funds_fmt=format_usdt,
usdt_fmt=format_usdt,
@@ -8192,32 +8187,6 @@ def add_order():
return redirect("/trade")
ok, reason = precheck_risk(conn, symbol, direction)
if not ok:
if "已达最大持仓数" in reason:
try:
tp_raw = parse_positive_float(d.get("tp"))
sl_raw = parse_positive_float(d.get("sl"))
tgt_raw = parse_positive_float(d.get("tgt"))
except Exception:
tp_raw = sl_raw = tgt_raw = None
ex_miss = normalize_exchange_symbol(symbol)
try:
ensure_markets_loaded()
except Exception:
pass
insert_trade_record(
conn,
symbol=symbol,
monitor_type="下单监控",
direction=direction if direction in ("long", "short") else "long",
trigger_price=round_price_to_exchange(ex_miss, tp_raw) if tp_raw else 0,
stop_loss=round_price_to_exchange(ex_miss, sl_raw) if sl_raw else 0,
take_profit=round_price_to_exchange(ex_miss, tgt_raw) if tgt_raw else 0,
result="错过",
miss_reason=f"持仓占用:{reason}",
opened_at=app_now_str(),
closed_at=app_now_str(),
)
conn.commit()
conn.close()
flash(f"风控拒绝下单:{reason}")
return redirect("/trade")
@@ -8918,43 +8887,6 @@ def del_order(id):
conn.close()
return redirect("/")
@app.route("/add_miss", methods=["POST"])
@login_required
def add_miss():
d = request.form
direction = d.get("direction", "long")
sym_in = normalize_symbol_input(d.get("symbol"))
ex_sym = normalize_exchange_symbol(sym_in)
try:
ensure_markets_loaded()
except Exception:
pass
try:
tp_px = round_price_to_exchange(ex_sym, float(d["tp"]))
sl_px = round_price_to_exchange(ex_sym, float(d["sl"]))
tgt_px = round_price_to_exchange(ex_sym, float(d["tgt"]))
except Exception:
flash("价格格式错误")
return _redirect_records()
conn = get_db()
insert_trade_record(
conn,
symbol=sym_in,
monitor_type=d["type"],
direction=direction,
trigger_price=tp_px,
stop_loss=sl_px,
take_profit=tgt_px,
result="错过",
miss_reason=d["reason"],
opened_at=app_now_str(),
closed_at=app_now_str(),
)
conn.commit()
conn.close()
flash("已记录错过机会")
return _redirect_records()
@app.route("/add_journal", methods=["POST"])
@login_required