refactor: Update SQL query to use window_start and timestamp conversion

This commit is contained in:
Bobby (aider) 2025-02-08 11:16:00 -08:00
parent 196ca39e63
commit 316ce608b6

View File

@ -25,16 +25,18 @@ def get_stock_data(ticker: str, start_date: datetime, end_date: datetime, interv
# Unified query format
query = f"""
SELECT
date,
toDate(window_start) as date,
open,
high,
low,
close,
volume
FROM stock_db.{table}
FROM stock_db.stock_prices
WHERE ticker = '{ticker}'
AND date BETWEEN '{start_date.date()}' AND '{end_date.date()}'
ORDER BY date ASC
AND window_start BETWEEN
toUnixTimestamp('{start_date.date()}') * 1000000000 AND
toUnixTimestamp('{end_date.date()}') * 1000000000
ORDER BY window_start ASC
"""
result = client.query(query)