136 lines
4.4 KiB
Markdown
136 lines
4.4 KiB
Markdown
# Prediction Candle Update - Debug Guide
|
|
|
|
## Current Status
|
|
|
|
Charts have been **restored** - pivot dots are back.
|
|
|
|
## How Prediction Updates Should Work
|
|
|
|
### 1. Prediction Created
|
|
- Ghost candle added to `ghostCandleHistory[timeframe]`
|
|
- Initial status: "AWAITING VALIDATION"
|
|
- Opacity: 30%
|
|
|
|
### 2. Real Candle Arrives
|
|
- `updateLatestCandle()` is called
|
|
- Triggers `_checkPredictionAccuracy(timeframe, chart.data)`
|
|
- Validation checks if timestamp matches prediction
|
|
|
|
### 3. Validation Happens
|
|
- Compares predicted vs actual OHLCV
|
|
- Calculates accuracy, errors, direction
|
|
- Stores accuracy in `ghost.accuracy`
|
|
- Logs: `[timeframe] ✓ Validated X predictions`
|
|
|
|
### 4. Display Refresh
|
|
- `_refreshPredictionDisplay(timeframe)` is called
|
|
- Removes old ghost candle traces
|
|
- Re-adds ghost candles with updated tooltips
|
|
- Validated candles show accuracy in tooltip
|
|
|
|
## Console Logs to Watch For
|
|
|
|
### Good Flow:
|
|
```
|
|
[1s] Added new candle: 2025-11-22 16:30:05
|
|
[1s] Triggering validation check for candle at index 2498
|
|
[1s] ✓ Validated 1 predictions (0 expired), 9 still pending, 1 total validated
|
|
[1s] Model Accuracy: 85.3% avg, 100.0% direction
|
|
[1s] Triggering prediction display refresh...
|
|
[1s] Refreshing 10 prediction candles with updated accuracy
|
|
[1s] Removing 10 old prediction traces
|
|
[1s] Added 10 updated prediction traces
|
|
```
|
|
|
|
### Problem Indicators:
|
|
```
|
|
[1s] No match yet for prediction: ... (age > 30s) ← Timestamps not matching
|
|
[1s] No ghost candle history, skipping prediction refresh ← Predictions not being stored
|
|
[1s] Chart has insufficient traces ← Chart initialization failed
|
|
```
|
|
|
|
## Debug Steps
|
|
|
|
### Step 1: Check Browser Console
|
|
Open DevTools Console and look for:
|
|
1. `Added new candle` messages - are candles updating?
|
|
2. `Validated X predictions` - is validation happening?
|
|
3. `Refreshing X prediction candles` - is refresh being called?
|
|
4. Any errors in red
|
|
|
|
### Step 2: Check Prediction Storage
|
|
In console, run:
|
|
```javascript
|
|
window.appState.chartManager.ghostCandleHistory
|
|
```
|
|
Should show predictions per timeframe with `accuracy` property when validated.
|
|
|
|
### Step 3: Check if Validation is Triggered
|
|
Look for:
|
|
```
|
|
[1s] Triggering validation check for candle at index...
|
|
```
|
|
This should appear every time a new candle is added.
|
|
|
|
### Step 4: Check Timestamp Matching
|
|
If you see many "No match yet for prediction" messages, the timestamps might not be aligning.
|
|
|
|
Check:
|
|
```javascript
|
|
// Last real candle timestamp
|
|
window.appState.chartManager.charts['1s'].data.timestamps.slice(-3)
|
|
|
|
// Prediction timestamps
|
|
window.appState.chartManager.ghostCandleHistory['1s'].map(g => g.timestamp)
|
|
```
|
|
|
|
## Common Issues & Fixes
|
|
|
|
### Issue 1: Predictions Never Validate
|
|
**Symptom**: All predictions stay "AWAITING VALIDATION" forever
|
|
**Cause**: Timestamp mismatch or validation not being triggered
|
|
**Fix**: Check that `updateLatestCandle` is calling `_checkPredictionAccuracy`
|
|
|
|
### Issue 2: Predictions Validate But Don't Update Visually
|
|
**Symptom**: Console shows validation, but tooltips still show "AWAITING VALIDATION"
|
|
**Cause**: `_refreshPredictionDisplay` not being called or failing
|
|
**Fix**: Check for errors in `_refreshPredictionDisplay`
|
|
|
|
### Issue 3: Charts are Blank
|
|
**Symptom**: No candles show at all
|
|
**Cause**: Chart initialization failed
|
|
**Fix**: Check console for "Chart has insufficient traces" errors
|
|
|
|
### Issue 4: Predictions Expire Immediately
|
|
**Symptom**: All predictions marked as "EXPIRED (no match)" after 30s
|
|
**Cause**: Timestamp format mismatch - predictions and real candles use different formats
|
|
**Fix**: Ensure both use `YYYY-MM-DD HH:MM:SS` UTC format
|
|
|
|
## Key Files
|
|
- `/ANNOTATE/web/static/js/chart_manager.js`:
|
|
- `updateLatestCandle()` - line 285 - handles new candles
|
|
- `_checkPredictionAccuracy()` - line 2145 - validates predictions
|
|
- `_refreshPredictionDisplay()` - line 2430 - updates display
|
|
|
|
## Next Steps
|
|
|
|
1. **Hard refresh**: `Ctrl + Shift + R`
|
|
2. **Open Console**: F12 → Console tab
|
|
3. **Start live training**: Click "Live Inference + Per-Candle Training"
|
|
4. **Watch console logs**: Look for validation and refresh messages
|
|
5. **Share console output**: Copy any errors or unexpected behavior
|
|
|
|
## Expected Timeline
|
|
|
|
For 1s charts:
|
|
- T+0s: Prediction created for T+1s
|
|
- T+1s: Real candle for T+1s arrives
|
|
- T+2s: Validation happens (against T-1s candle)
|
|
- T+2s: Display refreshes with accuracy
|
|
|
|
For 1m charts:
|
|
- T+0m: Prediction created for T+1m
|
|
- T+1m: Real candle for T+1m arrives
|
|
- T+2m: Validation happens
|
|
- T+2m: Display refreshes with accuracy
|