refactor: Update SQL query to use window_start and timestamp conversion
This commit is contained in:
parent
196ca39e63
commit
316ce608b6
@ -25,16 +25,18 @@ def get_stock_data(ticker: str, start_date: datetime, end_date: datetime, interv
|
|||||||
# Unified query format
|
# Unified query format
|
||||||
query = f"""
|
query = f"""
|
||||||
SELECT
|
SELECT
|
||||||
date,
|
toDate(window_start) as date,
|
||||||
open,
|
open,
|
||||||
high,
|
high,
|
||||||
low,
|
low,
|
||||||
close,
|
close,
|
||||||
volume
|
volume
|
||||||
FROM stock_db.{table}
|
FROM stock_db.stock_prices
|
||||||
WHERE ticker = '{ticker}'
|
WHERE ticker = '{ticker}'
|
||||||
AND date BETWEEN '{start_date.date()}' AND '{end_date.date()}'
|
AND window_start BETWEEN
|
||||||
ORDER BY date ASC
|
toUnixTimestamp('{start_date.date()}') * 1000000000 AND
|
||||||
|
toUnixTimestamp('{end_date.date()}') * 1000000000
|
||||||
|
ORDER BY window_start ASC
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = client.query(query)
|
result = client.query(query)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user