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:
parent
af732f1438
commit
809fb60a50
@ -217,6 +217,11 @@ def replay_trade(cur, tid, symbol, direction, strategy, entry_ts, atr):
|
|||||||
result_exit_ts = timeout_ts
|
result_exit_ts = timeout_ts
|
||||||
result_exit_price = exit_price
|
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 {
|
return {
|
||||||
'id': tid,
|
'id': tid,
|
||||||
'entry': entry,
|
'entry': entry,
|
||||||
@ -241,6 +246,7 @@ def main(dry_run=False):
|
|||||||
SELECT id, symbol, direction, strategy, entry_ts, atr_at_entry
|
SELECT id, symbol, direction, strategy, entry_ts, atr_at_entry
|
||||||
FROM paper_trades
|
FROM paper_trades
|
||||||
WHERE atr_at_entry > 0
|
WHERE atr_at_entry > 0
|
||||||
|
AND status NOT IN ('active', 'tp1_hit')
|
||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
""")
|
""")
|
||||||
trades = cur.fetchall()
|
trades = cur.fetchall()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user