Central Bank Policy Divergence Analyzer

Central Bank Policy Divergence Analyzer

Analyze monetary policy shifts across major global economies.

Current Policy Rates (%)

Policy Summary

Note: Data and analysis are simulated for illustrative purposes and do not constitute financial advice. Policy rates and summaries are based on publicly available information but may not be real-time.

Last Meeting: ${bank1.lastMeeting} | Rate: ${bank1.currentRate.toFixed(2)}%

${bank1.summary}

${bank2.name} (${bank2.shortName})

Last Meeting: ${bank2.lastMeeting} | Rate: ${bank2.currentRate.toFixed(2)}%

${bank2.summary}

`; } loaderEl.style.display = 'none'; resultsEl.classList.remove('hidden'); }, 1000); }; // --- TAB 3: HISTORICAL VIEW --- function renderHistoricalChart() { const histCtx = document.getElementById('historical-chart')?.getContext('2d'); if (!histCtx) return; const fedHistory = centralBanksData['FED'].historicalRates; const datasets = []; const colors = ['#3b82f6', '#10b981', '#f97316', '#8b5cf6', '#ec4899']; let colorIndex = 0; for (const key in centralBanksData) { if (key === 'FED') continue; const bankHistory = centralBanksData[key].historicalRates; const spreadData = bankHistory.map((point, i) => { // Find corresponding Fed rate by date const fedPoint = fedHistory.find(fp => fp.t === point.t) || fedHistory[i]; // Fallback to index match return { t: new Date(point.t), y: (point.y - fedPoint.y).toFixed(2) }; }); datasets.push({ label: `${key}/Fed Spread`, data: spreadData, borderColor: colors[colorIndex % colors.length], backgroundColor: colors[colorIndex % colors.length] + '33', // with opacity tension: 0.1, fill: false, }); colorIndex++; } if (historicalChart) historicalChart.destroy(); historicalChart = new Chart(histCtx, { type: 'line', data: { datasets }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { type: 'time', time: { unit: 'year' }, title: { display: true, text: 'Date' } }, y: { title: { display: true, text: 'Interest Rate Spread (%)' } } } } }); } // --- PDF DOWNLOAD FUNCTIONALITY --- window.downloadPDF = async () => { const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'l', unit: 'mm', format: 'a4' }); const contentEl = document.getElementById(`tab-${currentTab}`); if (!contentEl) return; const downloadBtn = document.querySelector('button[onclick="downloadPDF()"]'); const originalText = downloadBtn.innerHTML; downloadBtn.innerHTML = `Generating...`; downloadBtn.disabled = true; try { const canvas = await html2canvas(contentEl, { scale: 2, useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; const imgWidth = pdfWidth - 20; // with margin const imgHeight = imgWidth / ratio; pdf.text(`Central Bank Policy Divergence Report: ${currentTab.charAt(0).toUpperCase() + currentTab.slice(1)}`, 10, 10); pdf.addImage(imgData, 'PNG', 10, 20, imgWidth, imgHeight); pdf.save(`Central-Bank-Analyzer-${currentTab}.pdf`); } catch (error) { console.error("PDF generation failed:", error); alert("An error occurred while generating the PDF."); } finally { downloadBtn.innerHTML = originalText; downloadBtn.disabled = false; if(window.lucide) window.lucide.createIcons(); } }; // --- KICK IT OFF --- init(); });
Scroll to Top