diff --git a/app.py b/app.py index 63ffbe85..44ecec06 100755 --- a/app.py +++ b/app.py @@ -7008,6 +7008,8 @@ def get_watchlist_realtime(): load_trading_days() # ========== 使用 Redis 缓存优化批量查询 ========== + today = datetime.now().date() + # 1. 先从缓存批量获取 cached_prices, missing_codes = get_cached_latest_prices_batch(full_codes) @@ -7028,7 +7030,6 @@ def get_watchlist_realtime(): # 3. 查询缓存未命中的股票(使用 7 天回溯以处理节假日) if missing_codes: client = get_clickhouse_client() - today = datetime.now().date() start_date = today - timedelta(days=7) batch_query = """