Files
local-trading-agent/entry_report.py
T

34 lines
2.0 KiB
Python

#!/usr/bin/env python3
import json
from pathlib import Path
import bot
ROOT = Path(__file__).resolve().parent
cfg = json.loads((ROOT / 'config.json').read_text())
st = json.loads((ROOT / 'data/state.json').read_text())
required_gap = cfg['min_gap_pct'] + (2 * cfg['fee_bps'] + cfg['slippage_bps']) / 100.0 + cfg.get('min_edge_after_cost_pct', 0)
print(f"Required entry gap after costs: {required_gap:.2f}%")
print("Candidates now:")
for s in sorted(st.get('last_signals', []), key=lambda x: x.get('gap_pct', -1), reverse=True):
if s.get('status') != 'ok':
label = 'SKIP' if s.get('status') == 'skipped_low_data' else 'ERROR'
print(f"{s.get('symbol')}: {label} {s.get('error')}")
continue
ok = bot.signal_has_fee_aware_edge(cfg, s)
reasons=[]
if s['gap_pct'] < required_gap: reasons.append('gap too small')
if s.get('candles',0) < cfg.get('min_candles_24h',0): reasons.append('not enough candles')
if s.get('dollar_volume_24h',0) < cfg.get('min_dollar_volume_24h',0): reasons.append('volume too low')
if s.get('day_change_pct',0) > cfg.get('max_24h_pump_pct',999): reasons.append('24h pump too hot')
if s.get('day_change_pct',0) < -abs(cfg.get('max_24h_dump_pct',999)): reasons.append('24h dump too deep')
if s.get('rebound_from_recent_low_pct',0) < cfg.get('min_rebound_from_recent_low_pct',0): reasons.append('no rebound')
if s.get('hour_change_pct',0) < -abs(cfg.get('max_drop_last_hour_pct',100)): reasons.append('falling too fast')
flag = 'PASS' if ok else 'BLOCK'
if s.get('symbol') in cfg.get('symbols', []):
mode = 'TRADE'
elif s.get('watch_only'):
mode = 'WATCH'
else:
mode = 'SHADOW'
print(f"{s['symbol']:12s} {mode:6s} {flag:5s} gap={s['gap_pct']:.2f}% day={s.get('day_change_pct',0):+.2f}% rebound={s.get('rebound_from_recent_low_pct',0):.2f}% hour={s.get('hour_change_pct',0):+.2f}% vol24=${s.get('dollar_volume_24h',0):,.0f}" + (f" reason={','.join(reasons)}" if reasons else ''))