Verify that real-time intraday data exists before appening to historical daily data

This commit is contained in:
moshferatu 2024-11-12 07:20:13 -08:00
parent a4fe44ad2c
commit 24d216b63c

View File

@ -15,6 +15,9 @@ def get_daily_data(symbol: str, start_date: datetime = datetime.today() - timede
if today not in daily_data['Date'].values: if today not in daily_data['Date'].values:
intraday_data = ohlc(symbol = symbol, minutes = 5) intraday_data = ohlc(symbol = symbol, minutes = 5)
if intraday_data.empty:
return daily_data
open_price = intraday_data['Open'].iloc[0] open_price = intraday_data['Open'].iloc[0]
high_price = intraday_data['High'].max() high_price = intraday_data['High'].max()
low_price = intraday_data['Low'].min() low_price = intraday_data['Low'].min()