fix: Update date handling in ClickHouse query to filter future dates
This commit is contained in:
parent
a67f88211f
commit
44beec4b6c
@ -12,9 +12,11 @@ def run_atr_ema_target_scanner(min_price: float, max_price: float, min_volume: i
|
|||||||
|
|
||||||
interval = get_interval_choice()
|
interval = get_interval_choice()
|
||||||
end_date = datetime.now()
|
end_date = datetime.now()
|
||||||
start_date = end_date - timedelta(days=90) # Expand window for more data
|
start_date = end_date - timedelta(days=90)
|
||||||
start_ts = int(datetime.combine(start_date.date(), datetime.min.time()).timestamp() * 1e9)
|
|
||||||
end_ts = int(datetime.combine(end_date.date(), datetime.max.time()).timestamp() * 1e9)
|
# Convert to Unix timestamps (nanoseconds)
|
||||||
|
start_ts = int(start_date.timestamp() * 1e9)
|
||||||
|
end_ts = int(end_date.timestamp() * 1e9)
|
||||||
|
|
||||||
client = create_client()
|
client = create_client()
|
||||||
|
|
||||||
@ -32,7 +34,8 @@ def run_atr_ema_target_scanner(min_price: float, max_price: float, min_volume: i
|
|||||||
sum(transactions) AS transaction_count
|
sum(transactions) AS transaction_count
|
||||||
FROM stock_db.stock_prices
|
FROM stock_db.stock_prices
|
||||||
WHERE window_start BETWEEN {start_ts} AND {end_ts}
|
WHERE window_start BETWEEN {start_ts} AND {end_ts}
|
||||||
AND toYear(toDateTime(window_start/1000000000)) <= {end_date.year}
|
AND toYear(toDateTime(window_start/1000000000)) <= toYear(now())
|
||||||
|
AND toYear(toDateTime(window_start/1000000000)) >= (toYear(now()) - 1)
|
||||||
GROUP BY ticker
|
GROUP BY ticker
|
||||||
HAVING last_close BETWEEN {min_price} AND {max_price}
|
HAVING last_close BETWEEN {min_price} AND {max_price}
|
||||||
AND total_volume >= {min_volume}
|
AND total_volume >= {min_volume}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user