🔥 OBLITERATE ALL MOCK DATA - System now uses 100% real data sources

- DESTROYED: AI analysis fake 5-second responses → Real TradingView screenshots (30-180s)
- DESTROYED: Mock trading execution → Real Drift Protocol only
- DESTROYED: Fake price data (44.11) → Live CoinGecko API (78.60)
- DESTROYED: Mock balance/portfolio → Real Drift account data
- DESTROYED: Fake screenshot capture → Real enhanced-screenshot service
 Live trading only
- DESTROYED: Hardcoded market data → Real CoinGecko validation
- DESTROYED: Mock chart generation → Real TradingView automation

CRITICAL FIXES:
 AI analysis now takes proper time and analyzes real charts
 Bearish SOL (-0.74%) will now recommend SHORT positions correctly
 All trades execute on real Drift account
 Real-time price feeds from CoinGecko
 Actual technical analysis from live chart patterns
 Database reset with fresh AI learning (18k+ entries cleared)
 Trade confirmation system with ChatGPT integration

NO MORE FAKE DATA - TRADING SYSTEM IS NOW REAL!
This commit is contained in:
mindesbunister
2025-07-30 19:10:25 +02:00
parent d39ddaff40
commit ab6c4fd861
19 changed files with 1177 additions and 328 deletions

View File

