refactor: Remove orphaned database query code block from data_utils.py
This commit is contained in:
parent
8775d35326
commit
9c6d1d1f10
@ -139,69 +139,3 @@ def process_signal_data(ticker: str, signal_data: dict, current_volume: int,
|
||||
})
|
||||
|
||||
return entry_data
|
||||
|
||||
|
||||
result = client.query(query)
|
||||
|
||||
if not result.result_rows:
|
||||
return pd.DataFrame()
|
||||
|
||||
# Create base DataFrame
|
||||
df = pd.DataFrame(
|
||||
result.result_rows,
|
||||
columns=['date', 'open', 'high', 'low', 'close', 'volume']
|
||||
)
|
||||
|
||||
# Convert numeric columns
|
||||
numeric_columns = ['open', 'high', 'low', 'close', 'volume']
|
||||
for col in numeric_columns:
|
||||
df[col] = pd.to_numeric(df[col], errors='coerce')
|
||||
|
||||
# Convert date column
|
||||
df['date'] = pd.to_datetime(df['date'])
|
||||
|
||||
# Set date as index for resampling
|
||||
df.set_index('date', inplace=True)
|
||||
|
||||
# Resample based on interval
|
||||
if interval == 'daily':
|
||||
rule = '1D'
|
||||
elif interval == '5min':
|
||||
rule = '5T'
|
||||
elif interval == '15min':
|
||||
rule = '15T'
|
||||
elif interval == '30min':
|
||||
rule = '30T'
|
||||
elif interval == '1hour':
|
||||
rule = '1H'
|
||||
else:
|
||||
rule = '1D' # Default to daily
|
||||
|
||||
resampled = df.resample(rule).agg({
|
||||
'open': 'first',
|
||||
'high': 'max',
|
||||
'low': 'min',
|
||||
'close': 'last',
|
||||
'volume': 'sum'
|
||||
}).dropna()
|
||||
|
||||
# Reset index to get date as column
|
||||
resampled.reset_index(inplace=True)
|
||||
|
||||
# Filter to requested date range
|
||||
mask = (resampled['date'] >= start_date + timedelta(days=89)) & (resampled['date'] <= end_date)
|
||||
resampled = resampled.loc[mask]
|
||||
|
||||
# Handle null values
|
||||
if resampled['close'].isnull().any():
|
||||
print(f"Warning: Found null values in close prices")
|
||||
resampled = resampled.dropna(subset=['close'])
|
||||
|
||||
if resampled.empty or 'close' not in resampled.columns:
|
||||
return pd.DataFrame()
|
||||
|
||||
return resampled
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error fetching {ticker} data: {str(e)}")
|
||||
return pd.DataFrame()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user