Crypto Market Liquidity Risk Assessment

Crypto Market Liquidity Risk Assessment

$

$

$

$

$

$

$

Enter the number of listings on well-known, high-volume exchanges.

Summary of Inputs

Detailed Liquidity Analysis

Overall Liquidity Risk Assessment

Indicates trading activity relative to the asset's total value. Higher is generally better.

`; weightedScoreSum += getNumericScore(riskText) * weights.volumeToMarketCap; totalWeight += weights.volumeToMarketCap; } else { analysisHTML += `

Volume / Market Cap Ratio: N/A (Market Cap is zero or invalid)

`; } // 2. Bid-Ask Spread Percentage if (askPrice > 0 && askPrice > bidPrice) { const bidAskSpreadPerc = ((askPrice - bidPrice) / askPrice) * 100; const { riskClass, riskText } = getRiskClassAndText('bidAskSpread', bidAskSpreadPerc); analysisHTML += `

Bid-Ask Spread: ${formatNumber(bidAskSpreadPerc, 3)}%

Assessment: ${riskText}

Represents the cost to trade. Tighter spreads (lower percentage) are better.

`; weightedScoreSum += getNumericScore(riskText) * weights.bidAskSpread; totalWeight += weights.bidAskSpread; } else { analysisHTML += `

Bid-Ask Spread: N/A (Ask Price is zero, or Bid Price is not less than Ask Price)

`; } // 3. Market Depth (Buy Side) const depthBuyAssessment = getRiskClassAndText('marketDepth', depthBuy); analysisHTML += `

Buy-Side Depth (within 2%): $${formatNumber(depthBuy)}

Assessment: ${depthBuyAssessment.riskText}

The amount of buy orders near the current price. Higher indicates more support to absorb selling pressure.

`; weightedScoreSum += getNumericScore(depthBuyAssessment.riskText) * weights.marketDepthBuy; totalWeight += weights.marketDepthBuy; // 4. Market Depth (Sell Side) const depthSellAssessment = getRiskClassAndText('marketDepth', depthSell); analysisHTML += `

Sell-Side Depth (within 2%): $${formatNumber(depthSell)}

Assessment: ${depthSellAssessment.riskText}

The amount of sell orders near the current price. Higher indicates more supply to absorb buying pressure.

`; weightedScoreSum += getNumericScore(depthSellAssessment.riskText) * weights.marketDepthSell; totalWeight += weights.marketDepthSell; // 5. Exchange Listings if (exchangeListings !== null && !isNaN(exchangeListings)){ const exchangeAssessment = getRiskClassAndText('exchangeListings', exchangeListings); analysisHTML += `

Reputable Exchange Listings: ${exchangeListings}

Assessment: ${exchangeAssessment.riskText}

Number of listings on major exchanges. More reputable listings improve accessibility and perceived legitimacy.

`; weightedScoreSum += getNumericScore(exchangeAssessment.riskText) * weights.exchangeListings; totalWeight += weights.exchangeListings; } else { analysisHTML += `

Reputable Exchange Listings: N/A

`; } detailedAnalysis.innerHTML = analysisHTML; // ---- Overall Assessment ---- let overallRiskText = 'Not Enough Data'; let overallRiskClass = 'text-gray-600'; if (totalWeight > 0) { const averageScore = weightedScoreSum / totalWeight; if (averageScore <= 1.75) { // Adjusted thresholds based on 1-5 scale overallRiskText = 'Overall Low Liquidity Risk'; overallRiskClass = 'risk-low'; } else if (averageScore <= 2.5) { overallRiskText = 'Overall Low-Medium Liquidity Risk'; overallRiskClass = 'risk-medium-low'; } else if (averageScore <= 3.5) { overallRiskText = 'Overall Medium Liquidity Risk'; overallRiskClass = 'risk-medium'; } else if (averageScore <= 4.25) { overallRiskText = 'Overall Medium-High Liquidity Risk'; overallRiskClass = 'risk-medium-high'; } else { overallRiskText = 'Overall High Liquidity Risk'; overallRiskClass = 'risk-high'; } } overallAssessment.innerHTML = `