@@ -1,6 +1,7 @@
'use client'
import React, { useState, useEffect } from 'react'
import EnhancedAILearningPanel from '../../components/EnhancedAILearningPanel'
import TradeConfirmationModal from '../../components/TradeConfirmationModal'
// Available timeframes for automation (matching analysis page format)
const timeframes = [
@@ -18,7 +19,7 @@ export default function AutomationPageV2() {
mode: 'LIVE',
dexProvider: 'DRIFT',
symbol: 'SOLUSD',
selectedTimeframes: ['60', '240'], // Default to improved scalping preset (1h, 4h)
selectedTimeframes: ['5', '15', '30'], // Default to scalping preset
tradingAmount: 100,
balancePercentage: 100, // Default to 100% of available balance
})
@@ -29,6 +30,10 @@ export default function AutomationPageV2() {
const [loading, setLoading] = useState(false)
const [monitorData, setMonitorData] = useState(null)
const [automationDisabled, setAutomationDisabled] = useState(false) // Track manual disable state
const [showConfirmation, setShowConfirmation] = useState(false)
const [pendingTrade, setPendingTrade] = useState(null)
const [currentAnalysis, setCurrentAnalysis] = useState(null) // Current market analysis
const [loadingAnalysis, setLoadingAnalysis] = useState(false) // Loading state for analysis
const [liveDecisions, setLiveDecisions] = useState([]) // Live trading decisions
const [actionFeedback, setActionFeedback] = useState(null) // Track button action feedback
@@ -38,6 +43,7 @@ export default function AutomationPageV2() {
fetchPositions()
fetchMonitorData()
fetchLiveDecisions()
fetchCurrentAnalysis() // Fetch technical analysis
const interval = setInterval(() => {
fetchStatus()
@@ -45,6 +51,7 @@ export default function AutomationPageV2() {
fetchPositions()
fetchMonitorData()
fetchLiveDecisions() // Fetch live decisions frequently
fetchCurrentAnalysis() // Update analysis regularly
}, 30000) // 30 seconds for live data
return () => clearInterval(interval)
}, [])
@@ -161,6 +168,26 @@ Based on comprehensive technical analysis across multiple timeframes:
}
}
const fetchCurrentAnalysis = async () => {
try {
setLoadingAnalysis(true)
const response = await fetch(`/api/ai-analysis/latest?symbol=${config.symbol}&timeframe=60`, {
cache: 'no-store'
})
if (response.ok) {
const data = await response.json()
if (data.success) {
setCurrentAnalysis(data.data)
console.log('📈 Analysis fetched for', data.data.symbol)
}
}
} catch (error) {
console.error('Error fetching analysis:', error)
} finally {
setLoadingAnalysis(false)
}
}
const fetchPositions = async () => {
try {
const response = await fetch('/api/drift/positions')
@@ -176,12 +203,9 @@ Based on comprehensive technical analysis across multiple timeframes:
const handleStart = async () => {
console.log('🚀 Starting automation...')
setLoading(true)
setActionFeedback({ type: 'info', message: 'Starting Money Printing Machine...' })
try {
if (config.selectedTimeframes.length === 0) {
console.error('No timeframes selected')
setActionFeedback({ type: 'error', message: 'Please select at least one timeframe' })
setLoading(false)
return
}
@@ -196,51 +220,25 @@ Based on comprehensive technical analysis across multiple timeframes:
takeProfit: config.takeProfit
}
console.log('📤 Sending config:', automationConfig)
// Set a longer timeout for the API call
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 30000) // 30 second timeout
const response = await fetch('/api/automation/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(automationConfig),
signal: controller.signal
body: JSON.stringify(automationConfig)
})
clearTimeout(timeoutId)
if (!response.ok) {
throw new Error(`API Error: ${response.status} ${response.statusText}`)
}
const data = await response.json()
if (data.success) {
console.log('✅ Automation started successfully:', data)
setActionFeedback({ type: 'success', message: '✅ Money Printing Machine ACTIVATED! System is now trading autonomously.' })
console.log('✅ Automation started successfully')
if (data.learningSystem?.integrated) {
console.log('🧠 AI Learning System: Activated')
}
// Refresh status after a short delay
setTimeout(() => {
fetchStatus()
fetchLiveDecisions()
}, 2000)
// Clear success message after 5 seconds
setTimeout(() => setActionFeedback(null), 5000)
fetchStatus()
} else {
console.error('Failed to start automation:', data.error)
setActionFeedback({ type: 'error', message: `Failed to start: ${data.error || 'Unknown error'}` })
}
} catch (error) {
console.error('Failed to start automation:', error)
if (error.name === 'AbortError') {
setActionFeedback({ type: 'error', message: 'Start request timed out. Please try again.' })
} else {
setActionFeedback({ type: 'error', message: `Error: ${error.message}` })
}
} finally {
setLoading(false)
}
@@ -328,6 +326,52 @@ Based on comprehensive technical analysis across multiple timeframes:
}
}
// Trade Confirmation Handlers
const handleTradeConfirmation = (recommendation) => {
setPendingTrade(recommendation)
setShowConfirmation(true)
}
const handleConfirmTrade = async (confirmationData) => {
console.log('✅ Trade confirmed, executing...')
try {
// Execute the actual trade here
const response = await fetch('/api/trading', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
symbol: config.symbol,
side: pendingTrade?.side || 'LONG',
amount: config.tradingAmount,
analysis: currentAnalysis,
confirmed: true
})
})
const data = await response.json()
if (data.success) {
console.log('✅ Trade executed successfully')
setActionFeedback({ type: 'success', message: '✅ Trade executed successfully' })
} else {
console.error('Trade execution failed:', data.error)
setActionFeedback({ type: 'error', message: '❌ Trade execution failed' })
}
} catch (error) {
console.error('Trade execution error:', error)
setActionFeedback({ type: 'error', message: '❌ Network error during trade execution' })
}
setPendingTrade(null)
setTimeout(() => setActionFeedback(null), 3000)
}
const handleAbortTrade = async (abortData, reason) => {
console.log('❌ Trade aborted:', reason)
setActionFeedback({ type: 'info', message: `❌ Trade aborted: ${reason}` })
setPendingTrade(null)
setTimeout(() => setActionFeedback(null), 3000)
}
const generateTestDecision = async () => {
console.log('🧪 Generating test AI decision...')
setLoading(true)
@@ -539,12 +583,12 @@ Based on comprehensive technical analysis across multiple timeframes:
{loading ? (
<div className="flex items-center space-x-2">
<div className="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"></div>
<span>Starting Money Printing Machine...</span>
<span>Starting...</span>
</div>
) : (
<div className="flex items-center space-x-2">
<span>{status?.rateLimitHit ? '🔄' : '🚀'}</span>
<span>{status?.rateLimitHit ? 'RESTART MPM' : 'START MONEY PRINTING MACHINE'}</span>
<span>{status?.rateLimitHit ? 'RESTART' : 'START'}</span>
</div>
)}
</button>
@@ -573,6 +617,19 @@ Based on comprehensive technical analysis across multiple timeframes:
<span>ANALYZE</span>
</div>
</button>
{/* Get Trade Signal Button */}
<button
onClick={() => currentAnalysis && handleTradeConfirmation({ symbol: config.symbol, timeframe: '60' })}
disabled={loading || !currentAnalysis}
className="px-6 py-4 bg-gradient-to-r from-yellow-600 to-orange-600 text-white rounded-xl hover:from-yellow-700 hover:to-orange-700 transition-all duration-200 disabled:opacity-50 font-semibold border-2 border-yellow-500/50 shadow-lg shadow-yellow-500/25 transform hover:scale-105"
title="Get Trade Signal - AI analyzes current market and provides trade recommendation with confirmation"
>
<div className="flex items-center space-x-2">
<span>🎯</span>
<span>GET SIGNAL</span>
</div>
</button>
</div>
</div>
@@ -801,35 +858,35 @@ Based on comprehensive technical analysis across multiple timeframes:
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<button
type="button"
onClick={() => setConfig({...config, selectedTimeframes: ['60', '240']})}
onClick={() => setConfig({...config, selectedTimeframes: ['5', '15', '30']})}
disabled={status?.isActive}
className="group p-6 rounded-xl bg-gradient-to-br from-green-600/20 to-emerald-600/10 border-2 border-green-600/30 hover:border-green-500/50 hover:from-green-600/30 hover:to-emerald-600/20 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed text-left hover:scale-105"
>
<div className="flex items-center justify-between mb-3">
<div className="text-3xl group-hover:scale-110 transition-transform duration-200"><EFBFBD></div>
<div className="text-xs text-green-400 bg-green-500/20 px-2 py-1 rounded-lg">SMART</div>
<div className="text-3xl group-hover:scale-110 transition-transform duration-200">📈</div>
<div className="text-xs text-green-400 bg-green-500/20 px-2 py-1 rounded-lg">FAST</div>
</div>
<h4 className="text-lg font-bold text-green-300 mb-2">Smart Scalping</h4>
<p className="text-sm text-gray-300 mb-3">High-probability scalping with trend filter</p>
<h4 className="text-lg font-bold text-green-300 mb-2">Scalping</h4>
<p className="text-sm text-gray-300 mb-3">Quick trades on short timeframes</p>
<div className="text-xs text-green-400/80 font-mono bg-green-900/30 px-2 py-1 rounded">
1h 4h
5m 15m 30m
</div>
</button>
<button
type="button"
onClick={() => setConfig({...config, selectedTimeframes: ['5', '15', '30']})}
onClick={() => setConfig({...config, selectedTimeframes: ['60', '120']})}
disabled={status?.isActive}
className="group p-6 rounded-xl bg-gradient-to-br from-blue-600/20 to-indigo-600/10 border-2 border-blue-600/30 hover:border-blue-500/50 hover:from-blue-600/30 hover:to-indigo-600/20 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed text-left hover:scale-105"
>
<div className="flex items-center justify-between mb-3">
<div className="text-3xl group-hover:scale-110 transition-transform duration-200"></div>
<div className="text-xs text-blue-400 bg-blue-500/20 px-2 py-1 rounded-lg">FAST</div>
<div className="text-xs text-blue-400 bg-blue-500/20 px-2 py-1 rounded-lg">MEDIUM</div>
</div>
<h4 className="text-lg font-bold text-blue-300 mb-2">Speed Scalping</h4>
<p className="text-sm text-gray-300 mb-3">Very fast trades (higher risk)</p>
<h4 className="text-lg font-bold text-blue-300 mb-2">Day Trading</h4>
<p className="text-sm text-gray-300 mb-3">Intraday momentum strategies</p>
<div className="text-xs text-blue-400/80 font-mono bg-blue-900/30 px-2 py-1 rounded">
5m 15m 30m
1h 2h
</div>
</button>
@@ -1208,8 +1265,62 @@ Based on comprehensive technical analysis across multiple timeframes:
</h4>
<div className="bg-gradient-to-br from-gray-900/80 to-purple-900/20 rounded-xl p-6 border-l-4 border-purple-500 shadow-inner">
<div className="text-gray-200 leading-relaxed whitespace-pre-line text-lg">
{liveDecisions[0]?.reasoning || 'No reasoning available'}
{loadingAnalysis ?
'Loading current market analysis...' :
(currentAnalysis?.analysis?.reasoning || liveDecisions[0]?.reasoning || 'No reasoning available')
}
</div>
{/* Add Technical Analysis Levels */}
{currentAnalysis && (
<div className="mt-6 pt-4 border-t border-purple-500/30">
<h5 className="text-purple-300 font-semibold mb-3">📈 Technical Analysis Levels ({currentAnalysis.timeframe}m timeframe)</h5>
<div className="grid grid-cols-2 gap-4 text-sm">
<div className="bg-green-900/20 p-3 rounded-lg border border-green-500/30">
<div className="text-green-300 font-medium">Support Levels</div>
<div className="text-green-200 mt-1">
{currentAnalysis.analysis.support?.map(level => `$${level}`).join(', ') || 'N/A'}
</div>
</div>
<div className="bg-red-900/20 p-3 rounded-lg border border-red-500/30">
<div className="text-red-300 font-medium">Resistance Levels</div>
<div className="text-red-200 mt-1">
{currentAnalysis.analysis.resistance?.map(level => `$${level}`).join(', ') || 'N/A'}
</div>
</div>
<div className="bg-blue-900/20 p-3 rounded-lg border border-blue-500/30">
<div className="text-blue-300 font-medium">Trend & Strength</div>
<div className="text-blue-200 mt-1">
{currentAnalysis.analysis.trend} ({Math.round((currentAnalysis.analysis.strength || 0) * 100)}%)
</div>
</div>
<div className="bg-yellow-900/20 p-3 rounded-lg border border-yellow-500/30">
<div className="text-yellow-300 font-medium">Analysis Confidence</div>
<div className="text-yellow-200 mt-1">
{currentAnalysis.analysis.confidence}% confidence
</div>
</div>
</div>
{/* Indicators */}
{currentAnalysis.analysis.indicators && (
<div className="mt-4 p-3 bg-gray-800/50 rounded-lg">
<div className="text-gray-300 font-medium mb-2">Key Indicators</div>
<div className="grid grid-cols-3 gap-3 text-xs">
{currentAnalysis.analysis.indicators.rsi && (
<div>RSI: <span className="text-cyan-300">{currentAnalysis.analysis.indicators.rsi}</span></div>
)}
{currentAnalysis.analysis.indicators.macd && (
<div>MACD: <span className="text-cyan-300">{currentAnalysis.analysis.indicators.macd}</span></div>
)}
{currentAnalysis.analysis.indicators.volume && (
<div>Volume: <span className="text-cyan-300">{currentAnalysis.analysis.indicators.volume}</span></div>
)}
</div>
</div>
)}
</div>
)}
</div>
</div>
@@ -1301,6 +1412,17 @@ Based on comprehensive technical analysis across multiple timeframes:
)}
</div>
</div>
{/* Trade Confirmation Modal */}
<TradeConfirmationModal
isOpen={showConfirmation}
onClose={() => setShowConfirmation(false)}
analysis={currentAnalysis?.analysis}
symbol={config.symbol}
timeframe={currentAnalysis?.timeframe || '60'}
onConfirm={handleConfirmTrade}
onAbort={handleAbortTrade}
/>
</div>
)
}