Spaces:
Running
Running
Download index.html from Kenayi/quantumsignal: direct link, hf CLI and curl.
- Browser
- Download file 42.4 kB
-
https://huggingface.co/spaces/Kenayi/quantumsignal/resolve/main/index.html
- Command line
-
hf download hf://spaces/Kenayi/quantumsignal/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Kenayi/quantumsignal/resolve/main/index.html
42.4 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>QuantumSignal - AI Market Cycle Analyzer</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-annotation"></script> | |
| <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script> | |
| <style> | |
| .gradient-bg { | |
| background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); | |
| } | |
| .chart-container { | |
| position: relative; | |
| height: 60vh; | |
| width: 100%; | |
| } | |
| #cyclePhaseIndicator { | |
| transition: left 0.5s ease; | |
| box-shadow: 0 0 5px rgba(6, 182, 212, 0.8); | |
| } | |
| .cycle-line { | |
| position: absolute; | |
| height: 2px; | |
| background-color: rgba(255, 255, 255, 0.3); | |
| width: 100%; | |
| } | |
| .signal-indicator { | |
| width: 12px; | |
| height: 12px; | |
| border-radius: 50%; | |
| display: inline-block; | |
| margin-right: 5px; | |
| } | |
| .glow { | |
| box-shadow: 0 0 10px rgba(0, 255, 255, 0.7); | |
| } | |
| .tooltip { | |
| position: relative; | |
| display: inline-block; | |
| } | |
| .tooltip .tooltiptext { | |
| visibility: hidden; | |
| width: 200px; | |
| background-color: rgba(0, 0, 0, 0.8); | |
| color: #fff; | |
| text-align: center; | |
| border-radius: 6px; | |
| padding: 5px; | |
| position: absolute; | |
| z-index: 1; | |
| bottom: 125%; | |
| left: 50%; | |
| margin-left: -100px; | |
| opacity: 0; | |
| transition: opacity 0.3s; | |
| } | |
| .tooltip:hover .tooltiptext { | |
| visibility: visible; | |
| opacity: 1; | |
| } | |
| @keyframes pulse { | |
| 0% { opacity: 0.6; } | |
| 50% { opacity: 1; } | |
| 100% { opacity: 0.6; } | |
| } | |
| .pulse { | |
| animation: pulse 2s infinite; | |
| } | |
| </style> | |
| </head> | |
| <body class="gradient-bg text-gray-100 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <!-- Header --> | |
| <header class="flex flex-col md:flex-row justify-between items-center mb-8"> | |
| <div class="flex items-center mb-4 md:mb-0"> | |
| <div class="w-12 h-12 rounded-full bg-cyan-500 flex items-center justify-center mr-4 glow"> | |
| <i class="fas fa-wave-square text-white text-xl"></i> | |
| </div> | |
| <div> | |
| <h1 class="text-2xl font-bold text-cyan-400">QuantumSignal</h1> | |
| <p class="text-sm text-gray-300">AI-Powered Market Cycle Analysis</p> | |
| </div> | |
| </div> | |
| <div class="flex flex-wrap gap-4"> | |
| <div class="relative"> | |
| <select class="bg-gray-800 text-white rounded-lg px-4 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-cyan-500"> | |
| <option>BTC/USD</option> | |
| <option selected>ETH/USD</option> | |
| <option>SPX500</option> | |
| <option>NASDAQ100</option> | |
| <option>GOLD</option> | |
| </select> | |
| <div class="absolute right-3 top-3 text-gray-400"> | |
| <i class="fas fa-chevron-down"></i> | |
| </div> | |
| </div> | |
| <div class="relative"> | |
| <select class="bg-gray-800 text-white rounded-lg px-4 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-cyan-500"> | |
| <option>1D</option> | |
| <option selected>4H</option> | |
| <option>1H</option> | |
| <option>15M</option> | |
| </select> | |
| <div class="absolute right-3 top-3 text-gray-400"> | |
| <i class="fas fa-chevron-down"></i> | |
| </div> | |
| </div> | |
| <button class="bg-cyan-600 hover:bg-cyan-700 text-white px-4 py-2 rounded-lg transition duration-200 mr-2"> | |
| <i class="fas fa-sync-alt mr-2"></i>Refresh | |
| </button> | |
| <label class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition duration-200 cursor-pointer"> | |
| <i class="fas fa-upload mr-2"></i>Upload Data | |
| <input type="file" id="dataUpload" accept=".csv" class="hidden"> | |
| </label> | |
| </div> | |
| </header> | |
| <!-- Signal Status --> | |
| <div class="bg-gray-800 rounded-xl p-4 mb-6 flex flex-wrap justify-between items-center"> | |
| <div class="flex items-center mb-2 sm:mb-0"> | |
| <div class="signal-indicator bg-green-500 pulse"></div> | |
| <div> | |
| <h3 class="font-semibold">Current Market Phase</h3> | |
| <p class="text-sm text-gray-300">Accumulation (Cycle 5/7)</p> | |
| </div> | |
| </div> | |
| <div class="flex items-center mb-2 sm:mb-0"> | |
| <div class="signal-indicator bg-yellow-500"></div> | |
| <div> | |
| <h3 class="font-semibold">Next Turning Point</h3> | |
| <p class="text-sm text-gray-300">2023-11-15 ±2 days (78% confidence)</p> | |
| </div> | |
| </div> | |
| <div class="flex items-center"> | |
| <div class="signal-indicator bg-purple-500"></div> | |
| <div> | |
| <h3 class="font-semibold">HHT Dominant Cycle</h3> | |
| <p class="text-sm text-gray-300">42 days (IMF 3)</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Main Chart --> | |
| <div class="bg-gray-800 rounded-xl p-4 mb-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-semibold">ETH/USD - Hilbert-Huang Transform Analysis</h2> | |
| <div class="flex gap-2"> | |
| <button class="px-3 py-1 bg-gray-700 rounded-lg text-sm hover:bg-gray-600">Price</button> | |
| <button class="px-3 py-1 bg-gray-700 rounded-lg text-sm hover:bg-gray-600">IMF</button> | |
| <button class="px-3 py-1 bg-cyan-600 rounded-lg text-sm">Hilbert Spectrum</button> | |
| <button class="px-3 py-1 bg-gray-700 rounded-lg text-sm hover:bg-gray-600">Trend</button> | |
| </div> | |
| </div> | |
| <div class="chart-container"> | |
| <canvas id="priceChart"></canvas> | |
| <div id="cycleLines"></div> | |
| </div> | |
| <div class="mt-4 bg-gray-800 rounded-lg p-2"> | |
| <div class="flex justify-between items-center mb-2"> | |
| <h3 class="text-sm font-semibold">Dominant Cycle Analysis</h3> | |
| <div class="text-xs text-gray-400">Current: 42 days (IMF 3)</div> | |
| </div> | |
| <div class="relative h-16 w-full"> | |
| <canvas id="cycleChart"></canvas> | |
| <div id="cyclePhaseIndicator" class="absolute top-0 h-full w-1 bg-cyan-400"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Cycle Projections --> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8"> | |
| <!-- Historical Cycles --> | |
| <div class="bg-gray-800 rounded-xl p-4"> | |
| <h3 class="text-lg font-semibold mb-4 flex items-center"> | |
| <i class="fas fa-history mr-2 text-cyan-400"></i> Historical Cycles (7 iterations) | |
| </h3> | |
| <div class="overflow-x-auto"> | |
| <table class="w-full"> | |
| <thead> | |
| <tr class="text-gray-400 text-sm border-b border-gray-700"> | |
| <th class="pb-2 text-left">Cycle</th> | |
| <th class="pb-2 text-left">Duration</th> | |
| <th class="pb-2 text-left">Amplitude</th> | |
| <th class="pb-2 text-left">Phase</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr class="text-sm border-b border-gray-700 hover:bg-gray-700"> | |
| <td class="py-2">7</td> | |
| <td class="py-2">38 days</td> | |
| <td class="py-2">+24.5%</td> | |
| <td class="py-2 text-green-400">Bullish</td> | |
| </tr> | |
| <tr class="text-sm border-b border-gray-700 hover:bg-gray-700"> | |
| <td class="py-2">6</td> | |
| <td class="py-2">42 days</td> | |
| <td class="py-2">-18.2%</td> | |
| <td class="py-2 text-red-400">Bearish</td> | |
| </tr> | |
| <tr class="text-sm border-b border-gray-700 hover:bg-gray-700"> | |
| <td class="py-2">5</td> | |
| <td class="py-2">45 days</td> | |
| <td class="py-2">+31.7%</td> | |
| <td class="py-2 text-green-400">Bullish</td> | |
| </tr> | |
| <tr class="text-sm border-b border-gray-700 hover:bg-gray-700"> | |
| <td class="py-2">4</td> | |
| <td class="py-2">39 days</td> | |
| <td class="py-2">-22.4%</td> | |
| <td class="py-2 text-red-400">Bearish</td> | |
| </tr> | |
| <tr class="text-sm border-b border-gray-700 hover:bg-gray-700"> | |
| <td class="py-2">3</td> | |
| <td class="py-2">41 days</td> | |
| <td class="py-2">+28.9%</td> | |
| <td class="py-2 text-green-400">Bullish</td> | |
| </tr> | |
| <tr class="text-sm border-b border-gray-700 hover:bg-gray-700"> | |
| <td class="py-2">2</td> | |
| <td class="py-2">43 days</td> | |
| <td class="py-2">-15.6%</td> | |
| <td class="py-2 text-red-400">Bearish</td> | |
| </tr> | |
| <tr class="text-sm hover:bg-gray-700"> | |
| <td class="py-2">1</td> | |
| <td class="py-2">40 days</td> | |
| <td class="py-2">+19.8%</td> | |
| <td class="py-2 text-green-400">Bullish</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| <!-- Current Cycle Analysis --> | |
| <div class="bg-gray-800 rounded-xl p-4"> | |
| <h3 class="text-lg font-semibold mb-4 flex items-center"> | |
| <i class="fas fa-chart-line mr-2 text-cyan-400"></i> Current Cycle Metrics | |
| </h3> | |
| <div class="space-y-4"> | |
| <div> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>Cycle Progress</span> | |
| <span>68%</span> | |
| </div> | |
| <div class="w-full bg-gray-700 rounded-full h-2"> | |
| <div class="bg-cyan-500 h-2 rounded-full" style="width: 68%"></div> | |
| </div> | |
| </div> | |
| <div> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>Trend Strength</span> | |
| <span>0.73</span> | |
| </div> | |
| <div class="w-full bg-gray-700 rounded-full h-2"> | |
| <div class="bg-purple-500 h-2 rounded-full" style="width: 73%"></div> | |
| </div> | |
| </div> | |
| <div> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>Volatility Index</span> | |
| <span>1.24</span> | |
| </div> | |
| <div class="w-full bg-gray-700 rounded-full h-2"> | |
| <div class="bg-yellow-500 h-2 rounded-full" style="width: 62%"></div> | |
| </div> | |
| </div> | |
| <div class="pt-2"> | |
| <h4 class="font-medium mb-2">HHT IMF Components</h4> | |
| <div class="grid grid-cols-3 gap-2 text-center text-xs"> | |
| <div class="bg-gray-700 p-2 rounded"> | |
| <div>IMF1</div> | |
| <div class="text-cyan-400">0.89</div> | |
| </div> | |
| <div class="bg-gray-700 p-2 rounded"> | |
| <div>IMF2</div> | |
| <div class="text-cyan-400">0.76</div> | |
| </div> | |
| <div class="bg-gray-700 p-2 rounded"> | |
| <div>IMF3</div> | |
| <div class="text-cyan-400">0.92</div> | |
| </div> | |
| <div class="bg-gray-700 p-2 rounded"> | |
| <div>IMF4</div> | |
| <div class="text-cyan-400">0.68</div> | |
| </div> | |
| <div class="bg-gray-700 p-2 rounded"> | |
| <div>IMF5</div> | |
| <div class="text-cyan-400">0.54</div> | |
| </div> | |
| <div class="bg-gray-700 p-2 rounded"> | |
| <div>Residue</div> | |
| <div class="text-cyan-400">0.31</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Projected Turning Points --> | |
| <div class="bg-gray-800 rounded-xl p-4"> | |
| <h3 class="text-lg font-semibold mb-4 flex items-center"> | |
| <i class="fas fa-crystal-ball mr-2 text-cyan-400"></i> Projected Turning Points | |
| </h3> | |
| <div class="space-y-4"> | |
| <div class="bg-gray-700 p-3 rounded-lg"> | |
| <div class="flex justify-between mb-1"> | |
| <span class="font-medium">Next Peak</span> | |
| <span class="text-sm text-green-400">78% confidence</span> | |
| </div> | |
| <div class="text-sm">2023-11-15 ±2 days</div> | |
| <div class="text-xs text-gray-400 mt-1">Projected price: $2,240 - $2,320</div> | |
| </div> | |
| <div class="bg-gray-700 p-3 rounded-lg"> | |
| <div class="flex justify-between mb-1"> | |
| <span class="font-medium">Next Trough</span> | |
| <span class="text-sm text-green-400">65% confidence</span> | |
| </div> | |
| <div class="text-sm">2023-12-28 ±3 days</div> | |
| <div class="text-xs text-gray-400 mt-1">Projected price: $1,860 - $1,920</div> | |
| </div> | |
| <div class="bg-gray-700 p-3 rounded-lg"> | |
| <div class="flex justify-between mb-1"> | |
| <span class="font-medium">Following Peak</span> | |
| <span class="text-sm text-yellow-400">52% confidence</span> | |
| </div> | |
| <div class="text-sm">2024-02-10 ±5 days</div> | |
| <div class="text-xs text-gray-400 mt-1">Projected price: $2,450 - $2,600</div> | |
| </div> | |
| </div> | |
| <div class="mt-4 p-3 bg-gray-900 rounded-lg"> | |
| <h4 class="font-medium mb-2 flex items-center"> | |
| <i class="fas fa-robot mr-2 text-cyan-400"></i> AI Recommendation | |
| </h4> | |
| <p class="text-sm">Based on current cycle analysis and HHT spectrum, the AI suggests <span class="text-green-400 font-medium">accumulating positions</span> with a target take-profit zone between $2,240-$2,320. Set stop-loss below $1,950.</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Footer --> | |
| <footer class="text-center text-gray-400 text-sm pt-8 border-t border-gray-700"> | |
| <div class="flex justify-center space-x-4 mb-4"> | |
| <a href="#" class="hover:text-cyan-400"><i class="fas fa-info-circle"></i> About</a> | |
| <a href="#" class="hover:text-cyan-400"><i class="fas fa-book"></i> Docs</a> | |
| <a href="#" class="hover:text-cyan-400"><i class="fas fa-cog"></i> Settings</a> | |
| <a href="#" class="hover:text-cyan-400"><i class="fas fa-shield-alt"></i> Privacy</a> | |
| </div> | |
| <p>QuantumSignal uses Hilbert-Huang Transform (HHT) algorithm for nonlinear and non-stationary signal processing.</p> | |
| <p class="mt-2">Data updates every 5 minutes. Last update: <span id="lastUpdate">2023-10-25 14:32:45 UTC</span></p> | |
| </footer> | |
| </div> | |
| <!-- Upload Modal --> | |
| <div id="uploadModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-gray-800 rounded-xl p-6 w-full max-w-md"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-semibold">Upload Market Data</h3> | |
| <button id="closeModal" class="text-gray-400 hover:text-white"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="mb-4"> | |
| <p class="text-sm text-gray-300 mb-4"> | |
| Upload a CSV file with columns: <code>timestamp,open,high,low,close,volume</code>. | |
| Timestamp should be in ISO format (YYYY-MM-DD HH:MM:SS). | |
| </p> | |
| <div id="uploadStatus" class="text-sm"></div> | |
| </div> | |
| <div class="flex justify-end"> | |
| <button id="cancelUpload" class="px-4 py-2 bg-gray-700 rounded-lg mr-2">Cancel</button> | |
| <button id="confirmUpload" class="px-4 py-2 bg-purple-600 rounded-lg" disabled>Process Data</button> | |
| </div> | |
| </div> | |
| </div> | |
| <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | |
| <script> | |
| // Binance API configuration | |
| const binanceSymbols = { | |
| 'BTC/USD': 'btcusdt', | |
| 'ETH/USD': 'ethusdt', | |
| 'SPX500': null, | |
| 'NASDAQ100': null, | |
| 'GOLD': null | |
| }; | |
| let currentSymbol = 'ethusdt'; | |
| let socket = null; | |
| let historicalData = []; | |
| let isLive = false; | |
| // Initialize Binance WebSocket | |
| function initBinanceWS(symbol) { | |
| if (socket) { | |
| socket.close(); | |
| } | |
| currentSymbol = symbol; | |
| socket = new WebSocket(`wss://stream.binance.com:9443/ws/${symbol}@kline_1h`); | |
| socket.onmessage = function(event) { | |
| const data = JSON.parse(event.data); | |
| const candle = data.k; | |
| // Update last candle or add new one | |
| const lastCandle = historicalData[historicalData.length - 1]; | |
| const candleTime = new Date(candle.t); | |
| if (lastCandle && lastCandle.x.getTime() === candleTime.getTime()) { | |
| // Update existing candle | |
| lastCandle.y = parseFloat(candle.c); | |
| lastCandle.h = parseFloat(candle.h); | |
| lastCandle.l = parseFloat(candle.l); | |
| lastCandle.o = parseFloat(candle.o); | |
| } else { | |
| // Add new candle | |
| historicalData.push({ | |
| x: candleTime, | |
| y: parseFloat(candle.c), | |
| h: parseFloat(candle.h), | |
| l: parseFloat(candle.l), | |
| o: parseFloat(candle.o) | |
| }); | |
| // Keep only last 200 candles | |
| if (historicalData.length > 200) { | |
| historicalData.shift(); | |
| } | |
| } | |
| // Update chart | |
| if (window.chart) { | |
| window.chart.data.datasets[0].data = historicalData; | |
| window.chart.update('none'); | |
| } | |
| // Update last update time | |
| document.getElementById('lastUpdate').textContent = | |
| candleTime.toISOString().replace('T', ' ').substring(0, 19) + ' UTC'; | |
| }; | |
| socket.onerror = function(error) { | |
| console.error('WebSocket error:', error); | |
| document.getElementById('lastUpdate').textContent = 'Connection error - ' + new Date().toISOString().replace('T', ' ').substring(0, 19) + ' UTC'; | |
| }; | |
| } | |
| // Load historical data from Binance | |
| async function loadHistoricalData(symbol) { | |
| try { | |
| const response = await axios.get(`https://api.binance.com/api/v3/klines`, { | |
| params: { | |
| symbol: symbol.toUpperCase(), | |
| interval: '1h', | |
| limit: 200 | |
| } | |
| }); | |
| historicalData = response.data.map(item => ({ | |
| x: new Date(item[0]), | |
| y: parseFloat(item[4]), // close price | |
| h: parseFloat(item[2]), // high | |
| l: parseFloat(item[3]), // low | |
| o: parseFloat(item[1]) // open | |
| })); | |
| if (window.chart) { | |
| window.chart.data.datasets[0].data = historicalData; | |
| window.chart.update(); | |
| } | |
| return true; | |
| } catch (error) { | |
| console.error('Error loading historical data:', error); | |
| return false; | |
| } | |
| } | |
| // File upload handling | |
| let uploadedData = null; | |
| document.getElementById('dataUpload').addEventListener('change', function(e) { | |
| const file = e.target.files[0]; | |
| if (!file) return; | |
| document.getElementById('uploadModal').classList.remove('hidden'); | |
| document.getElementById('uploadStatus').textContent = `Loading ${file.name}...`; | |
| document.getElementById('confirmUpload').disabled = true; | |
| const reader = new FileReader(); | |
| reader.onload = function(e) { | |
| try { | |
| const csvData = e.target.result; | |
| uploadedData = parseCSV(csvData); | |
| document.getElementById('uploadStatus').innerHTML = | |
| `Successfully loaded ${uploadedData.length} data points<br> | |
| <span class="text-xs">From ${uploadedData[0].x.toLocaleString()} to ${uploadedData[uploadedData.length-1].x.toLocaleString()}</span>`; | |
| document.getElementById('confirmUpload').disabled = false; | |
| } catch (error) { | |
| document.getElementById('uploadStatus').textContent = `Error: ${error.message}`; | |
| } | |
| }; | |
| reader.readAsText(file); | |
| }); | |
| function parseCSV(csvText) { | |
| const lines = csvText.split('\n'); | |
| const headers = lines[0].split(',').map(h => h.trim().toLowerCase()); | |
| // Validate required columns | |
| const required = ['timestamp', 'close']; | |
| required.forEach(col => { | |
| if (!headers.includes(col)) { | |
| throw new Error(`Missing required column: ${col}`); | |
| } | |
| }); | |
| const data = []; | |
| for (let i = 1; i < lines.length; i++) { | |
| if (!lines[i].trim()) continue; | |
| const values = lines[i].split(','); | |
| const entry = {}; | |
| headers.forEach((header, index) => { | |
| entry[header] = values[index] ? values[index].trim() : null; | |
| }); | |
| // Parse timestamp (support multiple formats) | |
| let timestamp; | |
| if (entry.timestamp.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/)) { | |
| timestamp = new Date(entry.timestamp.replace(' ', 'T') + 'Z'); | |
| } else if (entry.timestamp.match(/^\d{10}$/)) { | |
| timestamp = new Date(parseInt(entry.timestamp) * 1000); | |
| } else { | |
| timestamp = new Date(entry.timestamp); | |
| } | |
| if (isNaN(timestamp.getTime())) { | |
| throw new Error(`Invalid timestamp at line ${i+1}: ${entry.timestamp}`); | |
| } | |
| // Use close price by default | |
| const price = parseFloat(entry.close); | |
| if (isNaN(price)) { | |
| throw new Error(`Invalid price at line ${i+1}: ${entry.close}`); | |
| } | |
| data.push({ | |
| x: timestamp, | |
| y: price | |
| }); | |
| } | |
| return data.sort((a, b) => a.x - b.x); | |
| } | |
| // Modal controls | |
| document.getElementById('closeModal').addEventListener('click', function() { | |
| document.getElementById('uploadModal').classList.add('hidden'); | |
| }); | |
| document.getElementById('cancelUpload').addEventListener('click', function() { | |
| document.getElementById('uploadModal').classList.add('hidden'); | |
| document.getElementById('dataUpload').value = ''; | |
| }); | |
| document.getElementById('confirmUpload').addEventListener('click', function() { | |
| if (uploadedData && uploadedData.length > 0) { | |
| // Update chart with new data | |
| chart.data.datasets[0].data = uploadedData; | |
| chart.update(); | |
| document.getElementById('uploadModal').classList.add('hidden'); | |
| document.getElementById('dataUpload').value = ''; | |
| // Update signal status to reflect new data | |
| document.querySelector('.signal-status p').textContent = | |
| `Custom Dataset (${uploadedData.length} points)`; | |
| } | |
| }); | |
| // Generate sample price data (fallback) | |
| function generatePriceData() { | |
| if (isLive && historicalData.length > 0) { | |
| return historicalData; | |
| } | |
| const data = []; | |
| let price = 1800; | |
| const now = new Date(); | |
| for (let i = 0; i < 200; i++) { | |
| const date = new Date(now); | |
| date.setHours(date.getHours() - i); | |
| // Simulate price movements with some randomness | |
| const trend = Math.sin(i / 20) * 0.5 + 0.5; | |
| const volatility = Math.random() * 20 - 10; | |
| price += trend * 2 + volatility; | |
| // Ensure price stays in reasonable range | |
| price = Math.max(1700, Math.min(2300, price)); | |
| data.push({ | |
| x: date, | |
| y: price | |
| }); | |
| } | |
| return data.reverse(); | |
| } | |
| // Generate cycle lines data | |
| function generateCycleLines() { | |
| const cycles = []; | |
| const now = new Date(); | |
| // Generate 7 historical cycles and 1 projected | |
| for (let i = 7; i >= 0; i--) { | |
| const startDate = new Date(now); | |
| startDate.setDate(startDate.getDate() - (i * 42) - 21); | |
| const endDate = new Date(startDate); | |
| endDate.setDate(endDate.getDate() + 42); | |
| cycles.push({ | |
| start: startDate, | |
| end: endDate, | |
| type: i % 2 === 0 ? 'bearish' : 'bullish', | |
| confidence: i === 0 ? 0.78 : 1 // Projected cycle has confidence | |
| }); | |
| } | |
| return cycles; | |
| } | |
| // Initialize chart | |
| function initChart() { | |
| const ctx = document.getElementById('priceChart').getContext('2d'); | |
| const priceData = []; | |
| // Create the chart | |
| const chart = new Chart(ctx, { | |
| type: 'line', | |
| data: { | |
| datasets: [{ | |
| label: 'ETH/USD Price', | |
| data: priceData, | |
| borderColor: 'rgba(6, 182, 212, 1)', | |
| backgroundColor: 'rgba(6, 182, 212, 0.1)', | |
| borderWidth: 2, | |
| fill: true, | |
| tension: 0.1, | |
| pointRadius: 0 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| scales: { | |
| x: { | |
| type: 'time', | |
| time: { | |
| unit: 'day', | |
| displayFormats: { | |
| day: 'MMM d' | |
| } | |
| }, | |
| grid: { | |
| color: 'rgba(255, 255, 255, 0.1)' | |
| }, | |
| ticks: { | |
| color: 'rgba(255, 255, 255, 0.7)' | |
| } | |
| }, | |
| y: { | |
| grid: { | |
| color: 'rgba(255, 255, 255, 0.1)' | |
| }, | |
| ticks: { | |
| color: 'rgba(255, 255, 255, 0.7)' | |
| } | |
| } | |
| }, | |
| plugins: { | |
| legend: { | |
| display: false | |
| }, | |
| tooltip: { | |
| mode: 'index', | |
| intersect: false, | |
| backgroundColor: 'rgba(0, 0, 0, 0.8)', | |
| titleColor: '#06b6d4', | |
| bodyColor: 'white', | |
| borderColor: 'rgba(255, 255, 255, 0.1)', | |
| borderWidth: 1 | |
| }, | |
| annotation: { | |
| annotations: { | |
| currentCycle: { | |
| type: 'box', | |
| xMin: cycles[6].start, | |
| xMax: cycles[6].end, | |
| backgroundColor: 'rgba(6, 182, 212, 0.1)', | |
| borderColor: 'rgba(6, 182, 212, 0.5)', | |
| borderWidth: 1 | |
| }, | |
| projectedCycle: { | |
| type: 'box', | |
| xMin: cycles[0].start, | |
| xMax: cycles[0].end, | |
| backgroundColor: 'rgba(168, 85, 247, 0.1)', | |
| borderColor: 'rgba(168, 85, 247, 0.5)', | |
| borderWidth: 1, | |
| borderDash: [5, 5] | |
| } | |
| } | |
| } | |
| }, | |
| interaction: { | |
| mode: 'nearest', | |
| axis: 'x', | |
| intersect: false | |
| } | |
| } | |
| }); | |
| return chart; | |
| } | |
| // Draw cycle lines below the chart | |
| function drawCycleLines(cycles) { | |
| const container = document.getElementById('cycleLines'); | |
| container.innerHTML = ''; | |
| // Calculate the height of the chart container | |
| const chartHeight = document.querySelector('.chart-container').offsetHeight; | |
| const cycleLineHeight = 20; | |
| cycles.forEach((cycle, index) => { | |
| const line = document.createElement('div'); | |
| line.className = 'cycle-line'; | |
| line.style.bottom = `${index * cycleLineHeight}px`; | |
| // Color based on cycle type | |
| if (cycle.type === 'bullish') { | |
| line.style.backgroundColor = 'rgba(16, 185, 129, 0.3)'; | |
| } else { | |
| line.style.backgroundColor = 'rgba(239, 68, 68, 0.3)'; | |
| } | |
| // Add tooltip | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute top-0 left-0 bg-gray-800 text-white p-2 rounded text-xs pointer-events-none opacity-0 transition-opacity'; | |
| tooltip.style.transform = 'translateY(-100%)'; | |
| tooltip.innerHTML = ` | |
| <div>Cycle ${cycles.length - index}/${cycles.length}</div> | |
| <div>${cycle.type === 'bullish' ? 'Bullish' : 'Bearish'} phase</div> | |
| <div>${cycle.start.toLocaleDateString()} - ${cycle.end.toLocaleDateString()}</div> | |
| ${index === 0 ? `<div class="text-purple-400">Projected (${Math.round(cycle.confidence * 100)}% confidence)</div>` : ''} | |
| `; | |
| line.appendChild(tooltip); | |
| // Show tooltip on hover | |
| line.addEventListener('mouseover', () => { | |
| tooltip.style.opacity = '1'; | |
| }); | |
| line.addEventListener('mouseout', () => { | |
| tooltip.style.opacity = '0'; | |
| }); | |
| container.appendChild(line); | |
| }); | |
| } | |
| // Initialize cycle chart | |
| function initCycleChart() { | |
| const ctx = document.getElementById('cycleChart').getContext('2d'); | |
| const cycleLength = 42; // days | |
| const data = Array(100).fill(0).map((_, i) => Math.sin(i / (100 / (2 * Math.PI)))); | |
| const chart = new Chart(ctx, { | |
| type: 'line', | |
| data: { | |
| labels: Array(100).fill(''), | |
| datasets: [{ | |
| data: data, | |
| borderColor: 'rgba(139, 92, 246, 0.8)', | |
| borderWidth: 2, | |
| tension: 0.1, | |
| pointRadius: 0, | |
| fill: true, | |
| backgroundColor: 'rgba(139, 92, 246, 0.2)' | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| animation: false, | |
| plugins: { | |
| legend: { | |
| display: false | |
| }, | |
| tooltip: { | |
| enabled: false | |
| } | |
| }, | |
| scales: { | |
| x: { | |
| display: false, | |
| grid: { | |
| display: false | |
| } | |
| }, | |
| y: { | |
| display: false, | |
| grid: { | |
| display: false | |
| } | |
| } | |
| }, | |
| interaction: { | |
| intersect: false, | |
| mode: 'index' | |
| } | |
| } | |
| }); | |
| // Update phase indicator position | |
| function updatePhaseIndicator() { | |
| const now = new Date(); | |
| const cycleProgress = ((now.getHours() % cycleLength) / cycleLength) * 100; | |
| document.getElementById('cyclePhaseIndicator').style.left = `${cycleProgress}%`; | |
| } | |
| setInterval(updatePhaseIndicator, 60000); | |
| updatePhaseIndicator(); | |
| return chart; | |
| } | |
| // Initialize the app | |
| document.addEventListener('DOMContentLoaded', async () => { | |
| let chart = initChart(); | |
| let cycleChart = initCycleChart(); | |
| drawCycleLines(generateCycleLines()); | |
| // Initialize with ETH/USD data | |
| await loadHistoricalData('ethusdt'); | |
| initBinanceWS('ethusdt'); | |
| isLive = true; | |
| // Handle symbol selection change | |
| document.querySelector('select').addEventListener('change', async function() { | |
| const selectedSymbol = this.value; | |
| const binanceSymbol = binanceSymbols[selectedSymbol]; | |
| if (binanceSymbol) { | |
| const success = await loadHistoricalData(binanceSymbol); | |
| if (success) { | |
| initBinanceWS(binanceSymbol); | |
| isLive = true; | |
| } | |
| } else { | |
| // For non-Binance symbols, use generated data | |
| if (socket) { | |
| socket.close(); | |
| socket = null; | |
| } | |
| isLive = false; | |
| chart.data.datasets[0].data = generatePriceData(); | |
| chart.update(); | |
| } | |
| }); | |
| // Store chart reference globally for updates | |
| window.chart = chart; | |
| // Update last update time | |
| setInterval(() => { | |
| const now = new Date(); | |
| document.getElementById('lastUpdate').textContent = now.toISOString().replace('T', ' ').substring(0, 19) + ' UTC'; | |
| }, 1000); | |
| // Sample HHT data for demonstration | |
| const hhtData = { | |
| imf1: Array(200).fill().map((_, i) => Math.sin(i/10) * 50 + 1900), | |
| imf2: Array(200).fill().map((_, i) => Math.sin(i/20) * 30 + 1900), | |
| imf3: Array(200).fill().map((_, i) => Math.sin(i/30) * 20 + 1900), | |
| trend: Array(200).fill().map((_, i) => i * 0.5 + 1900) | |
| }; | |
| // Add HHT data to chart | |
| function addHHTData() { | |
| chart.data.datasets = [ | |
| { | |
| label: 'ETH/USD Price', | |
| data: generatePriceData(), | |
| borderColor: 'rgba(6, 182, 212, 1)', | |
| backgroundColor: 'rgba(6, 182, 212, 0.1)', | |
| borderWidth: 2, | |
| fill: true, | |
| tension: 0.1, | |
| pointRadius: 0 | |
| }, | |
| { | |
| label: 'IMF1 (High Freq)', | |
| data: hhtData.imf1.map((y, i) => ({x: new Date(Date.now() - (200 - i) * 3600000), y})), | |
| borderColor: 'rgba(236, 72, 153, 0.7)', | |
| borderWidth: 1, | |
| pointRadius: 0 | |
| }, | |
| { | |
| label: 'IMF3 (Dominant Cycle)', | |
| data: hhtData.imf3.map((y, i) => ({x: new Date(Date.now() - (200 - i) * 3600000), y})), | |
| borderColor: 'rgba(139, 92, 246, 0.7)', | |
| borderWidth: 2, | |
| pointRadius: 0 | |
| }, | |
| { | |
| label: 'Trend', | |
| data: hhtData.trend.map((y, i) => ({x: new Date(Date.now() - (200 - i) * 3600000), y})), | |
| borderColor: 'rgba(16, 185, 129, 0.7)', | |
| borderWidth: 2, | |
| borderDash: [5, 5], | |
| pointRadius: 0 | |
| } | |
| ]; | |
| chart.update(); | |
| } | |
| // Initial chart update | |
| addHHTData(); | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Kenayi/quantumsignal" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |