AI-Powered Crypto Market Manipulation Detector
Analyzed Market Data
Price Chart ($)
Volume Chart
Potential Manipulation Detected
No manipulation patterns detected based on the current data and thresholds.
Details: ${pattern.description}
`; detectionResultsDiv.appendChild(detectionItem); }); } } // Function to reset the tool window.resetTool = function() { priceDataInput.value = ''; volumeDataInput.value = ''; spikeThresholdInput.value = '10'; volumeAnomalyThresholdInput.value = '2'; clearError(); resultsSection.style.display = 'none'; priceChartSvg.innerHTML = ''; // Clear charts volumeChartSvg.innerHTML = ''; detectionResultsDiv.innerHTML = 'No manipulation patterns detected based on the current data and thresholds.
'; }; // PDF Download Functionality window.downloadPdf = function() { const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(22); doc.text("Crypto Market Manipulation Detection Report", 105, 20, null, null, "center"); doc.setFontSize(12); doc.text(`Report Date: ${new Date().toLocaleDateString()}`, 14, 35); doc.text(`Price Spike/Dump Threshold: ${spikeThresholdInput.value}%`, 14, 42); doc.text(`Volume Anomaly Threshold: ${volumeAnomalyThresholdInput.value}x`, 14, 49); let yOffset = 60; // Add Input Data Section doc.setFontSize(16); doc.text("Input Market Data", 14, yOffset); yOffset += 10; doc.setFontSize(10); const priceDataText = priceDataInput.value.replace(/,/g, ', '); const volumeDataText = volumeDataInput.value.replace(/,/g, ', '); doc.text(`Prices: ${priceDataText}`, 14, yOffset, { maxWidth: 180 }); yOffset += Math.ceil(priceDataText.length / 100) * 4 + 5; // Estimate height based on text length doc.text(`Volumes: ${volumeDataText}`, 14, yOffset, { maxWidth: 180 }); yOffset += Math.ceil(volumeDataText.length / 100) * 4 + 20; // Placeholder for Charts in PDF (actual SVG embedding is complex client-side) doc.setFontSize(16); doc.text("Analyzed Market Data Charts", 14, yOffset); yOffset += 10; doc.setFontSize(10); doc.text("Price and Volume charts were generated on-screen, visualizing the input data for analysis.", 14, yOffset); doc.text("These charts help in visually identifying trends and anomalies.", 14, yOffset + 5); yOffset += 20; // Add Detected Patterns Section doc.setFontSize(16); doc.text("Potential Manipulation Detected", 14, yOffset); yOffset += 10; const detections = []; const detectionItems = detectionResultsDiv.querySelectorAll('.detection-item'); if (detectionItems.length === 0 || detectionResultsDiv.querySelector('.no-detections')) { detections.push([{ content: "No significant manipulation patterns detected based on the current data and thresholds.", styles: { textColor: [40, 167, 69], fontStyle: 'italic' } }]); } else { detectionItems.forEach(item => { const type = item.querySelector('h4').textContent; const details = item.querySelector('p:nth-of-type(2)').textContent.replace('Details: ', ''); const indices = item.querySelector('p:nth-of-type(1)').textContent.replace('Occurred around data point(s) index: ', ''); detections.push([{ content: type, styles: { fontStyle: 'bold', fillColor: [255, 240, 240], textColor: [220, 53, 69] } }]); // Light red background for manipulation detections.push([`Indices: ${indices}`]); detections.push([`Details: ${details}`]); detections.push(['']); // Empty row for spacing }); } doc.autoTable({ startY: yOffset, body: detections, theme: 'plain', styles: { font: 'helvetica', fontSize: 10, cellPadding: 3, valign: 'top', lineColor: [230, 230, 230], lineWidth: 0.1 }, didParseCell: function(data) { if (data.cell.raw && data.cell.raw.content && data.cell.raw.content.includes("No significant manipulation")) { data.cell.styles.fillColor = [240, 255, 240]; // Light green for positive message data.cell.styles.textColor = [40, 167, 69]; data.cell.styles.fontStyle = 'bolditalic'; data.cell.styles.halign = 'center'; } } }); doc.save(`Crypto_Manipulation_Report.pdf`); }; // Initial example data and detection on load priceDataInput.value = '10, 12, 11, 15, 25, 30, 28, 20, 15, 12, 10'; volumeDataInput.value = '1000, 1200, 1100, 1800, 5000, 7000, 4500, 2000, 1500, 1000, 800'; detectManipulation(); // Run detection on page load with example data });