fix: порог обнаружения депозита 15% от баланса (мин $20)

Предотвращает ложные срабатывания от unrealized PnL колебаний.
При $115 порог = $20, при $265 = $40. Реальный депозит $150 пройдёт.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-10 19:32:38 +10:00
co-authored by Claude Opus 4.6
parent 0fc318dec2
commit f796883b3a
+4 -1
View File
@@ -164,7 +164,10 @@ def run_cycle(conn: sqlite3.Connection, cfg: Config) -> list[str]:
"WHERE exchange_balance IS NOT NULL ORDER BY id DESC LIMIT 1"
).fetchone()
deposit = detect_deposit(conn, exchange_bal, realized_pnl)
# Threshold: 15% of balance to filter unrealized PnL noise
prev_bal_val = prev_snap["exchange_balance"] if prev_snap else exchange_bal
threshold = max(20.0, prev_bal_val * 0.15)
deposit = detect_deposit(conn, exchange_bal, realized_pnl, threshold)
if deposit is not None:
prev_bal = prev_snap["exchange_balance"] if prev_snap else 0
record_deposit(conn, deposit, prev_bal, exchange_bal)