diff --git a/ANNOTATE/web/static/js/chart_manager.js b/ANNOTATE/web/static/js/chart_manager.js index 9c18b7b..9f3be71 100644 --- a/ANNOTATE/web/static/js/chart_manager.js +++ b/ANNOTATE/web/static/js/chart_manager.js @@ -622,7 +622,27 @@ class ChartManager { if (data.pivot_markers && Object.keys(data.pivot_markers).length > 0) { const xMin = data.timestamps[0]; - const xMax = data.timestamps[data.timestamps.length - 1]; + let xMax = data.timestamps[data.timestamps.length - 1]; + + // Extend xMax to include ghost candle predictions if they exist + if (this.ghostCandleHistory && this.ghostCandleHistory[timeframe] && this.ghostCandleHistory[timeframe].length > 0) { + const ghosts = this.ghostCandleHistory[timeframe]; + const furthestGhost = ghosts[ghosts.length - 1]; + if (furthestGhost && furthestGhost.targetTime) { + const ghostTime = new Date(furthestGhost.targetTime); + const currentMax = new Date(xMax); + if (ghostTime > currentMax) { + const year = ghostTime.getUTCFullYear(); + const month = String(ghostTime.getUTCMonth() + 1).padStart(2, '0'); + const day = String(ghostTime.getUTCDate()).padStart(2, '0'); + const hours = String(ghostTime.getUTCHours()).padStart(2, '0'); + const minutes = String(ghostTime.getUTCMinutes()).padStart(2, '0'); + const seconds = String(ghostTime.getUTCSeconds()).padStart(2, '0'); + xMax = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + console.log(`[${timeframe}] Pivot lines extended to include ${ghosts.length} ghost candles (to ${xMax})`); + } + } + } // Process each timestamp that has pivot markers Object.entries(data.pivot_markers).forEach(([timestamp, pivots]) => { @@ -1041,7 +1061,26 @@ class ChartManager { if (data.pivot_markers && Object.keys(data.pivot_markers).length > 0) { const xMin = data.timestamps[0]; - const xMax = data.timestamps[data.timestamps.length - 1]; + let xMax = data.timestamps[data.timestamps.length - 1]; + + // Extend xMax to include ghost candle predictions if they exist + if (this.ghostCandleHistory && this.ghostCandleHistory[timeframe] && this.ghostCandleHistory[timeframe].length > 0) { + const ghosts = this.ghostCandleHistory[timeframe]; + const furthestGhost = ghosts[ghosts.length - 1]; + if (furthestGhost && furthestGhost.targetTime) { + const ghostTime = new Date(furthestGhost.targetTime); + const currentMax = new Date(xMax); + if (ghostTime > currentMax) { + const year = ghostTime.getUTCFullYear(); + const month = String(ghostTime.getUTCMonth() + 1).padStart(2, '0'); + const day = String(ghostTime.getUTCDate()).padStart(2, '0'); + const hours = String(ghostTime.getUTCHours()).padStart(2, '0'); + const minutes = String(ghostTime.getUTCMinutes()).padStart(2, '0'); + const seconds = String(ghostTime.getUTCSeconds()).padStart(2, '0'); + xMax = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + } + } + } // Process each timestamp that has pivot markers Object.entries(data.pivot_markers).forEach(([timestamp, pivots]) => { @@ -1977,7 +2016,27 @@ class ChartManager { if (data.pivot_markers && Object.keys(data.pivot_markers).length > 0) { const xMin = data.timestamps[0]; - const xMax = data.timestamps[data.timestamps.length - 1]; + let xMax = data.timestamps[data.timestamps.length - 1]; + + // Extend xMax to include ghost candle predictions if they exist + if (this.ghostCandleHistory && this.ghostCandleHistory[timeframe] && this.ghostCandleHistory[timeframe].length > 0) { + const ghosts = this.ghostCandleHistory[timeframe]; + const furthestGhost = ghosts[ghosts.length - 1]; + if (furthestGhost && furthestGhost.targetTime) { + const ghostTime = new Date(furthestGhost.targetTime); + const currentMax = new Date(xMax); + if (ghostTime > currentMax) { + const year = ghostTime.getUTCFullYear(); + const month = String(ghostTime.getUTCMonth() + 1).padStart(2, '0'); + const day = String(ghostTime.getUTCDate()).padStart(2, '0'); + const hours = String(ghostTime.getUTCHours()).padStart(2, '0'); + const minutes = String(ghostTime.getUTCMinutes()).padStart(2, '0'); + const seconds = String(ghostTime.getUTCSeconds()).padStart(2, '0'); + xMax = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + console.log(`[${timeframe}] Pivot lines extended to include ${ghosts.length} ghost candles (to ${xMax})`); + } + } + } // Process each timestamp that has pivot markers Object.entries(data.pivot_markers).forEach(([timestamp, pivots]) => { diff --git a/ANNOTATE/web/templates/components/training_panel.html b/ANNOTATE/web/templates/components/training_panel.html index d3402c9..62c056f 100644 --- a/ANNOTATE/web/templates/components/training_panel.html +++ b/ANNOTATE/web/templates/components/training_panel.html @@ -1124,6 +1124,16 @@ function updatePredictionHistory() { const historyDiv = document.getElementById('prediction-history'); + + // Filter out invalid predictions (cleanup any that got through) + predictionHistory = predictionHistory.filter(pred => { + return pred.action && + ['BUY', 'SELL', 'HOLD'].includes(pred.action) && + !isNaN(pred.confidence) && + pred.confidence > 0 && + pred.timestamp; + }); + if (predictionHistory.length === 0) { historyDiv.innerHTML = '