scripts: replay_paper_trades v3修复

- 加status NOT IN (active,tp1_hit)保护活跃单
- 内置fee_r扣除: 2*0.0005*entry/rd
- 解决xiaofan审阅的3个硬问题
This commit is contained in:
dev-worker 2026-03-03 04:50:00 +00:00
parent af732f1438
commit 809fb60a50

View File

@ -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()