Quantitative Multi-Factor Model Creator

Define Model Factors and Their Weights

Total Weight: 0%

Input Data for Each Asset

Factor Values:

Added Assets

No assets added yet.

Quantitative Multi-Factor Model Results

No results to display. Please define factors, add assets, and then click "Calculate Model".

No results calculated or no assets to display.

'; return; } let tableHTML = ``; displayFactors.forEach(f => tableHTML += ``); displayFactors.forEach(f => tableHTML += ``); tableHTML += ``; results.forEach(res => { tableHTML += ``; displayFactors.forEach(f => { const rawVal = res.factorValues[f.id]; tableHTML += ``; }); displayFactors.forEach(f => tableHTML += ``); tableHTML += ``; }); tableHTML += `
RankAsset Name${escapeHtml(f.name)} (Raw)${escapeHtml(f.name)} (Wgt. Score)Composite Score
${res.rank} ${escapeHtml(res.name)}${typeof rawVal === 'number' ? rawVal.toFixed(2) : rawVal}${res.weightedScores[f.id].toFixed(4)}${res.compositeScore.toFixed(4)}
`; resultsTableContainer.innerHTML = tableHTML; } downloadPdfButtonResults?.addEventListener('click', function () { const { jsPDF } = window.jspdf; const pdfOutputArea = document.getElementById('qmfPdfOutputArea'); if (!pdfOutputArea || assets.length === 0) { alert('No results to download or PDF area not found.'); return; } if (resultsTableContainer.querySelector('p')) { alert('Please calculate the model first before downloading PDF.'); return; } html2canvas(pdfOutputArea, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'landscape', unit: 'pt', format: 'a3' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const margin = 30; const contentWidth = pdfWidth - 2 * margin; const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; let imgWidth = contentWidth; let imgHeight = imgWidth / ratio; if (imgHeight > pdfHeight - 2*margin) { imgHeight = pdfHeight - 2*margin; imgWidth = imgHeight * ratio; } pdf.addImage(imgData, 'PNG', margin, margin, imgWidth, imgHeight); pdf.save('Quantitative_MultiFactor_Model.pdf'); }) .catch(err => { console.error("Error generating PDF:", err); alert("Error generating PDF. See console for details."); }); }); function escapeHtml(unsafe) { if (typeof unsafe !== 'string') return unsafe === undefined || unsafe === null ? '' : String(unsafe); return unsafe.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); } generateFactorInputsButton.click(); switchTab('factorsTab'); });
Scroll to Top