Files
gogo2/ANNOTATE_TIMEZONE_FIX_SUMMARY.md
2025-11-22 16:22:13 +02:00

56 lines
1.7 KiB
Markdown

# 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:**
1. `ANNOTATE/core/annotation_manager.py`
- Changed `datetime.now()``datetime.now(pytz.UTC)`
- Lines: 49, 99, 454
2. `ANNOTATE/web/app.py`
- Added `from datetime import datetime, timezone`
- Changed `datetime.now()``datetime.now(timezone.utc)`
- Line: 2451
3. `ANNOTATE/core/real_training_adapter.py`
- Changed all `datetime.now()``datetime.now(timezone.utc)`
- Lines: 2146, 2875, 3140, 3161 (ghost candle predictions)
### 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
## Result
- ✅ All timestamps now in UTC
- ✅ Candles, predictions, and annotations aligned on same timeline
- ✅ No more 2-hour offset
## Testing
1. Restart ANNOTATE application
2. Create new annotations
3. Verify predictions appear at correct time
4. 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