INNER CODE UNIT · Python
scan_market
aaryansinha16/AI-trader · backend/app.py:783
def scan_market():
"""Run one scan cycle — compute features, check signals, score trades."""
global state
# Only scan during market hours; clear suggestions outside market hours
if not _is_market_hours():
state["trade_suggestions"] = []
state["status"] = "idle"
return
state["status"] = "scanning"
try:
# ── Expire stale suggestions (older than cooldown window) ─────────
now_ts = datetime.now()
def _suggestion_age_secs(t):
try:
ts = datetime.strptime(t.get("time", "00:00:00"), "%H:%M:%S")