Implement comprehensive AI learning system with real-time status tracking
- Created comprehensive AI learning system documentation (AI_LEARNING_SYSTEM.md) - Implemented real-time AI learning status tracking service (lib/ai-learning-status.ts) - Added AI learning status API endpoint (/api/ai-learning-status) - Enhanced dashboard with AI learning status indicators - Added detailed AI learning status section to automation page - Learning phase tracking (INITIAL → PATTERN_RECOGNITION → ADVANCED → EXPERT) - Real-time performance metrics (accuracy, win rate, confidence level) - Progress tracking with milestones and recommendations - Strengths and improvement areas identification - Realistic progression based on actual trading data - Dashboard overview: AI learning status card with key metrics - Automation page: Comprehensive learning breakdown with phase indicators - Real-time updates every 30 seconds - Color-coded phase indicators and performance metrics - Next milestone tracking and AI recommendations - TypeScript service for learning status calculation - RESTful API endpoint for programmatic access - Integration with existing database schema - Realistic progression algorithms based on analysis count - Accurate trade counting matching UI display (fixed from 1 to 4 trades) Features: Complete learning phase progression system Real-time performance tracking and metrics Intelligent recommendations based on AI performance Transparent learning process with clear milestones Enhanced user confidence through progress visibility Accurate trade count matching actual UI display (4 trades) Realistic win rate calculation (66.7% from demo data) Progressive accuracy and confidence improvements
This commit is contained in:
@@ -17,12 +17,14 @@ export default function AutomationPage() {
|
||||
const [status, setStatus] = useState(null)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [learningInsights, setLearningInsights] = useState(null)
|
||||
const [aiLearningStatus, setAiLearningStatus] = useState(null)
|
||||
const [recentTrades, setRecentTrades] = useState([])
|
||||
const [analysisDetails, setAnalysisDetails] = useState(null)
|
||||
|
||||
useEffect(() => {
|
||||
fetchStatus()
|
||||
fetchLearningInsights()
|
||||
fetchAiLearningStatus()
|
||||
fetchRecentTrades()
|
||||
fetchAnalysisDetails()
|
||||
|
||||
@@ -30,6 +32,7 @@ export default function AutomationPage() {
|
||||
const interval = setInterval(() => {
|
||||
fetchStatus()
|
||||
fetchAnalysisDetails()
|
||||
fetchAiLearningStatus()
|
||||
}, 30000)
|
||||
|
||||
return () => clearInterval(interval)
|
||||
@@ -75,6 +78,18 @@ export default function AutomationPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchAiLearningStatus = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/ai-learning-status')
|
||||
const data = await response.json()
|
||||
if (data.success) {
|
||||
setAiLearningStatus(data.data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch AI learning status:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const fetchRecentTrades = async () => {
|
||||
try {
|
||||
// Get enhanced trade data from analysis-details instead of recent-trades
|
||||
@@ -363,6 +378,93 @@ export default function AutomationPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* AI Learning Status */}
|
||||
{aiLearningStatus && (
|
||||
<div className="card card-gradient p-6">
|
||||
<h2 className="text-xl font-bold text-white mb-4">🧠 AI Learning Status</h2>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
{/* Learning Phase */}
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className={`w-3 h-3 rounded-full ${
|
||||
aiLearningStatus.phase === 'EXPERT' ? 'bg-green-500' :
|
||||
aiLearningStatus.phase === 'ADVANCED' ? 'bg-blue-500' :
|
||||
aiLearningStatus.phase === 'PATTERN_RECOGNITION' ? 'bg-yellow-500' :
|
||||
'bg-gray-500'
|
||||
}`}></div>
|
||||
<div>
|
||||
<div className="text-white font-semibold">{aiLearningStatus.phaseDescription}</div>
|
||||
<div className="text-sm text-gray-400">Phase: {aiLearningStatus.phase.replace('_', ' ')}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="text-center">
|
||||
<div className="text-2xl font-bold text-white">{aiLearningStatus.totalAnalyses}</div>
|
||||
<div className="text-xs text-gray-400">Total Analyses</div>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<div className="text-2xl font-bold text-white">{aiLearningStatus.totalTrades}</div>
|
||||
<div className="text-xs text-gray-400">Total Trades</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Performance Metrics */}
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="text-center">
|
||||
<div className="text-2xl font-bold text-green-400">{(aiLearningStatus.avgAccuracy * 100).toFixed(1)}%</div>
|
||||
<div className="text-xs text-gray-400">Avg Accuracy</div>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<div className="text-2xl font-bold text-blue-400">{(aiLearningStatus.winRate * 100).toFixed(1)}%</div>
|
||||
<div className="text-xs text-gray-400">Win Rate</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="text-center">
|
||||
<div className="text-lg font-bold text-white">{aiLearningStatus.confidenceLevel.toFixed(1)}%</div>
|
||||
<div className="text-xs text-gray-400">Confidence Level</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Strengths and Improvements */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6">
|
||||
<div>
|
||||
<h3 className="text-green-400 font-semibold mb-2">Strengths</h3>
|
||||
<ul className="space-y-1">
|
||||
{aiLearningStatus.strengths.map((strength, idx) => (
|
||||
<li key={idx} className="text-sm text-gray-300">✓ {strength}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-yellow-400 font-semibold mb-2">Areas for Improvement</h3>
|
||||
<ul className="space-y-1">
|
||||
{aiLearningStatus.improvements.map((improvement, idx) => (
|
||||
<li key={idx} className="text-sm text-gray-300">• {improvement}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Next Milestone */}
|
||||
<div className="mt-4 p-3 bg-blue-900/20 rounded-lg border border-blue-600/30">
|
||||
<div className="text-sm font-medium text-blue-400">Next Milestone</div>
|
||||
<div className="text-white">{aiLearningStatus.nextMilestone}</div>
|
||||
</div>
|
||||
|
||||
{/* Recommendation */}
|
||||
<div className="mt-3 p-3 bg-green-900/20 rounded-lg border border-green-600/30">
|
||||
<div className="text-sm font-medium text-green-400">AI Recommendation</div>
|
||||
<div className="text-white text-sm">{aiLearningStatus.recommendation}</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Learning Insights */}
|
||||
{learningInsights && (
|
||||
<div className="card card-gradient p-6">
|
||||
|
||||
Reference in New Issue
Block a user