diff --git a/ANNOTATE/core/real_training_adapter.py b/ANNOTATE/core/real_training_adapter.py index 015464c..edaf649 100644 --- a/ANNOTATE/core/real_training_adapter.py +++ b/ANNOTATE/core/real_training_adapter.py @@ -2579,8 +2579,9 @@ class RealTrainingAdapter: for tf in ['1s', '1m', '1h', '1d']: # Get historical data (raw) # Force refresh for 1s/1m to ensure we have the very latest candle for prediction + # But set persist=False to avoid locking the database with high-frequency writes refresh = tf in ['1s', '1m'] - df = data_provider.get_historical_data(symbol, tf, limit=600, refresh=refresh) + df = data_provider.get_historical_data(symbol, tf, limit=600, refresh=refresh, persist=False) if df is not None and not df.empty: # Extract raw arrays opens = df['open'].values.astype(np.float32) diff --git a/ANNOTATE/web/static/js/chart_manager.js b/ANNOTATE/web/static/js/chart_manager.js index 68f1270..fdc4ad9 100644 --- a/ANNOTATE/web/static/js/chart_manager.js +++ b/ANNOTATE/web/static/js/chart_manager.js @@ -1902,10 +1902,11 @@ class ChartManager { // Add prediction traces (ghost candles) if (predictionTraces.length > 0) { - // Remove existing ghost traces first (heuristic: traces with name 'Ghost Prediction') + // Remove existing ghost traces safely + // We iterate backwards to avoid index shifting issues when deleting const currentTraces = plotElement.data.length; const indicesToRemove = []; - for (let i = 0; i < currentTraces; i++) { + for (let i = currentTraces - 1; i >= 0; i--) { if (plotElement.data[i].name === 'Ghost Prediction') { indicesToRemove.push(i); } diff --git a/ANNOTATE/web/templates/components/training_panel.html b/ANNOTATE/web/templates/components/training_panel.html index 25aac1b..dddcfa6 100644 --- a/ANNOTATE/web/templates/components/training_panel.html +++ b/ANNOTATE/web/templates/components/training_panel.html @@ -849,8 +849,8 @@ return; } - // Display last 5 predictions (most recent first) - const html = predictionHistory.slice(0, 5).map(pred => { + // Display last 15 predictions (most recent first) + const html = predictionHistory.slice(0, 15).map(pred => { // Safely parse timestamp let timeStr = '--:--:--'; try { @@ -868,12 +868,14 @@ pred.action === 'SELL' ? 'text-danger' : 'text-secondary'; const confidence = (pred.confidence * 100).toFixed(1); const price = (pred.predicted_price && !isNaN(pred.predicted_price)) ? pred.predicted_price.toFixed(2) : '--'; + const timeframe = pred.timeframe || '1m'; return `