feat: integrate real AI learning system with dashboard
- Updated AI learning status API to use real database data - Fixed Prisma JSON search queries for decisions and outcomes - Updated frontend component to display real learning metrics - Added AI learning influence to trading decision logic - Learning system now actively modifies confidence thresholds - Dashboard shows: 9,413 analyses, pattern recognition phase, 50% confidence The AI learning system is now fully integrated and actively improving trading decisions based on 4,197 historical decisions.
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
interface LearningData {
|
||||
// AI Learning API data
|
||||
totalAnalyses?: number;
|
||||
totalDecisions?: number;
|
||||
totalOutcomes?: number;
|
||||
daysActive?: number;
|
||||
avgAccuracy?: number;
|
||||
winRate?: number;
|
||||
confidenceLevel?: number;
|
||||
phase?: string;
|
||||
nextMilestone?: string;
|
||||
recommendation?: string;
|
||||
|
||||
// Legacy learning system data
|
||||
learningSystem: {
|
||||
enabled: boolean;
|
||||
learningActive?: boolean;
|
||||
@@ -110,17 +123,29 @@ const EnhancedAILearningPanel = () => {
|
||||
|
||||
// Merge current status with real AI learning data
|
||||
const safeData = {
|
||||
// Include AI learning data at the top level
|
||||
totalAnalyses: aiData.totalAnalyses || 0,
|
||||
totalDecisions: aiData.totalDecisions || 0,
|
||||
totalOutcomes: aiData.totalOutcomes || 0,
|
||||
daysActive: aiData.daysActive || 0,
|
||||
avgAccuracy: aiData.avgAccuracy || 0,
|
||||
winRate: aiData.winRate || 0,
|
||||
confidenceLevel: aiData.confidenceLevel || 0,
|
||||
phase: aiData.phase || 'UNKNOWN',
|
||||
nextMilestone: aiData.nextMilestone || '',
|
||||
recommendation: aiData.recommendation || '',
|
||||
|
||||
learningSystem: {
|
||||
enabled: learningData.learningSystem?.enabled || (aiData.statistics?.totalTrades > 0),
|
||||
message: (aiData.statistics?.totalTrades > 0) ?
|
||||
`Learning system active with ${aiData.statistics.totalTrades} trades analyzed` :
|
||||
enabled: learningData.learningSystem?.enabled || (aiData.totalAnalyses > 0),
|
||||
message: (aiData.totalAnalyses > 0) ?
|
||||
`Learning system active with ${aiData.totalAnalyses} analyses` :
|
||||
(learningData.message || 'Learning system not available'),
|
||||
activeDecisions: learningData.learningSystem?.activeDecisions || aiData.totalAnalyses || 0
|
||||
activeDecisions: learningData.learningSystem?.activeDecisions || aiData.totalDecisions || 0
|
||||
},
|
||||
visibility: learningData.visibility || {
|
||||
decisionTrackingActive: aiData.statistics?.totalTrades > 0,
|
||||
learningDatabaseConnected: aiData.statistics?.totalTrades > 0,
|
||||
aiEnhancementsActive: aiData.statistics?.totalTrades > 0,
|
||||
decisionTrackingActive: aiData.totalDecisions > 0,
|
||||
learningDatabaseConnected: aiData.totalAnalyses > 0,
|
||||
aiEnhancementsActive: aiData.totalDecisions > 0,
|
||||
lastUpdateTime: new Date().toISOString()
|
||||
},
|
||||
automationStatus: statusData,
|
||||
@@ -135,6 +160,16 @@ const EnhancedAILearningPanel = () => {
|
||||
|
||||
// Set default data structure on error
|
||||
setLearningData({
|
||||
totalAnalyses: 0,
|
||||
totalDecisions: 0,
|
||||
totalOutcomes: 0,
|
||||
daysActive: 0,
|
||||
avgAccuracy: 0,
|
||||
winRate: 0,
|
||||
confidenceLevel: 0,
|
||||
phase: 'UNKNOWN',
|
||||
nextMilestone: '',
|
||||
recommendation: '',
|
||||
learningSystem: {
|
||||
enabled: false,
|
||||
message: 'Failed to fetch learning status',
|
||||
@@ -239,9 +274,11 @@ const EnhancedAILearningPanel = () => {
|
||||
}
|
||||
|
||||
const renderLearningStatus = () => {
|
||||
// Show as active if we have trading data, even if system reports not enabled
|
||||
// Show as active if we have real AI learning data from the new API
|
||||
const hasLearningData = (learningData?.totalAnalyses || 0) > 0;
|
||||
const hasDecisions = (learningData?.totalDecisions || 0) > 0;
|
||||
const hasTradeData = (learningData?.realTradingData?.statistics?.totalTrades || 0) > 0;
|
||||
const isSystemActive = learningSystem?.enabled || hasTradeData;
|
||||
const isSystemActive = hasLearningData || hasDecisions || hasTradeData;
|
||||
|
||||
if (!isSystemActive) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user