fix: Update intraday ticker query to use today's market hours
This commit is contained in:
parent
abcdd561ca
commit
4f6b811666
@ -93,6 +93,7 @@ def get_valid_tickers(min_price: float, max_price: float, min_volume: int, inter
|
||||
"""Get tickers that meet the price and volume criteria"""
|
||||
client = create_client()
|
||||
yesterday = (datetime.now() - timedelta(days=1)).date()
|
||||
today = datetime.now().date()
|
||||
|
||||
if interval == "daily":
|
||||
table = "stock_prices_daily"
|
||||
@ -101,10 +102,10 @@ def get_valid_tickers(min_price: float, max_price: float, min_volume: int, inter
|
||||
else:
|
||||
table = "stock_prices"
|
||||
date_col = "window_start"
|
||||
# Get yesterday's timestamp range
|
||||
start_ts = int(datetime.combine(yesterday, datetime.min.time()).timestamp())
|
||||
end_ts = int(datetime.combine(yesterday, datetime.max.time()).timestamp())
|
||||
date_condition = f"{date_col} BETWEEN {start_ts} AND {end_ts}"
|
||||
# Get today's trading hours timestamp range (9:30 AM to 4:00 PM EST)
|
||||
market_open = int(datetime.combine(today, datetime.strptime("09:30", "%H:%M").time()).timestamp())
|
||||
market_close = int(datetime.combine(today, datetime.strptime("16:00", "%H:%M").time()).timestamp())
|
||||
date_condition = f"{date_col} BETWEEN {market_open} AND {market_close}"
|
||||
|
||||
query = f"""
|
||||
SELECT DISTINCT ticker
|
||||
|
||||
Loading…
Reference in New Issue
Block a user