Portfolio & Factor Inputs

Factor Betas and Premiums

Factor Exposure Analysis Results

Summary of Analysis

Portfolio Return (%): 0.00%
Risk-Free Rate (%): 0.00%
Market Return (%): 0.00%
Expected Portfolio Return (CAPM) (%): 0.00%
Total Factor Contribution to Return (%): 0.00%
Alpha (Portfolio Return - Total Factor Return) (%): 0.00%

Individual Factor Contributions

Chart will appear here after calculation.

Portfolio Return: ${formatPercentage(parseFloat(portfolioReturnInput.value) || 0)}

Risk-Free Rate: ${formatPercentage(parseFloat(riskFreeRateInput.value) || 0)}

Market Return: ${formatPercentage(parseFloat(marketReturnInput.value) || 0)}

Factor Betas and Premiums:

${factorsTableRows}
Factor Name Beta Premium (%)

Calculated Analysis Results

Portfolio Return: ${formatPercentage(calculatedMetrics.portfolioReturn)}
Risk-Free Rate: ${formatPercentage(calculatedMetrics.riskFreeRate)}
Market Return: ${formatPercentage(calculatedMetrics.marketReturn)}
Expected Portfolio Return (CAPM): ${formatPercentage(calculatedMetrics.expectedReturnCAPM)}
Total Factor Contribution to Return: ${formatPercentage(calculatedMetrics.totalFactorContribution)}
Alpha (Portfolio Return - Total Factor Return): ${formatPercentage(calculatedMetrics.alpha)}

Individual Factor Contributions

${individualContributionsHtml}
`; return content; } function downloadPdf() { // Need to ensure calculations have been run if (Object.keys(calculatedMetrics).length === 0) { errorMessageDiv.textContent = "Please analyze exposure first before downloading the PDF."; errorMessageDiv.style.display = 'block'; return; } const printWindow = window.open('', '_blank'); if (!printWindow) { alert("Please allow pop-ups for PDF download."); return; } printWindow.document.write('Factor Exposure Report'); printWindow.document.write(''); printWindow.document.write(''); printWindow.document.write(generatePdfContent()); printWindow.document.write(''); printWindow.document.close(); printWindow.print(); printWindow.close(); } // --- Event Listeners --- tab1Button.addEventListener('click', () => activateTab('tab1Content')); tab2Button.addEventListener('click', () => activateTab('tab2Content')); calculateButton.addEventListener('click', analyzeExposure); resetButton.addEventListener('click', resetCalculator); pdfDownloadButton.addEventListener('click', downloadPdf); addFactorButton.addEventListener('click', addFactorInputRow); // Event delegation for dynamically added remove buttons factorInputsContainer.addEventListener('click', function(event) { if (event.target.classList.contains('remove-factor-button')) { if (currentFactorCount > 1) { // Ensure at least one factor remains event.target.closest('.factor-input-row').remove(); currentFactorCount--; } } }); prevTabButton.addEventListener('click', function() { const currentTab = document.querySelector('.factor-tab-content.active'); const tabs = [tab1Content, tab2Content]; const currentIndex = tabs.indexOf(currentTab); if (currentIndex > 0) { activateTab(tabs[currentIndex - 1].id); } }); nextTabButton.addEventListener('click', function() { const currentTab = document.querySelector('.factor-tab-content.active'); const tabs = [tab1Content, tab2Content]; const currentIndex = tabs.indexOf(currentTab); if (currentIndex < tabs.length - 1) { // If on input tab and trying to go to results, calculate first if (currentTab.id === 'tab1Content') { analyzeExposure(); // Attempt calculation // If calculation fails, do not proceed to tab 2 if (errorMessageDiv.style.display === 'block') { return; } } activateTab(tabs[currentIndex + 1].id); } }); // Initial setup resetCalculator(); // Call reset to set up default inputs and initial state updateNavigationButtons(); });
Scroll to Top