remove: 全面移除「错过机会」功能与文案
删除手动记录表单与 /add_miss;停止自动生成错过类交易记录;列表/统计/顶栏不再展示;复盘卡片改为整行。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+10
-78
@@ -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
|
||||
|
||||
@@ -334,7 +334,6 @@
|
||||
<div class="stat-box instance-desktop-only">
|
||||
<div class="stat-item"><div class="label">交易所</div><div class="value">{{ exchange_display }}</div></div>
|
||||
<div class="stat-item"><div class="label">总交易</div><div class="value">{{ total }}</div></div>
|
||||
<div class="stat-item"><div class="label">错过次数</div><div class="value">{{ miss_count }}</div></div>
|
||||
<div class="stat-item"><div class="label">胜率</div><div class="value">{{ rate }}%</div></div>
|
||||
<div class="stat-item"><div class="label">资金账户(USDT)</div><div class="value" id="total-capital">{% if funding_usdt is not none %}{{ funds_fmt(funding_usdt) }}U{% else %}—{% endif %}</div></div>
|
||||
<div class="stat-item"><div class="label">交易日</div><div class="value">{{ trading_day }}</div></div>
|
||||
@@ -532,7 +531,7 @@
|
||||
|
||||
{% if page == 'records' %}
|
||||
<div class="card full records-card">
|
||||
<h2>交易记录 & 错过机会</h2>
|
||||
<h2>交易记录</h2>
|
||||
<div class="form-row" style="margin-bottom:10px;gap:8px">
|
||||
<label style="display:flex;align-items:center;gap:6px;font-size:.82rem;color:#cfd3ef">
|
||||
<input id="review-mode-toggle" type="checkbox">
|
||||
@@ -565,7 +564,7 @@
|
||||
{% if effective_result in ["止盈","保本止盈","移动止盈"] %}<span class="badge profit">{{ effective_result }}</span>
|
||||
{% elif effective_result in ["止损","强制清仓","手动平仓"] %}<span class="badge loss">{{ effective_result }}</span>
|
||||
{% elif effective_result == "时间平仓" %}<span class="badge miss">{{ effective_result }}</span>
|
||||
{% else %}<span class="badge miss">{{ effective_result }}</span>{% endif %}
|
||||
{% else %}<span class="badge">{{ effective_result or '-' }}</span>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
@@ -612,27 +611,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card miss-card" style="opacity:.78">
|
||||
<h2>记录错过机会</h2>
|
||||
<form action="/add_miss" method="post" class="form-row">
|
||||
<input name="symbol" placeholder="品种" required>
|
||||
<select name="type" required>
|
||||
<option value="箱体突破">箱体突破</option>
|
||||
<option value="收敛突破">收敛突破</option>
|
||||
<option value="关键支撑阻力">关键支撑阻力</option>
|
||||
</select>
|
||||
<select name="direction" required>
|
||||
<option value="">方向</option><option value="long">做多</option><option value="short">做空</option>
|
||||
</select>
|
||||
<input name="tp" step="0.0001" placeholder="入场价" required>
|
||||
<input name="sl" step="any" placeholder="止损" required>
|
||||
<input name="tgt" step="any" placeholder="止盈" required>
|
||||
<input name="reason" placeholder="错过原因" required>
|
||||
<button type="submit">记录</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card journal-card">
|
||||
<div class="card full journal-card">
|
||||
<h2>交易复盘记录上传(含截图)</h2>
|
||||
<form id="journal-form" action="/add_journal" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="risk_amount_hint" id="risk-amount-hint">
|
||||
@@ -764,9 +743,6 @@
|
||||
<button type="button" class="stats-toggle" id="stats-toggle-btn" onclick="toggleStatsCard()">折叠</button>
|
||||
</div>
|
||||
<div class="stats-content" id="stats-content">
|
||||
<div class="stat-box" style="margin-bottom:10px">
|
||||
<div class="stat-item"><div class="label">持仓占用导致错过(累计)</div><div class="value">{{ occupied_miss_total }}</div></div>
|
||||
</div>
|
||||
<div class="sub" style="margin-bottom:12px;color:#8892b0;font-size:.82rem">
|
||||
统计分析按<strong>北京时间 {{ stats_bundle.stats_reset_hour }}:00</strong>切日计入(与顶栏 UTC 列表窗无关)。历史总开仓(累计):
|
||||
<strong style="color:#cfd3ef">{{ stats_bundle.total_opens_all }}</strong> 次
|
||||
|
||||
Reference in New Issue
Block a user