AI-Based Foreign Exchange Rate Movement Prediction Model
Forecast currency movements based on key economic indicator differentials.
Prediction Inputs
Enter data for the currency pair you wish to analyze.
Base Currency (EUR)
Quote Currency (USD)
Prediction Signal
Forecast Visualization
Prediction Rationale
No Prediction Generated
Your forex forecast will appear here.
• Inflation Differential: Lower inflation is favorable. This factor contributed ${rationale.inflationImpact.toFixed(2)} points. High inflation in the base currency is a negative signal.
`; html += `• GDP Growth Differential: Stronger GDP growth in ${inputs.base.name} contributed ${rationale.gdpImpact.toFixed(2)} points. This indicates a robust economy, strengthening the currency.
`; html += `The combined model score of ${rationale.totalImpactScore.toFixed(2)} led to the final prediction.
`; rationaleOutput.innerHTML = html; } /** * Renders the chart comparing current and predicted rates. */ function renderChart(current, predicted) { if (forexChart) forexChart.destroy(); const ctx = chartCanvas.getContext('2d'); forexChart = new Chart(ctx, { type: 'line', data: { labels: ['Current Rate', 'Predicted Rate'], datasets: [{ label: 'Exchange Rate', data: [current, predicted], borderColor: '#3b82f6', // blue-500 backgroundColor: 'rgba(59, 130, 246, 0.1)', fill: false, tension: 0.1, pointRadius: 5, pointBackgroundColor: '#3b82f6', }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } }, scales: { y: { title: { display: true, text: 'Exchange Rate' }, ticks: { callback: value => value.toFixed(4) } } } } }); } /** * Exports the prediction results to a PDF. */ function exportToPDF() { if (!lastPredictionResult.signal) { alert("Please generate a prediction first."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); // Header doc.setFontSize(18); doc.setTextColor(40); doc.text("Foreign Exchange Rate Prediction Report", 14, 22); doc.setFontSize(11); doc.setTextColor(100); doc.text(`Pair: ${currencyPairEl.value} | Current Rate: ${currentRateEl.value}`, 14, 30); // Inputs Table const tableColumn = ["Indicator", `Base (${baseInterestEl.id.includes('base') ? currencyPairEl.value.split('/')[0] : currencyPairEl.value.split('/')[1]})`, `Quote (${quoteInterestEl.id.includes('quote') ? currencyPairEl.value.split('/')[1] : currencyPairEl.value.split('/')[0]})`]; const tableRows = [ ["Interest Rate (%)", baseInterestEl.value, quoteInterestEl.value], ["Inflation Rate (%)", baseInflationEl.value, quoteInflationEl.value], ["GDP Growth (%)", baseGdpEl.value, quoteGdpEl.value] ]; doc.autoTable({ head: [tableColumn], body: tableRows, startY: 40, theme: 'grid' }); let finalY = doc.lastAutoTable.finalY || 80; // Prediction doc.setFontSize(14); doc.text(`Prediction: ${lastPredictionResult.signal}`, 14, finalY + 15); doc.setFontSize(11); doc.text(`Forecasted Rate: ${lastPredictionResult.predictedRate.toFixed(4)} (${lastPredictionResult.predictedChangePercent.toFixed(2)}% Change)`, 14, finalY + 22); // Rationale doc.setFontSize(14); doc.text("Prediction Rationale", 14, finalY + 32); doc.setFontSize(10); const rationaleText = rationaleOutput.innerText.replace(/•/g, '\n-'); doc.text(rationaleText, 14, finalY + 39, { maxWidth: 180 }); // Chart if(forexChart) { const chartImage = forexChart.toBase64Image(); doc.addImage(chartImage, 'PNG', 14, doc.autoTable.previous.finalY + 100, 180, 80); } doc.save('Forex-Prediction-Report.pdf'); } /** * Updates currency labels based on dropdown selection. */ function updateCurrencyLabels() { const [base, quote] = currencyPairEl.value.split('/'); baseCurrencyLabel.textContent = `Base Currency (${base})`; quoteCurrencyLabel.textContent = `Quote Currency (${quote})`; } });