Files
trading_bot_v3/show-learning-proof.js
mindesbunister f263cac55f Fix: Correct all database model names from camelCase to snake_case
- Fixed ai-analytics API: Created missing endpoint and corrected model names
- Fixed ai-learning-status.ts: Updated to use ai_learning_data and trades models
- Fixed batch-analysis route: Corrected ai_learning_data model references
- Fixed analysis-details route: Updated automation_sessions and trades models
- Fixed test scripts: Updated model names in check-learning-data.js and others
- Disabled conflicting route files to prevent Next.js confusion

All APIs now use correct snake_case model names matching Prisma schema:
- ai_learning_data (not aILearningData)
- automation_sessions (not automationSession)
- trades (not trade)

This resolves 'Unable to load REAL AI analytics' frontend errors.
2025-07-26 10:53:56 +02:00

121 lines
4.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function showDetailedLearningData() {
try {
console.log('🔍 Detailed AI Learning Data Analysis...\n');
const learningData = await prisma.ai_learning_data.findMany({
orderBy: { createdAt: 'desc' },
take: 3
});
console.log(`📊 Analyzing ${learningData.length} most recent learning records:\n`);
learningData.forEach((record, i) => {
console.log(`\n🧠 LEARNING RECORD #${i + 1}`);
console.log('═'.repeat(50));
console.log(`📅 Date: ${record.createdAt}`);
console.log(`👤 User: ${record.userId}`);
console.log(`⏰ Timeframe: ${record.timeframe}`);
console.log(`🎯 Recommendation: ${record.recommendation || 'PENDING'}`);
console.log(`📊 Confidence: ${record.confidence || 'CALCULATING'}%`);
console.log(`🎯 Accuracy Score: ${record.accuracyScore || 'NOT YET MEASURED'}`);
if (record.analysisData) {
try {
const analysis = JSON.parse(record.analysisData);
console.log('\n📈 TECHNICAL ANALYSIS:');
console.log(`📝 Reasoning: ${analysis.reasoning || 'Multi-timeframe analysis'}`);
if (analysis.multiTimeframeResults) {
console.log('\n⏱ MULTI-TIMEFRAME BREAKDOWN:');
analysis.multiTimeframeResults.forEach((tf, idx) => {
console.log(` ${idx + 1}. ${tf.timeframe}: ${tf.analysis?.recommendation || 'ANALYZING'} (${tf.analysis?.confidence || 0}% confidence)`);
});
}
if (analysis.confidence) {
console.log(`\n🎯 Final Combined Confidence: ${analysis.confidence}%`);
}
if (analysis.marketSentiment) {
console.log(`📊 Market Sentiment: ${analysis.marketSentiment}`);
}
} catch (e) {
console.log('📝 Analysis: [Complex multi-timeframe data - parsing limited]');
}
}
if (record.marketConditions) {
try {
const conditions = JSON.parse(record.marketConditions);
console.log('\n🌍 MARKET CONDITIONS:');
console.log(`📊 Symbol: ${conditions.symbol || 'UNKNOWN'}`);
console.log(`⏰ Timestamp: ${conditions.timestamp}`);
console.log(`🔗 Session: ${conditions.session}`);
} catch (e) {
console.log('🌍 Market Conditions: [Data available]');
}
}
console.log('\n' + '─'.repeat(50));
});
// Show learning progression
const totalAnalyses = await prisma.aILearningData.count();
const accurateAnalyses = await prisma.aILearningData.count({
where: {
accuracyScore: { gt: 0.6 }
}
});
console.log(`\n📊 LEARNING PROGRESSION SUMMARY:`);
console.log('═'.repeat(50));
console.log(`📈 Total Analyses: ${totalAnalyses}`);
console.log(`✅ Accurate Predictions: ${accurateAnalyses}`);
console.log(`🎯 Accuracy Rate: ${totalAnalyses > 0 ? ((accurateAnalyses / totalAnalyses) * 100).toFixed(1) : 0}%`);
// Determine learning phase
let phase = 'INITIAL';
let phaseDescription = 'Learning market basics';
if (totalAnalyses >= 100) {
phase = 'EXPERT';
phaseDescription = 'Advanced pattern recognition and risk management';
} else if (totalAnalyses >= 50) {
phase = 'ADVANCED';
phaseDescription = 'Developing sophisticated trading strategies';
} else if (totalAnalyses >= 20) {
phase = 'PATTERN_RECOGNITION';
phaseDescription = 'Learning to identify market patterns';
}
console.log(`🧠 Current Learning Phase: ${phase}`);
console.log(`📝 Phase Description: ${phaseDescription}`);
// Show recent automation activity
const recentSessions = await prisma.automationSession.findMany({
orderBy: { createdAt: 'desc' },
take: 1
});
if (recentSessions.length > 0) {
const session = recentSessions[0];
console.log(`\n🤖 CURRENT AUTOMATION STATUS:`);
console.log('═'.repeat(50));
console.log(`📊 Status: ${session.status}`);
console.log(`⚙️ Mode: ${session.mode}`);
console.log(`📅 Started: ${session.createdAt}`);
console.log(`📈 Trades Count: ${session.tradesCount || 0}`);
}
await prisma.$disconnect();
} catch (error) {
console.error('❌ Error:', error);
}
}
showDetailedLearningData();