From 809fb60a50457d578887a84434e6af5b7c141368 Mon Sep 17 00:00:00 2001 From: dev-worker Date: Tue, 3 Mar 2026 04:50:00 +0000 Subject: [PATCH] =?UTF-8?q?scripts:=20replay=5Fpaper=5Ftrades=20v3?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 加status NOT IN (active,tp1_hit)保护活跃单 - 内置fee_r扣除: 2*0.0005*entry/rd - 解决xiaofan审阅的3个硬问题 --- scripts/replay_paper_trades.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/replay_paper_trades.py b/scripts/replay_paper_trades.py index b006983..30367b0 100644 --- a/scripts/replay_paper_trades.py +++ b/scripts/replay_paper_trades.py @@ -217,6 +217,11 @@ def replay_trade(cur, tid, symbol, direction, strategy, entry_ts, atr): result_exit_ts = timeout_ts result_exit_price = exit_price + # 扣手续费: fee_r = 2 * taker_rate * entry / rd(开仓+平仓各一次) + PAPER_FEE_RATE = 0.0005 + fee_r = 2 * PAPER_FEE_RATE * entry / rd if rd > 0 else 0 + result_pnl_r -= fee_r + return { 'id': tid, 'entry': entry, @@ -241,6 +246,7 @@ def main(dry_run=False): SELECT id, symbol, direction, strategy, entry_ts, atr_at_entry FROM paper_trades WHERE atr_at_entry > 0 + AND status NOT IN ('active', 'tp1_hit') ORDER BY id ASC """) trades = cur.fetchall()