Compare commits
2 Commits
3afe9b93dd
...
35f09dfcd8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35f09dfcd8 | ||
|
|
f80f7f2973 |
@@ -55,21 +55,30 @@ export default function AutomationPageV2() {
|
|||||||
|
|
||||||
const fetchStatus = async () => {
|
const fetchStatus = async () => {
|
||||||
try {
|
try {
|
||||||
|
console.log('🔍 fetchStatus called at:', new Date().toISOString())
|
||||||
const response = await fetch('/api/automation/status')
|
const response = await fetch('/api/automation/status')
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
console.log('Status response:', data) // Debug log
|
console.log('📊 Status response:', data) // Debug log
|
||||||
|
|
||||||
if (response.ok && !data.error) {
|
if (response.ok && !data.error) {
|
||||||
// If no lastDecision exists, get real analysis data
|
// If no lastDecision exists, get real analysis data
|
||||||
if (!data.lastDecision) {
|
if (!data.lastDecision) {
|
||||||
|
console.log('📋 No lastDecision found, fetching analysis details...')
|
||||||
try {
|
try {
|
||||||
const analysisResponse = await fetch('/api/automation/analysis-details')
|
const analysisResponse = await fetch('/api/automation/analysis-details')
|
||||||
const analysisData = await analysisResponse.json()
|
const analysisData = await analysisResponse.json()
|
||||||
|
console.log('🧠 Analysis response:', { success: analysisData.success, hasAnalysis: !!analysisData.data?.analysis })
|
||||||
|
|
||||||
if (analysisData.success && analysisData.data.analysis) {
|
if (analysisData.success && analysisData.data.analysis) {
|
||||||
const analysis = analysisData.data.analysis
|
const analysis = analysisData.data.analysis
|
||||||
const recentTrade = analysisData.data.recentTrades?.[0]
|
const recentTrade = analysisData.data.recentTrades?.[0]
|
||||||
|
|
||||||
|
console.log('✅ Creating lastDecision from analysis:', {
|
||||||
|
decision: analysis.decision,
|
||||||
|
confidence: analysis.confidence,
|
||||||
|
hasRecentTrade: !!recentTrade
|
||||||
|
})
|
||||||
|
|
||||||
data.lastDecision = {
|
data.lastDecision = {
|
||||||
recommendation: analysis.decision || 'HOLD',
|
recommendation: analysis.decision || 'HOLD',
|
||||||
confidence: analysis.confidence || 84,
|
confidence: analysis.confidence || 84,
|
||||||
@@ -89,18 +98,21 @@ Based on comprehensive technical analysis across multiple timeframes:
|
|||||||
entryPrice: recentTrade.entryPrice || recentTrade.price,
|
entryPrice: recentTrade.entryPrice || recentTrade.price,
|
||||||
stopLoss: analysis.stopLoss?.price || 185.50,
|
stopLoss: analysis.stopLoss?.price || 185.50,
|
||||||
takeProfit: analysis.takeProfits?.tp1?.price || 193.00,
|
takeProfit: analysis.takeProfits?.tp1?.price || 193.00,
|
||||||
positionSize: recentTrade.amount || 15.2
|
positionSize: recentTrade.positionSize || recentTrade.amount || 15.2,
|
||||||
|
side: recentTrade.side || 'BUY',
|
||||||
|
amount: recentTrade.realTradingAmount || recentTrade.tradingAmount || recentTrade.actualInvestment
|
||||||
} : null,
|
} : null,
|
||||||
isRetrospective: false
|
isRetrospective: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (analysisError) {
|
} catch (analysisError) {
|
||||||
console.warn('Could not fetch analysis details:', analysisError)
|
console.warn('❌ Could not fetch analysis details:', analysisError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('🎯 Setting status with lastDecision:', !!data.lastDecision)
|
||||||
setStatus(data) // Status data is returned directly, not wrapped in 'success'
|
setStatus(data) // Status data is returned directly, not wrapped in 'success'
|
||||||
} else {
|
} else {
|
||||||
console.error('Status API error:', data.error || 'Unknown error')
|
console.error('❌ Status API error:', data.error || 'Unknown error')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch status:', error)
|
console.error('Failed to fetch status:', error)
|
||||||
@@ -990,7 +1002,7 @@ Based on comprehensive technical analysis across multiple timeframes:
|
|||||||
status?.lastDecision ? 'bg-green-400 animate-pulse shadow-green-400/50' : 'bg-gray-500'
|
status?.lastDecision ? 'bg-green-400 animate-pulse shadow-green-400/50' : 'bg-gray-500'
|
||||||
}`}></div>
|
}`}></div>
|
||||||
<span className="text-lg text-gray-300 font-medium">
|
<span className="text-lg text-gray-300 font-medium">
|
||||||
{status?.lastDecision ? '🟢 Analysis Active' : '⚪ Waiting for Analysis'}
|
{status ? (status.lastDecision ? '🟢 Analysis Active' : '⚪ Waiting for Analysis') : '⏳ Loading...'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1091,7 +1103,7 @@ Based on comprehensive technical analysis across multiple timeframes:
|
|||||||
<div className="bg-blue-900/20 rounded-xl p-4 border border-blue-500/30">
|
<div className="bg-blue-900/20 rounded-xl p-4 border border-blue-500/30">
|
||||||
<div className="text-blue-400 text-sm mb-1 font-medium">Entry Price</div>
|
<div className="text-blue-400 text-sm mb-1 font-medium">Entry Price</div>
|
||||||
<div className="text-white font-mono text-xl font-bold">
|
<div className="text-white font-mono text-xl font-bold">
|
||||||
${status.lastDecision.executionDetails.currentPrice?.toFixed(4)}
|
${status.lastDecision.executionDetails.entryPrice?.toFixed(4)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-green-900/20 rounded-xl p-4 border border-green-500/30">
|
<div className="bg-green-900/20 rounded-xl p-4 border border-green-500/30">
|
||||||
|
|||||||
Binary file not shown.
63
test-display-values.js
Normal file
63
test-display-values.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
// Test the specific values that should be displayed
|
||||||
|
const testDisplayValues = async () => {
|
||||||
|
try {
|
||||||
|
console.log('🔍 Testing display values for missing data fields...\n');
|
||||||
|
|
||||||
|
// Get the analysis data
|
||||||
|
const analysisResponse = await fetch('http://localhost:9001/api/automation/analysis-details');
|
||||||
|
const analysisData = await analysisResponse.json();
|
||||||
|
|
||||||
|
if (analysisData.success) {
|
||||||
|
const analysis = analysisData.data.analysis;
|
||||||
|
const recentTrade = analysisData.data.recentTrades?.[0];
|
||||||
|
|
||||||
|
console.log('📊 Analysis Data:');
|
||||||
|
console.log('- Decision:', analysis.decision);
|
||||||
|
console.log('- Confidence:', analysis.confidence + '%');
|
||||||
|
console.log('- Entry Price:', '$' + (analysis.entry?.price || 'N/A'));
|
||||||
|
console.log('- Stop Loss:', '$' + (analysis.stopLoss?.price || 'N/A'));
|
||||||
|
console.log('- Take Profit:', '$' + (analysis.takeProfits?.tp1?.price || 'N/A'));
|
||||||
|
|
||||||
|
console.log('\n💰 Recent Trade Data:');
|
||||||
|
if (recentTrade) {
|
||||||
|
console.log('- Entry Price:', '$' + (recentTrade.entryPrice || recentTrade.price || 'N/A'));
|
||||||
|
console.log('- Position Size:', '$' + (recentTrade.positionSize || recentTrade.amount || 'N/A'));
|
||||||
|
console.log('- Trading Amount:', '$' + (recentTrade.realTradingAmount || recentTrade.tradingAmount || 'N/A'));
|
||||||
|
console.log('- Side:', recentTrade.side || 'N/A');
|
||||||
|
console.log('- Leverage:', (recentTrade.leverage || 'N/A') + 'x');
|
||||||
|
console.log('- Status:', recentTrade.status || 'N/A');
|
||||||
|
} else {
|
||||||
|
console.log('No recent trade found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simulate the execution details object
|
||||||
|
console.log('\n🎯 Execution Details Object (as component would create):');
|
||||||
|
if (recentTrade) {
|
||||||
|
const executionDetails = {
|
||||||
|
leverage: recentTrade.leverage || 3,
|
||||||
|
entryPrice: recentTrade.entryPrice || recentTrade.price,
|
||||||
|
stopLoss: analysis.stopLoss?.price || 185.50,
|
||||||
|
takeProfit: analysis.takeProfits?.tp1?.price || 193.00,
|
||||||
|
positionSize: recentTrade.positionSize || recentTrade.amount || 15.2,
|
||||||
|
side: recentTrade.side || 'BUY',
|
||||||
|
amount: recentTrade.realTradingAmount || recentTrade.tradingAmount || recentTrade.actualInvestment
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('Execution Details:', JSON.stringify(executionDetails, null, 2));
|
||||||
|
|
||||||
|
console.log('\n📋 Display Values:');
|
||||||
|
console.log('- Entry Price Display:', '$' + (executionDetails.entryPrice?.toFixed(4) || 'N/A'));
|
||||||
|
console.log('- Position Size Display:', '$' + (executionDetails.amount || 'N/A'));
|
||||||
|
console.log('- Direction Display:', executionDetails.side || 'N/A');
|
||||||
|
console.log('- Leverage Display:', (executionDetails.leverage || 'N/A') + 'x');
|
||||||
|
console.log('- Stop Loss Display:', '$' + (executionDetails.stopLoss?.toFixed(4) || 'N/A'));
|
||||||
|
console.log('- Take Profit Display:', '$' + (executionDetails.takeProfit?.toFixed(4) || 'N/A'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Error testing display values:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
testDisplayValues();
|
||||||
Reference in New Issue
Block a user