const fs = require('fs'); console.log('🔧 Merging position sections (attempt 2)...'); let content = fs.readFileSync('/app/app/automation-v2/page.js', 'utf8'); // First, remove the separate "Open Positions" section completely const openPosStart = content.indexOf(' {/* Positions */}'); const openPosEnd = content.indexOf(' )}', openPosStart + 50) + 12; // Get the closing if (openPosStart > -1 && openPosEnd > openPosStart) { const before = content.slice(0, openPosStart); const after = content.slice(openPosEnd); content = before + after; console.log('✅ Removed separate Open Positions section'); } else { console.log('❌ Could not find Open Positions section to remove'); } // Now find and replace the Position Monitor section const monitorStart = content.indexOf(' {/* Position Monitor */}'); if (monitorStart > -1) { const monitorEnd = content.indexOf(' )}', monitorStart + 50) + 12; if (monitorEnd > monitorStart) { const newSection = ` {/* Merged Position Status & Monitor */}

📊 Position Status & Monitor

{/* Monitor Status Section */} {monitorData && (

📈 Monitor Overview

Has Position: {monitorData.hasPosition ? '✅ YES' : '❌ NO'}
Risk Level: {monitorData.riskLevel}
Next Action: {monitorData.nextAction}
{monitorData.orphanedOrderCleanup && (
{monitorData.orphanedOrderCleanup.success ? '✅ Cleanup Success' : '❌ Cleanup Failed'}
{monitorData.orphanedOrderCleanup.message}
)}
)} {/* Open Positions Section */} {positions.length > 0 ? (

📈 Active Positions ({positions.length})

{positions.map((position, index) => (
{position.symbol} {position.side}
Size: \${position.size}
{position.entryPrice && (
Entry: \${position.entryPrice}
)} {position.markPrice && (
Mark: \${position.markPrice}
)} {position.pnl !== undefined && (
PnL: = 0 ? 'text-green-400' : 'text-red-400' }\`}> \${position.pnl >= 0 ? '+' : ''}\${position.pnl}
)}
))}
) : (
📊

No Active Positions

Start automation to begin trading

)}
`; content = content.slice(0, monitorStart) + newSection + content.slice(monitorEnd); console.log('✅ Updated Position Monitor with merged content'); } else { console.log('❌ Could not find Position Monitor end'); } } else { console.log('❌ Could not find Position Monitor section'); } fs.writeFileSync('/app/app/automation-v2/page.js', content); console.log('🎉 Positions merged successfully!');