fix display predictions only on the selected main chart

This commit is contained in:
Dobromir Popov
2025-12-10 01:18:34 +02:00
parent bf381a9649
commit e84eed2839
3 changed files with 51 additions and 28 deletions

View File

@@ -0,0 +1 @@
once there are 2 Low or 2 high Level 2 pivots AFTER the trend line prediction, we should make a trend line and do backpropagation to adjust our model predictions of trend

View File

@@ -2976,6 +2976,7 @@ class AnnotationDashboard:
'current_price': current_price,
'price_change': price_change,
'predicted_candle': predicted_candle, # This is what frontend needs!
'primary_timeframe': '1m', # The main timeframe the model is predicting for
'type': 'transformer_prediction'
}

View File

@@ -2863,18 +2863,39 @@ class ChartManager {
/**
* Update model predictions on charts
* Draws predictions ONLY on the primary timeframe (the one the model is predicting for)
* Other timeframes are just reference data for the model
*/
updatePredictions(predictions) {
if (!predictions) return;
try {
// Use the currently active timeframe from app state
// This ensures predictions appear on the chart the user is watching (e.g., '1s')
const timeframe = window.appState?.currentTimeframes?.[0] || '1m';
// CRITICAL: Only draw predictions on the PRIMARY timeframe
// The model uses other timeframes as reference, but predictions are for the primary timeframe only
const primaryTimeframe = predictions.transformer?.primary_timeframe ||
window.appState?.currentTimeframes?.[0] ||
'1m';
console.log(`[updatePredictions] Drawing predictions on primary timeframe: ${primaryTimeframe}`);
// Update only the primary timeframe
this._updatePredictionsForTimeframe(primaryTimeframe, predictions);
} catch (error) {
console.error('[updatePredictions] Error:', error);
}
}
/**
* Update predictions for a specific timeframe
* @private
*/
_updatePredictionsForTimeframe(timeframe, predictions) {
try {
const chart = this.charts[timeframe];
if (!chart) {
console.warn(`[updatePredictions] Chart not found for timeframe: ${timeframe}`);
console.debug(`[updatePredictions] Chart not found for timeframe: ${timeframe}`);
return;
}
@@ -2894,7 +2915,7 @@ class ChartManager {
// 1. Too soon since last update (throttle)
// 2. Predictions haven't actually changed
if (now - lastUpdate < this.predictionUpdateThrottle && predictionHash === this.lastPredictionHash) {
console.debug(`[updatePredictions] Skipping update (throttled or unchanged)`);
console.debug(`[updatePredictions] Skipping update for ${timeframe} (throttled or unchanged)`);
return;
}