diff --git a/src/screener/t_atr_ema.py b/src/screener/t_atr_ema.py index e086bc1..4253440 100644 --- a/src/screener/t_atr_ema.py +++ b/src/screener/t_atr_ema.py @@ -79,7 +79,7 @@ def run_atr_ema_scanner(min_price: float, max_price: float, min_volume: int, por window_start, close, volume, - toDate(toDateTime(window_start/1000000000)) as trade_date + toDateTime(toDateTime(window_start/1000000000)) as trade_date FROM stock_db.stock_prices WHERE window_start BETWEEN {start_ts} AND {end_ts} AND toDateTime(window_start/1000000000) <= now() @@ -87,11 +87,11 @@ def run_atr_ema_scanner(min_price: float, max_price: float, min_volume: int, por daily_data AS ( SELECT ticker, - trade_date, + toDate(trade_date) as trade_date, argMax(close, window_start) as daily_close, sum(volume) as daily_volume FROM filtered_data - GROUP BY ticker, trade_date + GROUP BY ticker, toDate(trade_date) HAVING daily_close BETWEEN {min_price} AND {max_price} AND daily_volume >= {min_volume} ), @@ -100,7 +100,7 @@ def run_atr_ema_scanner(min_price: float, max_price: float, min_volume: int, por ticker, argMax(daily_close, trade_date) as last_close, sum(daily_volume) as total_volume, - max(trade_date) as last_update + max(toUnixTimestamp(trade_date)) as last_update FROM daily_data GROUP BY ticker ) diff --git a/src/screener/t_atr_ema_v2.py b/src/screener/t_atr_ema_v2.py index 34c0771..97f4a22 100644 --- a/src/screener/t_atr_ema_v2.py +++ b/src/screener/t_atr_ema_v2.py @@ -88,7 +88,7 @@ def run_atr_ema_scanner_v2(min_price: float, max_price: float, min_volume: int, window_start, close, volume, - toDate(toDateTime(window_start/1000000000)) as trade_date + toDateTime(toDateTime(window_start/1000000000)) as trade_date FROM stock_db.stock_prices WHERE window_start BETWEEN {start_ts} AND {end_ts} AND toDateTime(window_start/1000000000) <= now() @@ -96,11 +96,11 @@ def run_atr_ema_scanner_v2(min_price: float, max_price: float, min_volume: int, daily_data AS ( SELECT ticker, - trade_date, + toDate(trade_date) as trade_date, argMax(close, window_start) as daily_close, sum(volume) as daily_volume FROM filtered_data - GROUP BY ticker, trade_date + GROUP BY ticker, toDate(trade_date) HAVING daily_close BETWEEN {min_price} AND {max_price} AND daily_volume >= {min_volume} ), @@ -109,7 +109,7 @@ def run_atr_ema_scanner_v2(min_price: float, max_price: float, min_volume: int, ticker, argMax(daily_close, trade_date) as last_close, sum(daily_volume) as total_volume, - max(trade_date) as last_update + max(toUnixTimestamp(trade_date)) as last_update FROM daily_data GROUP BY ticker )