wip
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 `
|
||||
<div class="d-flex justify-content-between align-items-center mb-1 pb-1 border-bottom">
|
||||
<div>
|
||||
<span class="badge bg-dark text-light me-1" style="font-size: 0.6rem;">${timeframe}</span>
|
||||
<span class="${actionColor} fw-bold">${pred.action}</span>
|
||||
<span class="text-muted ms-1">${timeStr}</span>
|
||||
<span class="text-muted ms-1" style="font-size: 0.75rem;">${timeStr}</span>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<div>${confidence}%</div>
|
||||
@@ -930,17 +932,23 @@
|
||||
timestamp = latest.timestamp;
|
||||
}
|
||||
|
||||
// Add to prediction history (keep last 5)
|
||||
predictionHistory.unshift({
|
||||
// Add to prediction history (keep last 15)
|
||||
const newPrediction = {
|
||||
timestamp: timestamp,
|
||||
action: latest.action,
|
||||
confidence: latest.confidence,
|
||||
predicted_price: latest.predicted_price
|
||||
});
|
||||
if (predictionHistory.length > 5) {
|
||||
predictionHistory = predictionHistory.slice(0, 5);
|
||||
predicted_price: latest.predicted_price,
|
||||
timeframe: appState.currentTimeframes ? appState.currentTimeframes[0] : '1m'
|
||||
};
|
||||
|
||||
// Filter out undefined/invalid predictions before adding
|
||||
if (latest.action && !isNaN(latest.confidence)) {
|
||||
predictionHistory.unshift(newPrediction);
|
||||
if (predictionHistory.length > 15) {
|
||||
predictionHistory = predictionHistory.slice(0, 15);
|
||||
}
|
||||
updatePredictionHistory();
|
||||
}
|
||||
updatePredictionHistory();
|
||||
|
||||
// Update chart with signal markers and predictions
|
||||
if (window.appState && window.appState.chartManager) {
|
||||
|
||||
Reference in New Issue
Block a user