286 lines
6.3 KiB
Markdown
286 lines
6.3 KiB
Markdown
# Real-Time Inference Guide
|
||
|
||
## 🎯 Overview
|
||
|
||
Real-time inference mode runs your trained model on **live streaming data** from the DataProvider, updating charts every second and displaying model predictions in real-time.
|
||
|
||
---
|
||
|
||
## 🚀 Starting Real-Time Inference
|
||
|
||
### Step 1: Select Model
|
||
Choose the model you want to run from the dropdown in the training panel.
|
||
|
||
### Step 2: Click "Start Live Inference"
|
||
- Button turns red: "Stop Inference"
|
||
- Live mode banner appears at top
|
||
- Charts begin updating every second
|
||
- Model predictions displayed
|
||
|
||
### Visual Indicators
|
||
- **🔴 LIVE banner** at top of page
|
||
- **Green status box** in training panel
|
||
- **Update counter** showing number of updates
|
||
- **Signal markers** on charts (🔵 BUY, 🔴 SELL)
|
||
|
||
---
|
||
|
||
## 📊 What Updates in Real-Time
|
||
|
||
### Charts (Every 1 Second)
|
||
- **All 4 timeframes** update with latest data
|
||
- **Candlesticks** show new price action
|
||
- **Volume bars** update with new volume
|
||
- **Smooth updates** without page refresh
|
||
|
||
### Model Signals
|
||
- **Latest prediction** displayed (BUY/SELL/HOLD)
|
||
- **Confidence level** shown as percentage
|
||
- **Signal markers** added to charts
|
||
- **Last 10 signals** kept visible
|
||
|
||
### Data Source
|
||
- Uses **DataProvider's cached data**
|
||
- Same data as main trading system
|
||
- Updates from exchange feeds
|
||
- 1-second resolution
|
||
|
||
---
|
||
|
||
## 🎨 Visual Elements
|
||
|
||
### Live Mode Banner
|
||
```
|
||
🔴 LIVE | Real-Time Inference Active
|
||
Charts updating with live data every second
|
||
[X updates]
|
||
```
|
||
|
||
### Signal Markers on Charts
|
||
- **🔵 BUY** - Green marker with arrow
|
||
- **🔴 SELL** - Red marker with arrow
|
||
- **Timestamp** - When signal was generated
|
||
- **Price** - Price at signal time
|
||
|
||
### Training Panel Status
|
||
```
|
||
🔴 LIVE
|
||
Signal: BUY
|
||
Confidence: 75.3%
|
||
Charts updating every 1s
|
||
```
|
||
|
||
---
|
||
|
||
## 🛑 Stopping Real-Time Inference
|
||
|
||
### Click "Stop Inference"
|
||
- Live mode banner disappears
|
||
- Charts stop updating
|
||
- Signal markers remain visible
|
||
- Can review final signals
|
||
|
||
### What Happens
|
||
- Inference loop terminates
|
||
- Chart updates stop
|
||
- Last 100 signals saved
|
||
- Model remains loaded
|
||
|
||
---
|
||
|
||
## 📈 Monitoring Performance
|
||
|
||
### Watch For
|
||
- **Signal frequency** - How often model signals
|
||
- **Confidence levels** - Higher is better (>70%)
|
||
- **Signal accuracy** - Do signals make sense?
|
||
- **False positives** - Signals that shouldn't happen
|
||
|
||
### Good Signs
|
||
- ✅ Signals at key levels (support/resistance)
|
||
- ✅ High confidence (>70%)
|
||
- ✅ Signals match your analysis
|
||
- ✅ Few false positives
|
||
|
||
### Warning Signs
|
||
- ⚠️ Too many signals (every second)
|
||
- ⚠️ Low confidence (<50%)
|
||
- ⚠️ Random signals
|
||
- ⚠️ Signals don't match patterns
|
||
|
||
---
|
||
|
||
## 🔧 Technical Details
|
||
|
||
### Update Frequency
|
||
- **Charts**: 1 second
|
||
- **Signals**: 1 second
|
||
- **Model inference**: 1 second
|
||
|
||
### Data Flow
|
||
```
|
||
DataProvider (Live Data)
|
||
↓
|
||
Latest Market State (4 timeframes)
|
||
↓
|
||
Model Inference
|
||
↓
|
||
Prediction (Action + Confidence)
|
||
↓
|
||
Update Charts + Display Signal
|
||
```
|
||
|
||
### Performance
|
||
- **Latency**: ~100-200ms per update
|
||
- **CPU Usage**: Moderate (model inference)
|
||
- **Memory**: Stable (no leaks)
|
||
- **Network**: Minimal (uses cached data)
|
||
|
||
---
|
||
|
||
## 💡 Tips & Tricks
|
||
|
||
### Tip 1: Watch Multiple Timeframes
|
||
All 4 charts update simultaneously. Watch for:
|
||
- Alignment across timeframes
|
||
- Divergences between timeframes
|
||
- Pattern confirmation
|
||
|
||
### Tip 2: Monitor Confidence
|
||
- **>80%**: Very strong signal
|
||
- **70-80%**: Strong signal
|
||
- **50-70%**: Moderate signal
|
||
- **<50%**: Weak signal (ignore)
|
||
|
||
### Tip 3: Compare with Annotations
|
||
- Do live signals match your annotations?
|
||
- Are signals at similar price levels?
|
||
- Is timing similar to your trades?
|
||
|
||
### Tip 4: Test Different Models
|
||
- Try CNN vs DQN vs Transformer
|
||
- Compare signal quality
|
||
- Note which performs best
|
||
|
||
### Tip 5: Use for Validation
|
||
- After training, test with live inference
|
||
- Verify model learned correctly
|
||
- Check for overfitting
|
||
|
||
---
|
||
|
||
## 🐛 Troubleshooting
|
||
|
||
### Charts Not Updating
|
||
**Issue**: Live mode active but charts frozen
|
||
|
||
**Solutions**:
|
||
- Check browser console for errors
|
||
- Verify DataProvider has live data
|
||
- Refresh page and restart inference
|
||
- Check network tab for failed requests
|
||
|
||
### No Signals Generated
|
||
**Issue**: Status shows "HOLD" constantly
|
||
|
||
**Solutions**:
|
||
- Model may need more training
|
||
- Check model is loaded correctly
|
||
- Verify market conditions (model may correctly hold)
|
||
- Try different model
|
||
|
||
### Signals Too Frequent
|
||
**Issue**: Signal every second
|
||
|
||
**Solutions**:
|
||
- Model may be overtrained
|
||
- Need more negative examples in training
|
||
- Adjust confidence threshold
|
||
- Retrain with better annotations
|
||
|
||
### Performance Issues
|
||
**Issue**: Browser slow/laggy
|
||
|
||
**Solutions**:
|
||
- Close other tabs
|
||
- Reduce number of visible timeframes
|
||
- Stop inference when not needed
|
||
- Clear browser cache
|
||
|
||
---
|
||
|
||
## 📊 Example Session
|
||
|
||
### Scenario: Testing CNN After Training
|
||
|
||
**1. Preparation**
|
||
- Trained CNN on 20 breakout annotations
|
||
- Model learned breakout patterns
|
||
- Ready to test on live data
|
||
|
||
**2. Start Inference**
|
||
- Select "StandardizedCNN"
|
||
- Click "Start Live Inference"
|
||
- 🔴 LIVE banner appears
|
||
- Charts begin updating
|
||
|
||
**3. Observation (5 minutes)**
|
||
- Charts update smoothly
|
||
- Model generates 2 BUY signals
|
||
- Both at resistance breakouts
|
||
- Confidence: 78% and 82%
|
||
|
||
**4. Validation**
|
||
- Signals match training patterns
|
||
- Timing is precise
|
||
- No false positives
|
||
- Model learned correctly ✅
|
||
|
||
**5. Stop Inference**
|
||
- Click "Stop Inference"
|
||
- Review signal history
|
||
- Model performs well
|
||
- Ready for production
|
||
|
||
---
|
||
|
||
## 🎯 Best Practices
|
||
|
||
### Before Starting
|
||
- ✅ Train model first
|
||
- ✅ Verify model loaded
|
||
- ✅ Check DataProvider has data
|
||
- ✅ Close unnecessary tabs
|
||
|
||
### During Inference
|
||
- ✅ Monitor all timeframes
|
||
- ✅ Note signal quality
|
||
- ✅ Check confidence levels
|
||
- ✅ Compare with your analysis
|
||
|
||
### After Stopping
|
||
- ✅ Review signal history
|
||
- ✅ Note performance
|
||
- ✅ Identify improvements
|
||
- ✅ Adjust training if needed
|
||
|
||
---
|
||
|
||
## 🚀 Summary
|
||
|
||
Real-time inference provides:
|
||
|
||
✅ **Live chart updates** (1/second)
|
||
✅ **Model predictions** in real-time
|
||
✅ **Signal markers** on charts
|
||
✅ **Confidence levels** displayed
|
||
✅ **Performance monitoring** built-in
|
||
|
||
Use it to:
|
||
- **Validate training** - Check model learned correctly
|
||
- **Test models** - Compare different models
|
||
- **Monitor performance** - Track signal quality
|
||
- **Debug issues** - Identify problems
|
||
|
||
**Result**: Confidence that your model works correctly before deploying to production! 🎯
|