Carry Trade Profitability Calculator
API fetch failed or rate not found. Please provide the necessary current exchange rates for conversion:
Currency Fluctuation: Pair moved ${pipsMoved.toFixed(1)} pips. Each pip worth ${pipValueInAcctCcy.toFixed(2)} ${accountCcy}.
`; resultsContainer.style.display = 'block'; }); function displayValue(element, value, currency, isTotal = false) { const formattedValue = value.toFixed(2); element.textContent = `${formattedValue} ${currency}`; element.className = 'ctpc-value'; // Reset if (value >= 0) { element.classList.add('ctpc-profit'); } else { element.classList.add('ctpc-loss'); } if (isTotal) { // Extra class for total to apply background in CSS if needed if (value >= 0) totalPlEl.classList.add('ctpc-profit'); else totalPlEl.classList.add('ctpc-loss'); } } downloadPdfBtn.addEventListener('click', function() { if (resultsContainer.style.display === 'none') { alert("Please calculate profitability first."); return; } const pair = pairSelect.value; const accountCcy = accountCurrencySelect.value; const pdfContainer = document.createElement('div'); pdfContainer.style.padding = '20px'; pdfContainer.style.fontFamily = 'Arial, sans-serif'; pdfContainer.style.fontSize = '12px'; pdfContainer.innerHTML = `Carry Trade Profitability Report
Inputs:
Currency Pair: ${pair}
Base Currency (${pair.substring(0,3)}) Interest Rate: ${baseRateInput.value}% p.a.
Quote Currency (${pair.substring(4,7)}) Interest Rate: ${quoteRateInput.value}% p.a.
Trade Size: ${parseFloat(tradeSizeInput.value).toLocaleString()} units of ${pair.substring(0,3)}
Account Currency: ${accountCcy}
Entry Exchange Rate: ${entryRateInput.value}
Expected Exit Exchange Rate: ${exitRateInput.value}
Holding Period: ${holdingPeriodValueInput.value} ${holdingPeriodUnitSelect.value}
Conversion Rates Used (to ${accountCcy}):
${pair.substring(0,3)}/${accountCcy}: ${baseToAcctRateGroup.style.display !== 'none' && !isNaN(parseFloat(baseToAcctRateInput.value)) ? parseFloat(baseToAcctRateInput.value).toFixed(5) : (pair.substring(0,3) === accountCcy ? '1.00000 (N/A)' : 'Error/Not Set')}
${pair.substring(4,7)}/${accountCcy}: ${quoteToAcctRateGroup.style.display !== 'none' && !isNaN(parseFloat(quoteToAcctRateInput.value)) ? parseFloat(quoteToAcctRateInput.value).toFixed(5) : (pair.substring(4,7) === accountCcy ? '1.00000 (N/A)' : 'Error/Not Set')}
Profitability Breakdown (${accountCcy}):
Interest Rate Differential P/L: ${interestPlEl.textContent}
Exchange Rate Fluctuation P/L: ${exchangeRatePlEl.textContent}
Total Estimated P/L: ${totalPlEl.textContent}