timezones

This commit is contained in:
Dobromir Popov
2025-07-27 20:43:28 +03:00
parent 1636082ba3
commit 1894d453c9
5 changed files with 255 additions and 31 deletions

View File

@ -1082,6 +1082,8 @@ class DataProvider:
# Process columns with proper timezone handling (MEXC returns UTC timestamps)
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms', utc=True)
# Convert from UTC to Europe/Sofia timezone
df['timestamp'] = df['timestamp'].dt.tz_convert('Europe/Sofia')
for col in ['open', 'high', 'low', 'close', 'volume']:
df[col] = df[col].astype(float)
@ -1125,9 +1127,17 @@ class DataProvider:
# Convert timestamp to datetime if needed
if isinstance(timestamp, (int, float)):
tick_time = datetime.fromtimestamp(timestamp)
tick_time = datetime.fromtimestamp(timestamp, tz=pd.Timestamp.now().tz)
# If no timezone info, assume UTC and convert to Europe/Sofia
if tick_time.tzinfo is None:
tick_time = tick_time.replace(tzinfo=pd.Timestamp.now(tz='UTC').tz)
tick_time = tick_time.astimezone(pd.Timestamp.now(tz='Europe/Sofia').tz)
elif isinstance(timestamp, datetime):
tick_time = timestamp
# If no timezone info, assume UTC and convert to Europe/Sofia
if tick_time.tzinfo is None:
tick_time = tick_time.replace(tzinfo=pd.Timestamp.now(tz='UTC').tz)
tick_time = tick_time.astimezone(pd.Timestamp.now(tz='Europe/Sofia').tz)
else:
continue
@ -1245,6 +1255,8 @@ class DataProvider:
# Process columns with proper timezone handling (Binance returns UTC timestamps)
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms', utc=True)
# Convert from UTC to Europe/Sofia timezone
df['timestamp'] = df['timestamp'].dt.tz_convert('Europe/Sofia')
for col in ['open', 'high', 'low', 'close', 'volume']:
df[col] = df[col].astype(float)