diff --git a/app/safe-paper-trading/page.js b/app/safe-paper-trading/page.js index 04872f5..a62c076 100644 --- a/app/safe-paper-trading/page.js +++ b/app/safe-paper-trading/page.js @@ -219,30 +219,81 @@ export default function SafePaperTradingPage() { const fetchLearningStatus = async () => { try { - // Simulate fetching AI learning status - const mockLearningStatus = { - totalDecisions: Math.floor(Math.random() * 50) + 10, - recentDecisions: Math.floor(Math.random() * 10) + 2, - successRate: 0.65 + (Math.random() * 0.25), // 65-90% - currentThresholds: { - emergency: 0.5, - risk: 1.5, - confidence: 75 - }, - nextTradeAdjustments: [ - 'Increasing position size confidence for SOL/USD setups', - 'Tightening stop losses on 1h timeframe trades', - 'Looking for momentum exhaustion signals before entry' - ] - } + // Fetch real AI learning status from the learning system + console.log('🧠 Fetching real AI learning status...') - setLearningInsights(prev => ({ - ...prev, - status: mockLearningStatus - })) + // Get real learning status from the AI learning system + const response = await fetch('/api/ai-learning-status', { + method: 'GET', + headers: { 'Content-Type': 'application/json' } + }) + + if (response.ok) { + const result = await response.json() + const realLearningData = result.data + console.log('✅ Real learning status received:', realLearningData) + + setLearningInsights(prev => ({ + ...prev, + status: { + totalDecisions: realLearningData.totalDecisions || 0, + recentDecisions: realLearningData.totalOutcomes || 0, + successRate: (realLearningData.avgAccuracy || 0) / 100, + currentThresholds: { + emergency: 0.5, + risk: 1.5, + confidence: realLearningData.confidenceLevel || 75 + }, + nextTradeAdjustments: [ + realLearningData.recommendation || 'Learning system initializing...', + realLearningData.nextMilestone || 'Building pattern recognition', + `Phase: ${realLearningData.phase || 'INITIALIZATION'}` + ], + phase: realLearningData.phase, + winRate: realLearningData.winRate, + daysActive: realLearningData.daysActive + } + })) + } else { + // If learning API not available, create basic structure without mock data + console.log('⚠️ Learning API not available, using basic structure') + setLearningInsights(prev => ({ + ...prev, + status: { + totalDecisions: 0, + recentDecisions: 0, + successRate: 0, + currentThresholds: { + emergency: 0.5, + risk: 1.5, + confidence: 75 + }, + nextTradeAdjustments: [ + 'Learning system initializing...', + 'Building pattern recognition database', + 'Preparing adaptive decision making' + ] + } + })) + } } catch (error) { console.error('❌ Error fetching learning status:', error) + // Minimal structure without any mock data + setLearningInsights(prev => ({ + ...prev, + status: { + totalDecisions: 0, + recentDecisions: 0, + successRate: 0, + currentThresholds: { + emergency: 0.5, + risk: 1.5, + confidence: 75 + }, + nextTradeAdjustments: ['Learning system offline'] + } + })) } } @@ -276,7 +327,7 @@ export default function SafePaperTradingPage() {

🧠 AI learning through safe simulation

-

📊 Mock analysis for practice

+

📊 Real market analysis for practice

🎯 Perfect for confidence building

@@ -381,7 +432,7 @@ export default function SafePaperTradingPage() {
- ✅ Isolated mock analysis • No real APIs • Zero trading risk + ✅ Real market analysis • Paper trading only • Zero trading risk
@@ -498,7 +549,8 @@ export default function SafePaperTradingPage() {

Resistance Levels

- {currentAnalysis.resistance || `$${(currentAnalysis.entry?.price * 1.02 || 164).toFixed(2)}, $${(currentAnalysis.entry?.price * 1.05 || 168).toFixed(2)}`} + {currentAnalysis.keyLevels?.resistance?.join(', ') || + `$${(currentAnalysis.entry?.price * 1.02 || 164).toFixed(2)}, $${(currentAnalysis.entry?.price * 1.05 || 168).toFixed(2)}`}

@@ -506,7 +558,8 @@ export default function SafePaperTradingPage() {

Support Levels

- {currentAnalysis.support || `$${(currentAnalysis.entry?.price * 0.98 || 160).toFixed(2)}, $${(currentAnalysis.entry?.price * 0.95 || 156).toFixed(2)}`} + {currentAnalysis.keyLevels?.support?.join(', ') || + `$${(currentAnalysis.entry?.price * 0.98 || 160).toFixed(2)}, $${(currentAnalysis.entry?.price * 0.95 || 156).toFixed(2)}`}

@@ -522,9 +575,9 @@ export default function SafePaperTradingPage() { 🎯 Entry Point -

${currentAnalysis.entry?.price?.toFixed(2) || '159.20'}

+

${currentAnalysis.entry?.price?.toFixed(2) || 'N/A'}

- {currentAnalysis.entryReason || 'Rejection from 15 EMA + VWAP confluence near intraday supply'} + {currentAnalysis.entry?.reasoning || currentAnalysis.summary || 'Real market analysis entry point'}

@@ -534,9 +587,9 @@ export default function SafePaperTradingPage() { Stop Loss -

${currentAnalysis.stopLoss?.price?.toFixed(2) || '157.80'}

+

${currentAnalysis.stopLoss?.price?.toFixed(2) || 'N/A'}

- {currentAnalysis.stopReason || 'Above VWAP + failed breakout zone'} + {currentAnalysis.stopLoss?.reasoning || 'Real market analysis stop loss level'}

@@ -549,15 +602,17 @@ export default function SafePaperTradingPage() {
TP1: - ${currentAnalysis.takeProfits?.tp1?.price?.toFixed(2) || '160.50'} -
-
- TP2: - ${currentAnalysis.takeProfits?.tp2?.price?.toFixed(2) || '162.00'} + ${currentAnalysis.takeProfits?.tp1?.price?.toFixed(2) || 'N/A'}
+ {currentAnalysis.takeProfits?.tp2 && ( +
+ TP2: + ${currentAnalysis.takeProfits.tp2.price?.toFixed(2)} +
+ )}

- Immediate structure target with RSI/OBV expectations + {currentAnalysis.takeProfits?.reasoning || 'Real market analysis target levels'}

@@ -572,7 +627,7 @@ export default function SafePaperTradingPage() {
Risk/Reward Ratio - {currentAnalysis.riskRewardRatio || '1:3'} + {currentAnalysis.riskToReward || 'N/A'}
@@ -581,27 +636,27 @@ export default function SafePaperTradingPage() { Confirmation Trigger

- {currentAnalysis.confirmationTrigger || 'Specific signal: Bullish engulfing candle on rejection from VWAP zone with RSI above 50'} + {currentAnalysis.confirmationTrigger || 'Real market confirmation signals from analysis'}

- RSI: - RSI should reach 60-65 zone + Trend: + {currentAnalysis.trendAnalysis?.direction || 'Analyzing...'}
- OBV: - OBV confirming momentum + Momentum: + {currentAnalysis.momentumAnalysis?.status || 'Analyzing...'}
- Extended target: - If momentum continues + Volume: + {currentAnalysis.volumeAnalysis?.trend || 'Analyzing...'}
- Structure: - RSI approaching 70+ overbought + Timeframe Risk: + {currentAnalysis.timeframeRisk || 'Medium'}
@@ -729,10 +784,10 @@ export default function SafePaperTradingPage() {
Pattern Recognition:
-
• {symbol} {timeframe}m setups: {Math.floor(Math.random() * 8) + 3} previous analyses
-
• Success rate this timeframe: {(65 + Math.random() * 25).toFixed(1)}%
-
• Learned stop-loss distance: {(1.2 + Math.random() * 0.8).toFixed(1)}%
-
• Best entry signals: RSI + VWAP confluence
+
• {symbol} {timeframe}m setups: {learningInsights.status?.totalDecisions || 0} total decisions in database
+
• Success rate: {((learningInsights.status?.successRate || 0) * 100).toFixed(1)}%
+
• Learning phase: {learningInsights.status?.phase || 'INITIALIZATION'}
+
• Days active: {learningInsights.status?.daysActive || 0} days