Crypto vs. Stock Market Diversification Analyzer
Self-assess your portfolio allocation, expected returns, and perceived risk levels.
** VERY IMPORTANT - PLEASE READ **
- This tool is for educational and self-assessment purposes ONLY.
- The analysis is based entirely on **your manually entered data, return expectations, and subjective risk assessments.** It does NOT use live market data or perform quantitative risk analysis.
- Cryptocurrencies are generally considered higher risk than traditional stocks. Diversification does not guarantee profits or protect against all losses.
- This tool **DOES NOT provide investment advice.** Always consult with a qualified financial advisor before making investment decisions.
Overall Portfolio Allocation
$
$
Stock Market Investment Profile
%
Cryptocurrency Investment Profile
%
Portfolio Diversification Analysis (Based on Your Inputs)
Crypto Notes: ${iC.notes.replace(/\n/g, '
')}
Overall Portfolio Profile (Illustrative)
`;
pdfHtml += `
`;
pdfHtml += `Weighted Average Estimated Return: ${this.formatPercent(r.weightedAvgReturn).replace(' %','')}
`;
pdfHtml += `Overall Assessed Risk Profile: ${r.overallRiskProfile} (Score: ${r.weightedAvgRiskScore.toFixed(2)})
`;
pdfHtml += `General Qualitative Comparison
| Feature | Stock Market (General) | Cryptocurrency Market (General) |
|---|---|---|
| ${item.factor} | ${item.stocks} | ${item.crypto} |
Observations Based on Your Inputs
${observationsEl.innerHTML.replace(/
`;
}
pdfExportContainer.innerHTML = pdfHtml;
document.body.appendChild(pdfExportContainer);
try {
const canvas = await html2canvas(pdfExportContainer, { scale: 1.2, useCORS: true, logging: false, windowWidth: pdfExportContainer.scrollWidth, windowHeight: pdfExportContainer.scrollHeight });
document.body.removeChild(pdfExportContainer);
const imgData = canvas.toDataURL('image/png');
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = pdf.internal.pageSize.getHeight();
let imgFinalWidth = pdfWidth - 40;
let imgFinalHeight = (canvas.height * imgFinalWidth) / canvas.width;
let position = 20;
let heightProcessed = 0;
const pageMargin = 20;
const pageHeightAvailable = pdfHeight - 2 * pageMargin;
while(heightProcessed < canvas.height) {
let pageSegmentHeightOnCanvas = Math.min(canvas.height - heightProcessed, (pageHeightAvailable / imgFinalHeight) * canvas.height );
if (pageSegmentHeightOnCanvas <=0) break;
const segmentCanvas = document.createElement('canvas');
segmentCanvas.width = canvas.width; segmentCanvas.height = pageSegmentHeightOnCanvas;
const sctx = segmentCanvas.getContext('2d');
sctx.drawImage(canvas, 0, heightProcessed, canvas.width, pageSegmentHeightOnCanvas, 0, 0, canvas.width, pageSegmentHeightOnCanvas);
const segmentImgData = segmentCanvas.toDataURL('image/png');
if(heightProcessed > 0) pdf.addPage();
pdf.addImage(segmentImgData, 'PNG', pageMargin, pageMargin, imgFinalWidth, (segmentCanvas.height * imgFinalWidth) / segmentCanvas.width);
heightProcessed += pageSegmentHeightOnCanvas;
}
pdf.save('Crypto_vs_Stock_Diversification_Analysis.pdf');
} catch (error) {
console.error("Error generating PDF:", error);
alert("An error occurred while generating PDF.");
if (document.body.contains(pdfExportContainer)) document.body.removeChild(pdfExportContainer);
}
}
};
document.addEventListener('DOMContentLoaded', function() {
cvsApp.init();
});
