1.7 KiB
1.7 KiB
Timezone Fix for ANNOTATE Charts
Problem
Charts showed 2-hour offset between:
- Candle data (from exchange in UTC)
- Predictions/ghost candles (timestamped in local EET time)
- Trade annotations/actions (timestamped in local EET time)
Root Cause
System timezone: EET (UTC+2)
- Exchange data: UTC
- Python code: Used
datetime.now()which returns local time (EET) - Result: 2-hour mismatch on charts
Solution Applied
1. Python Backend Changes
Updated Files:
-
ANNOTATE/core/annotation_manager.py- Changed
datetime.now()→datetime.now(pytz.UTC) - Lines: 49, 99, 454
- Changed
-
ANNOTATE/web/app.py- Added
from datetime import datetime, timezone - Changed
datetime.now()→datetime.now(timezone.utc) - Line: 2451
- Added
-
ANNOTATE/core/real_training_adapter.py- Changed all
datetime.now()→datetime.now(timezone.utc) - Lines: 2146, 2875, 3140, 3161 (ghost candle predictions)
- Changed all
2. JavaScript Frontend Changes
Updated File:
ANNOTATE/web/static/js/chart_manager.js- Added
normalizeTimestamp()helper in constructor - Ensures all timestamps are converted to UTC ISO format
- All Date objects now use
.toISOString()for UTC consistency
- Added
Result
- ✅ All timestamps now in UTC
- ✅ Candles, predictions, and annotations aligned on same timeline
- ✅ No more 2-hour offset
Testing
- Restart ANNOTATE application
- Create new annotations
- Verify predictions appear at correct time
- Verify ghost candles align with real candles
Notes
- Existing annotations in database remain in local time (will show correctly once converted on read)
- New annotations are stored in UTC
- Charts now display all timestamps consistently in UTC