STATUS
${simulation.state.running ? 'ACTIVE' : 'IDLE'}
[${new Date().toLocaleTimeString()}] ${message}
${profitText}
`; logContainer.appendChild(entry); logContainer.scrollTop = logContainer.scrollHeight; } function initChart() { const ctx = document.getElementById('price-chart').getContext('2d'); if (priceChart) priceChart.destroy(); priceChart = new Chart(ctx, { type: 'line', data: { datasets: Object.entries(marketData).map(([label, data]) => ({ label, data: [{x: new Date(), y: data.price}], borderColor: data.color, tension: 0.1, pointRadius: 0 })) }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { type: 'timeseries', time: { unit: 'second' }, ticks: { color: '#9ca3af' } }, y: { ticks: { callback: v => `$${v.toFixed(2)}`, color: '#9ca3af' } } } } }); } // --- PDF GENERATION --- async function generatePdfReport() { if (simulation.state.running) stopSimulation(); downloadPdfBtn.disabled = true; downloadPdfBtn.textContent = 'Generating...'; const { opportunities, totalProfit, tradeCount } = simulation.state; const tableRows = opportunities.map(o => `Arbitrage Scan Report
ASSET: ${document.getElementById('asset-ticker').value} | DATE: ${new Date().toLocaleDateString()}
OPPORTUNITIES FOUND
${tradeCount}
TOTAL SIMULATED PROFIT
$${totalProfit.toFixed(2)}
AVG PROFIT / TRADE
$${(totalProfit / tradeCount || 0).toFixed(2)}
Trade Execution Log
| Time | Route | Buy Price | Sell Price | Profit (100 shares) |
|---|
