beef up DQN model, fix training issues
This commit is contained in:
102
test_timezone_fix.py
Normal file
102
test_timezone_fix.py
Normal file
@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test Timezone Fix
|
||||
|
||||
This script tests that historical data timestamps are properly converted to Europe/Sofia timezone.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
from core.data_provider import DataProvider
|
||||
|
||||
async def test_timezone_fix():
|
||||
"""Test the timezone conversion fix"""
|
||||
print("=== Testing Timezone Fix ===")
|
||||
|
||||
# Initialize data provider
|
||||
print("1. Initializing data provider...")
|
||||
data_provider = DataProvider()
|
||||
|
||||
# Wait for initialization
|
||||
await asyncio.sleep(2)
|
||||
|
||||
# Test different timeframes
|
||||
timeframes = ['1m', '1h', '1d']
|
||||
symbol = 'ETH/USDT'
|
||||
|
||||
for timeframe in timeframes:
|
||||
print(f"\n2. Testing {timeframe} data for {symbol}:")
|
||||
|
||||
# Get historical data
|
||||
df = data_provider.get_historical_data(symbol, timeframe, limit=5)
|
||||
|
||||
if df is not None and not df.empty:
|
||||
print(f" ✅ Got {len(df)} candles")
|
||||
|
||||
# Check timezone
|
||||
if 'timestamp' in df.columns:
|
||||
first_timestamp = df['timestamp'].iloc[0]
|
||||
last_timestamp = df['timestamp'].iloc[-1]
|
||||
|
||||
print(f" First timestamp: {first_timestamp}")
|
||||
print(f" Last timestamp: {last_timestamp}")
|
||||
|
||||
# Check if timezone is Europe/Sofia
|
||||
if hasattr(first_timestamp, 'tz') and first_timestamp.tz is not None:
|
||||
timezone_str = str(first_timestamp.tz)
|
||||
if 'Europe/Sofia' in timezone_str or 'EET' in timezone_str or 'EEST' in timezone_str:
|
||||
print(f" ✅ Timezone is correct: {timezone_str}")
|
||||
else:
|
||||
print(f" ❌ Timezone is incorrect: {timezone_str}")
|
||||
else:
|
||||
print(" ❌ No timezone information found")
|
||||
|
||||
# Show time difference from UTC
|
||||
if hasattr(first_timestamp, 'utcoffset') and first_timestamp.utcoffset() is not None:
|
||||
offset_hours = first_timestamp.utcoffset().total_seconds() / 3600
|
||||
print(f" UTC offset: {offset_hours:+.0f} hours")
|
||||
|
||||
if offset_hours == 2 or offset_hours == 3: # EET (+2) or EEST (+3)
|
||||
print(" ✅ UTC offset is correct for Europe/Sofia")
|
||||
else:
|
||||
print(f" ❌ UTC offset is incorrect: {offset_hours:+.0f} hours")
|
||||
|
||||
# Show sample data
|
||||
print(" Sample data:")
|
||||
for i in range(min(3, len(df))):
|
||||
row = df.iloc[i]
|
||||
print(f" {row['timestamp']}: O={row['open']:.2f} H={row['high']:.2f} L={row['low']:.2f} C={row['close']:.2f}")
|
||||
else:
|
||||
print(" ❌ No timestamp column found")
|
||||
else:
|
||||
print(f" ❌ No data available for {timeframe}")
|
||||
|
||||
# Test current time comparison
|
||||
print(f"\n3. Current time comparison:")
|
||||
current_utc = datetime.utcnow()
|
||||
current_sofia = datetime.now()
|
||||
|
||||
print(f" Current UTC time: {current_utc}")
|
||||
print(f" Current local time: {current_sofia}")
|
||||
|
||||
# Calculate expected offset
|
||||
import pytz
|
||||
sofia_tz = pytz.timezone('Europe/Sofia')
|
||||
current_sofia_tz = datetime.now(sofia_tz)
|
||||
offset_hours = current_sofia_tz.utcoffset().total_seconds() / 3600
|
||||
|
||||
print(f" Europe/Sofia current time: {current_sofia_tz}")
|
||||
print(f" Current UTC offset: {offset_hours:+.0f} hours")
|
||||
|
||||
if offset_hours == 2:
|
||||
print(" ✅ Currently in EET (Eastern European Time)")
|
||||
elif offset_hours == 3:
|
||||
print(" ✅ Currently in EEST (Eastern European Summer Time)")
|
||||
else:
|
||||
print(f" ❌ Unexpected offset: {offset_hours:+.0f} hours")
|
||||
|
||||
print("\n✅ Timezone fix test completed!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_timezone_fix())
|
Reference in New Issue
Block a user