${overallRiskText}

`; if(totalWeight > 0 && totalWeight < (weights.volumeToMarketCap + weights.bidAskSpread + weights.marketDepthBuy + weights.marketDepthSell + weights.exchangeListings) * 0.99) { // check if some data was missing overallAssessment.innerHTML += `

(Note: Some data points were unavailable, which may affect the overall assessment accuracy.)

`; } // Enable report tab and next button, then switch to it reportTabButton.disabled = false; updateNavigationButtons(); // This will enable the 'Next' button if it was disabled return true; // Indicate successful processing } function validateAndProcess() { if (validateInputs()) { if(calculateLiquidityRisk()){ return true; } else { // This case might not be hit if calculateLiquidityRisk always returns true or errors out // but as a safeguard: reportTabButton.disabled = true; updateNavigationButtons(); return false; } } else { reportTabButton.disabled = true; // Keep report tab disabled if validation fails updateNavigationButtons(); // Ensure 'Next' button reflects this state return false; } } // Event listener for the "Assess Liquidity Risk" button if (assessButton) { assessButton.addEventListener('click', () => { if(validateAndProcess()){ // Automatically navigate to the report tab if validation and processing are successful showTab('reportTab', reportTabButton); // Use reportTabButton as the clicked button for styling } }); } // Event listener for PDF download if (downloadPdfButton) { downloadPdfButton.addEventListener('click', () => { // Corrected from ()_ const { jsPDF } = window.jspdf; const reportContent = document.getElementById('pdfReportContent'); if (!reportContent) { console.error("PDF report content area not found."); // Optionally, show a user-facing error message here // alert("Could not generate PDF: Report content missing."); // Avoid alert() const overallAssessmentEl = document.getElementById('overallAssessment'); if(overallAssessmentEl) { const p = document.createElement('p'); p.textContent = "Error: Could not generate PDF: Report content missing."; p.className = "error-message text-center"; overallAssessmentEl.appendChild(p); setTimeout(() => p.remove(), 5000); } return; } // Temporarily ensure all text is dark for PDF generation const originalColors = []; reportContent.querySelectorAll('*').forEach(el => { originalColors.push({el, color: el.style.color}); // el.style.color = '#000000'; // Force black for better PDF readability - Handled by CSS }); html2canvas(reportContent, { scale: 2, // Increase scale for better quality useCORS: true, // If you have any external images (though not in this example) onclone: (document) => { // This onclone function is crucial for applying PDF-specific styles // or ensuring all elements are rendered correctly. } }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; let imgWidth = pdfWidth - 20; // With 10mm margin on each side let imgHeight = imgWidth / ratio; if (imgHeight > pdfHeight - 20) { // Check if it exceeds page height with margin imgHeight = pdfHeight - 20; imgWidth = imgHeight * ratio; } const x = (pdfWidth - imgWidth) / 2; const y = 10; // 10mm margin from top pdf.addImage(imgData, 'PNG', x, y, imgWidth, imgHeight); const cryptoNameVal = document.getElementById('cryptoName')?.value.trim() || "crypto_assessment"; pdf.save(`${cryptoNameVal.replace(/\s+/g, '_')}_liquidity_report.pdf`); // Restore original colors - important for consistent UI after PDF generation originalColors.forEach(item => item.el.style.color = item.color); }).catch(error => { console.error("Error generating PDF: ", error); // alert("An error occurred while generating the PDF. Please try again."); // Avoid alert() const overallAssessmentEl = document.getElementById('overallAssessment'); if(overallAssessmentEl) { const p = document.createElement('p'); p.textContent = "Error: An error occurred while generating the PDF. Please try again."; p.className = "error-message text-center"; overallAssessmentEl.appendChild(p); setTimeout(() => p.remove(), 5000); } // Restore original colors even on error originalColors.forEach(item => item.el.style.color = item.color); }); }); } // Initialize navigation buttons state updateNavigationButtons(); });
Scroll to Top