Optional numeric return head (predicts percent change for 1s,1m,1h,1d)
This commit is contained in:
@@ -1268,15 +1268,12 @@ class DataProvider:
|
||||
logger.debug(f"No valid candles generated for {symbol}")
|
||||
return None
|
||||
|
||||
# Convert to DataFrame (timestamps remain UTC tz-aware)
|
||||
# Convert to DataFrame and normalize timestamps to UTC tz-aware
|
||||
df = pd.DataFrame(candles)
|
||||
# Ensure timestamps are timezone-aware (UTC to match COB WebSocket data)
|
||||
if not df.empty and 'timestamp' in df.columns:
|
||||
# Normalize to UTC tz-aware using pandas idioms
|
||||
if df['timestamp'].dt.tz is None:
|
||||
df['timestamp'] = pd.to_datetime(df['timestamp'], utc=True)
|
||||
else:
|
||||
df['timestamp'] = df['timestamp'].dt.tz_convert('UTC')
|
||||
# Coerce to datetime with UTC; avoid .dt on non-datetimelike
|
||||
df['timestamp'] = pd.to_datetime(df['timestamp'], utc=True, errors='coerce')
|
||||
df = df.dropna(subset=['timestamp'])
|
||||
|
||||
df = df.sort_values('timestamp').reset_index(drop=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user