fix: Replace async ClickHouse query with synchronous method

This commit is contained in:
Bobby (aider) 2025-02-08 11:01:13 -08:00
parent 8560214494
commit 7ef27027ee

View File

@ -49,8 +49,15 @@ def run_atr_ema_target_scanner(min_price: float, max_price: float, min_volume: i
return
print("\n🔍 Verifying data availability...")
with client.query_stream(f"SELECT ticker FROM stock_db.stock_prices WHERE window_start BETWEEN {start_ts} AND {end_ts} GROUP BY ticker HAVING count() > 50") as stream:
valid_symbols = {row[0] for row in stream.result_rows}
valid_query = f"""
SELECT ticker
FROM stock_db.stock_prices
WHERE window_start BETWEEN {start_ts} AND {end_ts}
GROUP BY ticker
HAVING count() > 50
"""
valid_result = client.query(valid_query)
valid_symbols = {row[0] for row in valid_result.result_rows}
qualified_stocks = [s for s in stocks if s[0] in valid_symbols]
print(f"\n✅ Found {len(qualified_stocks)} stocks with sufficient historical data")