fix: Correct datetime handling in scanner queries
This commit is contained in:
parent
c03a361096
commit
0a5ffbcadb
@ -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
|
||||
)
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user