Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- index.html +702 -564
index.html
CHANGED
|
@@ -3,648 +3,786 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
-
<
|
| 8 |
-
<
|
|
|
|
| 9 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 10 |
-
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;700;900&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
|
| 11 |
|
| 12 |
-
<
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
}
|
| 34 |
-
},
|
| 35 |
-
animation: {
|
| 36 |
-
'pulse-slow': 'pulse 4s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
| 37 |
-
'scanline': 'scanline 8s linear infinite',
|
| 38 |
-
},
|
| 39 |
-
keyframes: {
|
| 40 |
-
scanline: {
|
| 41 |
-
'0%': { transform: 'translateY(-100%)' },
|
| 42 |
-
'100%': { transform: 'translateY(100%)' }
|
| 43 |
-
}
|
| 44 |
-
}
|
| 45 |
-
}
|
| 46 |
-
}
|
| 47 |
}
|
| 48 |
-
</script>
|
| 49 |
|
| 50 |
-
<style>
|
| 51 |
body {
|
| 52 |
-
|
| 53 |
-
color:
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
position: relative;
|
| 72 |
-
overflow: hidden;
|
| 73 |
}
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
border: 1px solid #d4a373;
|
| 88 |
-
transition: all 0.3s ease;
|
| 89 |
-
}
|
| 90 |
-
.tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
|
| 91 |
-
.tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
|
| 92 |
-
.bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
|
| 93 |
-
.br { bottom: -1px; right: -1px; border-left: none; border-top: none; }
|
| 94 |
-
|
| 95 |
-
.scifi-panel:hover .scifi-border-corner {
|
| 96 |
-
width: 12px;
|
| 97 |
-
height: 12px;
|
| 98 |
-
box-shadow: 0 0 8px #d4a373;
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
/* Typography Utilities */
|
| 102 |
-
.text-glow { text-shadow: 0 0 10px rgba(212, 163, 115, 0.4); }
|
| 103 |
-
.text-glow-green { text-shadow: 0 0 10px rgba(74, 222, 128, 0.4); }
|
| 104 |
-
.text-glow-red { text-shadow: 0 0 10px rgba(248, 113, 113, 0.4); }
|
| 105 |
-
|
| 106 |
-
/* Scanline Effect Overlay */
|
| 107 |
-
.scanlines {
|
| 108 |
-
position: fixed;
|
| 109 |
-
top: 0; left: 0; width: 100%; height: 100%;
|
| 110 |
-
background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.1));
|
| 111 |
-
background-size: 100% 4px;
|
| 112 |
-
pointer-events: none;
|
| 113 |
-
z-index: 9999;
|
| 114 |
-
opacity: 0.3;
|
| 115 |
}
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
width: 100%;
|
| 124 |
-
|
| 125 |
position: relative;
|
|
|
|
|
|
|
| 126 |
overflow: hidden;
|
|
|
|
| 127 |
}
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
animation: loading 2s infinite ease-in-out;
|
| 134 |
}
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
}
|
| 139 |
-
</style>
|
| 140 |
-
</head>
|
| 141 |
-
<body class="font-sans min-h-screen flex flex-col selection:bg-dune-accent selection:text-black">
|
| 142 |
-
|
| 143 |
-
<!-- CRT Scanline Overlay -->
|
| 144 |
-
<div class="scanlines"></div>
|
| 145 |
-
|
| 146 |
-
<!-- Navbar -->
|
| 147 |
-
<nav class="fixed w-full z-50 bg-dune-bg/90 backdrop-blur-md border-b border-dune-border">
|
| 148 |
-
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 149 |
-
<div class="flex items-center justify-between h-16">
|
| 150 |
-
<div class="flex items-center gap-4">
|
| 151 |
-
<div class="w-8 h-8 border border-dune-accent flex items-center justify-center relative">
|
| 152 |
-
<div class="absolute inset-0 bg-dune-accent opacity-20 animate-pulse"></div>
|
| 153 |
-
<i class="fa-solid fa-microchip text-dune-accent text-sm"></i>
|
| 154 |
-
</div>
|
| 155 |
-
<div>
|
| 156 |
-
<span class="text-lg font-bold tracking-widest text-white font-mono">CRYPTO<span class="text-dune-accent">OS</span></span>
|
| 157 |
-
<div class="text-[10px] text-dune-muted tracking-[0.2em]">SYSTEM_V.4.0.2</div>
|
| 158 |
-
</div>
|
| 159 |
-
</div>
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
class="text-[10px] text-dune-muted hover:text-dune-accent transition-colors border border-dune-border px-3 py-1 font-mono uppercase">
|
| 168 |
-
Built with anycoder
|
| 169 |
-
</a>
|
| 170 |
-
</div>
|
| 171 |
-
</div>
|
| 172 |
-
</div>
|
| 173 |
-
<div class="loader-bar"></div>
|
| 174 |
-
</nav>
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
<!-- Header Stats Grid -->
|
| 180 |
-
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
| 181 |
-
<!-- Ticker -->
|
| 182 |
-
<div class="scifi-panel p-4 flex items-center justify-between group">
|
| 183 |
-
<div class="scifi-border-corner tl"></div><div class="scifi-border-corner tr"></div>
|
| 184 |
-
<div class="scifi-border-corner bl"></div><div class="scifi-border-corner br"></div>
|
| 185 |
-
|
| 186 |
-
<div>
|
| 187 |
-
<p class="text-[10px] text-dune-muted font-mono mb-1">ASSET_ID</p>
|
| 188 |
-
<h2 class="text-2xl font-bold text-white font-mono tracking-tighter">BTC/USDT</h2>
|
| 189 |
-
</div>
|
| 190 |
-
<i class="fa-brands fa-bitcoin text-3xl text-dune-accent opacity-80 group-hover:scale-110 transition-transform"></i>
|
| 191 |
-
</div>
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
| 197 |
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
<span id="priceChangeBadge" class="px-2 py-1 border border-dune-border text-xs font-mono bg-dune-panel text-dune-muted">0.00%</span>
|
| 203 |
-
</div>
|
| 204 |
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
</div>
|
| 218 |
-
<div class="
|
| 219 |
-
<
|
| 220 |
-
|
| 221 |
</div>
|
| 222 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
-
<
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
</div>
|
| 233 |
-
<
|
| 234 |
</div>
|
| 235 |
-
</div>
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
<div
|
| 242 |
-
<div class="scifi-panel p-1">
|
| 243 |
-
<div class="scifi-border-corner tl"></div><div class="scifi-border-corner tr"></div>
|
| 244 |
-
<div class="scifi-border-corner bl"></div><div class="scifi-border-corner br"></div>
|
| 245 |
-
|
| 246 |
-
<div class="flex justify-between items-center p-3 border-b border-dune-border bg-dune-panel/50">
|
| 247 |
-
<h3 class="text-xs font-bold text-dune-accent font-mono tracking-widest flex items-center gap-2">
|
| 248 |
-
<i class="fa-solid fa-wave-square"></i> TECHNICAL_ANALYSIS
|
| 249 |
-
</h3>
|
| 250 |
-
<div class="flex gap-2">
|
| 251 |
-
<span class="text-[10px] px-2 py-1 border border-dune-border text-dune-muted font-mono">1H</span>
|
| 252 |
-
<span class="text-[10px] px-2 py-1 border border-dune-accent/30 text-dune-accent font-mono bg-dune-accent/10">LIVE</span>
|
| 253 |
-
</div>
|
| 254 |
-
</div>
|
| 255 |
-
<div class="p-4 bg-dune-bg relative">
|
| 256 |
-
<div class="chart-container">
|
| 257 |
-
<canvas id="cryptoChart"></canvas>
|
| 258 |
-
</div>
|
| 259 |
-
</div>
|
| 260 |
-
</div>
|
| 261 |
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
|
|
|
|
|
|
| 268 |
</div>
|
| 269 |
-
<div class="
|
| 270 |
-
<div class="
|
| 271 |
-
<
|
| 272 |
-
<p id="macdVal" class="text-lg font-bold text-yellow-400 font-mono">--</p>
|
| 273 |
</div>
|
| 274 |
-
<div class="
|
| 275 |
-
<div class="
|
| 276 |
-
<
|
| 277 |
-
<p id="emaVal" class="text-lg font-bold text-purple-400 font-mono">--</p>
|
| 278 |
</div>
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
| 283 |
</div>
|
| 284 |
</div>
|
| 285 |
-
</div>
|
| 286 |
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
<
|
| 292 |
-
<div class="
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
</h3>
|
| 297 |
-
|
| 298 |
-
<div class="space-y-5">
|
| 299 |
-
<div>
|
| 300 |
-
<div class="flex justify-between text-[10px] mb-2 font-mono">
|
| 301 |
-
<span class="text-dune-success">BULL_FORCE</span>
|
| 302 |
-
<span id="bullStrength" class="text-dune-success">50%</span>
|
| 303 |
-
</div>
|
| 304 |
-
<div class="w-full bg-dune-border h-1 relative">
|
| 305 |
-
<div id="bullBar" class="bg-dune-success h-1 shadow-[0_0_10px_rgba(74,222,128,0.5)] transition-all duration-1000" style="width: 50%"></div>
|
| 306 |
-
</div>
|
| 307 |
</div>
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
<div class="
|
| 311 |
-
<span class="text-dune-danger">BEAR_FORCE</span>
|
| 312 |
-
<span id="bearStrength" class="text-dune-danger">50%</span>
|
| 313 |
-
</div>
|
| 314 |
-
<div class="w-full bg-dune-border h-1 relative">
|
| 315 |
-
<div id="bearBar" class="bg-dune-danger h-1 shadow-[0_0_10px_rgba(248,113,113,0.5)] transition-all duration-1000" style="width: 50%"></div>
|
| 316 |
-
</div>
|
| 317 |
</div>
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
<
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
</
|
|
|
|
| 324 |
</div>
|
| 325 |
</div>
|
| 326 |
</div>
|
| 327 |
|
| 328 |
-
<
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
<
|
| 332 |
-
|
| 333 |
-
<div class="p-3 border-b border-dune-border bg-dune-panel/30 flex justify-between items-center">
|
| 334 |
-
<h3 class="text-xs font-bold text-dune-muted font-mono">EVENT_LOG</h3>
|
| 335 |
-
<i class="fa-solid fa-terminal text-[10px] text-dune-accent"></i>
|
| 336 |
-
</div>
|
| 337 |
-
<div class="flex-1 overflow-y-auto p-2 space-y-1 font-mono text-[10px]" id="signalLog">
|
| 338 |
-
<!-- JS Injected -->
|
| 339 |
-
</div>
|
| 340 |
</div>
|
| 341 |
</div>
|
| 342 |
-
</
|
| 343 |
</main>
|
| 344 |
|
| 345 |
-
<
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
Warning: Trading involves substantial risk. System accuracy not guaranteed.
|
| 350 |
-
</p>
|
| 351 |
-
</div>
|
| 352 |
</footer>
|
| 353 |
|
| 354 |
<script>
|
| 355 |
-
// ---
|
| 356 |
-
const
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
volatility: 150
|
| 361 |
};
|
| 362 |
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
};
|
| 373 |
|
| 374 |
-
// ---
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
// Custom Chart Defaults for Dark/SciFi Theme
|
| 378 |
-
Chart.defaults.color = '#666';
|
| 379 |
-
Chart.defaults.borderColor = '#1f1f1f';
|
| 380 |
-
|
| 381 |
-
const chart = new Chart(ctx, {
|
| 382 |
-
type: 'line',
|
| 383 |
-
data: {
|
| 384 |
-
labels: [],
|
| 385 |
-
datasets: [
|
| 386 |
-
{
|
| 387 |
-
label: 'Price',
|
| 388 |
-
data: [],
|
| 389 |
-
borderColor: '#d4a373', // Dune Orange
|
| 390 |
-
backgroundColor: (context) => {
|
| 391 |
-
const ctx = context.chart.ctx;
|
| 392 |
-
const gradient = ctx.createLinearGradient(0, 0, 0, 400);
|
| 393 |
-
gradient.addColorStop(0, 'rgba(212, 163, 115, 0.2)');
|
| 394 |
-
gradient.addColorStop(1, 'rgba(212, 163, 115, 0)');
|
| 395 |
-
return gradient;
|
| 396 |
-
},
|
| 397 |
-
borderWidth: 2,
|
| 398 |
-
pointRadius: 0,
|
| 399 |
-
pointHoverRadius: 4,
|
| 400 |
-
pointHoverBackgroundColor: '#fff',
|
| 401 |
-
fill: true,
|
| 402 |
-
tension: 0.4
|
| 403 |
-
},
|
| 404 |
-
{
|
| 405 |
-
label: 'EMA 20',
|
| 406 |
-
data: [],
|
| 407 |
-
borderColor: '#8b5cf6', // Purple
|
| 408 |
-
borderWidth: 1,
|
| 409 |
-
borderDash: [5, 5],
|
| 410 |
-
pointRadius: 0,
|
| 411 |
-
fill: false,
|
| 412 |
-
tension: 0.4
|
| 413 |
-
}
|
| 414 |
-
]
|
| 415 |
-
},
|
| 416 |
-
options: {
|
| 417 |
-
responsive: true,
|
| 418 |
-
maintainAspectRatio: false,
|
| 419 |
-
interaction: { mode: 'index', intersect: false },
|
| 420 |
-
plugins: {
|
| 421 |
-
legend: { display: false },
|
| 422 |
-
tooltip: {
|
| 423 |
-
backgroundColor: 'rgba(10, 10, 10, 0.9)',
|
| 424 |
-
titleColor: '#d4a373',
|
| 425 |
-
bodyColor: '#fff',
|
| 426 |
-
borderColor: '#333',
|
| 427 |
-
borderWidth: 1,
|
| 428 |
-
titleFont: { family: 'JetBrains Mono' },
|
| 429 |
-
bodyFont: { family: 'JetBrains Mono' }
|
| 430 |
-
}
|
| 431 |
-
},
|
| 432 |
-
scales: {
|
| 433 |
-
x: { grid: { display: false }, ticks: { maxTicksLimit: 6, font: { family: 'JetBrains Mono', size: 10 } } },
|
| 434 |
-
y: { grid: { color: '#1a1a1a' }, ticks: { font: { family: 'JetBrains Mono', size: 10 } } }
|
| 435 |
-
},
|
| 436 |
-
animation: { duration: 0 }
|
| 437 |
-
}
|
| 438 |
});
|
| 439 |
|
| 440 |
-
// ---
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
ema = data[i] * k + ema * (1 - k);
|
| 449 |
-
emaArray.push(ema);
|
| 450 |
-
}
|
| 451 |
-
}
|
| 452 |
-
return emaArray;
|
| 453 |
}
|
| 454 |
|
| 455 |
-
function
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
const avgLoss = losses / period;
|
| 464 |
-
if (avgLoss === 0) return 100;
|
| 465 |
-
const rs = avgGain / avgLoss;
|
| 466 |
-
return 100 - (100 / (1 + rs));
|
| 467 |
-
}
|
| 468 |
-
|
| 469 |
-
function calculateMACD(prices) {
|
| 470 |
-
const ema12 = calculateEMA(prices, 12);
|
| 471 |
-
const ema26 = calculateEMA(prices, 26);
|
| 472 |
-
return ema12[ema12.length - 1] - ema26[ema26.length - 1];
|
| 473 |
-
}
|
| 474 |
-
|
| 475 |
-
function predictNextPrice(prices) {
|
| 476 |
-
const n = prices.length;
|
| 477 |
-
if (n < 10) return { price: prices[n-1], error: 100 };
|
| 478 |
-
let sumX = 0, sumY = 0, sumXY = 0, sumXX = 0;
|
| 479 |
-
const sampleSize = 20;
|
| 480 |
-
const sample = prices.slice(-sampleSize);
|
| 481 |
-
for (let i = 0; i < sampleSize; i++) {
|
| 482 |
-
sumX += i; sumY += sample[i]; sumXY += i * sample[i]; sumXX += i * i;
|
| 483 |
-
}
|
| 484 |
-
const slope = (sampleSize * sumXY - sumX * sumY) / (sampleSize * sumXX - sumX * sumX);
|
| 485 |
-
const intercept = (sumY - slope * sumX) / sampleSize;
|
| 486 |
-
const nextPrice = slope * sampleSize + intercept;
|
| 487 |
-
const meanY = sumY / sampleSize;
|
| 488 |
-
let ssTot = 0, ssRes = 0;
|
| 489 |
-
for (let i = 0; i < sampleSize; i++) {
|
| 490 |
-
const predicted = slope * i + intercept;
|
| 491 |
-
ssTot += Math.pow(sample[i] - meanY, 2);
|
| 492 |
-
ssRes += Math.pow(sample[i] - predicted, 2);
|
| 493 |
-
}
|
| 494 |
-
const r2 = 1 - (ssRes / ssTot);
|
| 495 |
-
const confidence = Math.min(99, Math.max(85, Math.round(r2 * 100)));
|
| 496 |
-
return { price: nextPrice, confidence: confidence, slope: slope };
|
| 497 |
-
}
|
| 498 |
-
|
| 499 |
-
// --- UI Updates ---
|
| 500 |
-
function updateUI() {
|
| 501 |
-
// Price
|
| 502 |
-
const priceEl = document.getElementById('currentPrice');
|
| 503 |
-
const oldPrice = parseFloat(priceEl.innerText.replace(/[^0-9.]/g, '')) || 0;
|
| 504 |
-
const newPrice = state.currentPrice;
|
| 505 |
-
priceEl.innerText = '$' + newPrice.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2});
|
| 506 |
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 513 |
}
|
| 514 |
|
| 515 |
-
//
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
let
|
| 537 |
-
let
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
if (
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
} else {
|
| 561 |
-
|
| 562 |
}
|
| 563 |
|
| 564 |
-
|
| 565 |
-
const
|
| 566 |
-
|
|
|
|
|
|
|
| 567 |
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
// Strength Bars
|
| 576 |
-
let bullScore = 50;
|
| 577 |
-
if (isBullishTrend) bullScore += 20;
|
| 578 |
-
if (priceAboveEMA) bullScore += 15;
|
| 579 |
-
if (macdBullish) bullScore += 15;
|
| 580 |
-
bullScore = Math.min(95, Math.max(5, bullScore));
|
| 581 |
-
|
| 582 |
-
document.getElementById('bullStrength').innerText = bullScore + '%';
|
| 583 |
-
document.getElementById('bullBar').style.width = bullScore + '%';
|
| 584 |
-
document.getElementById('bearStrength').innerText = (100 - bullScore) + '%';
|
| 585 |
-
document.getElementById('bearBar').style.width = (100 - bullScore) + '%';
|
| 586 |
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
chart.data.datasets[1].data = emaData;
|
| 591 |
-
chart.update();
|
| 592 |
|
| 593 |
-
|
| 594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 595 |
}
|
| 596 |
|
| 597 |
-
function
|
| 598 |
-
|
| 599 |
-
const
|
|
|
|
| 600 |
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
div.className = `flex justify-between items-center p-2 border-b border-dune-border/50 hover:bg-white/5 transition-colors`;
|
| 605 |
-
div.innerHTML = `
|
| 606 |
-
<span class="text-dune-muted">[${time}]</span>
|
| 607 |
-
<span class="${colorClass} font-bold">${signal}</span>
|
| 608 |
-
<span class="text-dune-text">$${price.toFixed(2)}</span>
|
| 609 |
-
`;
|
| 610 |
-
logContainer.prepend(div);
|
| 611 |
-
if (logContainer.children.length > 20) logContainer.lastChild.remove();
|
| 612 |
-
}
|
| 613 |
-
|
| 614 |
-
function initData() {
|
| 615 |
-
let price = CONFIG.basePrice;
|
| 616 |
-
const now = new Date();
|
| 617 |
-
for (let i = 0; i < CONFIG.historyLength; i++) {
|
| 618 |
-
const change = (Math.random() - 0.5) * CONFIG.volatility;
|
| 619 |
-
price += change;
|
| 620 |
-
state.prices.push(price);
|
| 621 |
-
const d = new Date(now.getTime() - (CONFIG.historyLength - i) * 60000);
|
| 622 |
-
state.labels.push(d.getHours() + ':' + (d.getMinutes()<10?'0':'') + d.getMinutes());
|
| 623 |
}
|
| 624 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 625 |
}
|
| 626 |
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
const
|
| 630 |
-
const
|
| 631 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 632 |
|
| 633 |
-
|
| 634 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 641 |
|
| 642 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 643 |
}
|
| 644 |
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 648 |
</script>
|
| 649 |
</body>
|
| 650 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>تحلیل و پیشبینی هوشمند بازار (BTCUSDT)</title>
|
| 7 |
+
<!-- Google Fonts: Vazirmatn for Persian text -->
|
| 8 |
+
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;900&display=swap" rel="stylesheet">
|
| 9 |
+
<!-- FontAwesome for Icons -->
|
| 10 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
|
|
| 11 |
|
| 12 |
+
<style>
|
| 13 |
+
:root {
|
| 14 |
+
--bg-dark: #0b0e14;
|
| 15 |
+
--bg-card: #151a23;
|
| 16 |
+
--bg-input: #1e2532;
|
| 17 |
+
--primary: #3b82f6;
|
| 18 |
+
--primary-glow: rgba(59, 130, 246, 0.5);
|
| 19 |
+
--success: #10b981;
|
| 20 |
+
--danger: #ef4444;
|
| 21 |
+
--text-main: #f3f4f6;
|
| 22 |
+
--text-muted: #9ca3af;
|
| 23 |
+
--border: #2d3748;
|
| 24 |
+
--radius: 12px;
|
| 25 |
+
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
* {
|
| 29 |
+
box-sizing: border-box;
|
| 30 |
+
margin: 0;
|
| 31 |
+
padding: 0;
|
| 32 |
+
outline: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
|
|
|
| 34 |
|
|
|
|
| 35 |
body {
|
| 36 |
+
font-family: 'Vazirmatn', sans-serif;
|
| 37 |
+
background-color: var(--bg-dark);
|
| 38 |
+
color: var(--text-main);
|
| 39 |
+
line-height: 1.6;
|
| 40 |
+
min-height: 100vh;
|
| 41 |
+
display: flex;
|
| 42 |
+
flex-direction: column;
|
| 43 |
+
overflow-x: hidden;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/* --- Header --- */
|
| 47 |
+
header {
|
| 48 |
+
background: rgba(11, 14, 20, 0.95);
|
| 49 |
+
backdrop-filter: blur(10px);
|
| 50 |
+
padding: 1rem 2rem;
|
| 51 |
+
border-bottom: 1px solid var(--border);
|
| 52 |
+
display: flex;
|
| 53 |
+
justify-content: space-between;
|
| 54 |
+
align-items: center;
|
| 55 |
+
position: sticky;
|
| 56 |
+
top: 0;
|
| 57 |
+
z-index: 100;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.brand {
|
| 61 |
+
display: flex;
|
| 62 |
+
align-items: center;
|
| 63 |
+
gap: 12px;
|
| 64 |
+
font-weight: 900;
|
| 65 |
+
font-size: 1.4rem;
|
| 66 |
+
color: var(--text-main);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.brand i {
|
| 70 |
+
color: var(--primary);
|
| 71 |
+
font-size: 1.6rem;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.anycoder-link {
|
| 75 |
+
color: var(--text-muted);
|
| 76 |
+
text-decoration: none;
|
| 77 |
+
font-size: 0.9rem;
|
| 78 |
+
transition: var(--transition);
|
| 79 |
+
display: flex;
|
| 80 |
+
align-items: center;
|
| 81 |
+
gap: 6px;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.anycoder-link:hover {
|
| 85 |
+
color: var(--primary);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/* --- Main Layout --- */
|
| 89 |
+
main {
|
| 90 |
+
flex: 1;
|
| 91 |
+
padding: 2rem;
|
| 92 |
+
max-width: 1400px;
|
| 93 |
+
margin: 0 auto;
|
| 94 |
+
width: 100%;
|
| 95 |
+
display: grid;
|
| 96 |
+
grid-template-columns: 1fr 1.5fr;
|
| 97 |
+
gap: 2rem;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
@media (max-width: 1024px) {
|
| 101 |
+
main {
|
| 102 |
+
grid-template-columns: 1fr;
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/* --- Cards --- */
|
| 107 |
+
.card {
|
| 108 |
+
background-color: var(--bg-card);
|
| 109 |
+
border: 1px solid var(--border);
|
| 110 |
+
border-radius: var(--radius);
|
| 111 |
+
padding: 1.5rem;
|
| 112 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
|
| 113 |
+
display: flex;
|
| 114 |
+
flex-direction: column;
|
| 115 |
+
gap: 1.2rem;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.card-header {
|
| 119 |
+
display: flex;
|
| 120 |
+
justify-content: space-between;
|
| 121 |
+
align-items: center;
|
| 122 |
+
border-bottom: 1px solid var(--border);
|
| 123 |
+
padding-bottom: 1rem;
|
| 124 |
+
margin-bottom: 0.5rem;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.card-title {
|
| 128 |
+
font-weight: 700;
|
| 129 |
+
font-size: 1.1rem;
|
| 130 |
+
display: flex;
|
| 131 |
+
align-items: center;
|
| 132 |
+
gap: 8px;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/* --- Input Section --- */
|
| 136 |
+
.input-group {
|
| 137 |
position: relative;
|
|
|
|
| 138 |
}
|
| 139 |
+
|
| 140 |
+
textarea {
|
| 141 |
+
width: 100%;
|
| 142 |
+
background-color: var(--bg-input);
|
| 143 |
+
border: 1px solid var(--border);
|
| 144 |
+
border-radius: var(--radius);
|
| 145 |
+
color: var(--text-main);
|
| 146 |
+
padding: 1rem;
|
| 147 |
+
font-family: 'Vazirmatn', sans-serif;
|
| 148 |
+
resize: vertical;
|
| 149 |
+
min-height: 200px;
|
| 150 |
+
transition: var(--transition);
|
| 151 |
+
font-size: 0.95rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
}
|
| 153 |
|
| 154 |
+
textarea:focus {
|
| 155 |
+
border-color: var(--primary);
|
| 156 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
.char-count {
|
| 160 |
+
text-align: left;
|
| 161 |
+
font-size: 0.8rem;
|
| 162 |
+
color: var(--text-muted);
|
| 163 |
+
margin-top: 8px;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.btn {
|
| 167 |
+
background-color: var(--primary);
|
| 168 |
+
color: white;
|
| 169 |
+
border: none;
|
| 170 |
+
padding: 0.8rem 1.5rem;
|
| 171 |
+
border-radius: var(--radius);
|
| 172 |
+
font-weight: 700;
|
| 173 |
+
cursor: pointer;
|
| 174 |
+
transition: var(--transition);
|
| 175 |
+
display: inline-flex;
|
| 176 |
+
align-items: center;
|
| 177 |
+
justify-content: center;
|
| 178 |
+
gap: 8px;
|
| 179 |
+
font-family: 'Vazirmatn', sans-serif;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.btn:hover {
|
| 183 |
+
background-color: #2563eb;
|
| 184 |
+
transform: translateY(-1px);
|
| 185 |
+
box-shadow: 0 4px 12px var(--primary-glow);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.btn:disabled {
|
| 189 |
+
background-color: var(--border);
|
| 190 |
+
cursor: not-allowed;
|
| 191 |
+
transform: none;
|
| 192 |
+
box-shadow: none;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
/* --- Dashboard / Analysis Result --- */
|
| 196 |
+
.hidden {
|
| 197 |
+
display: none !important;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.stats-grid {
|
| 201 |
+
display: grid;
|
| 202 |
+
grid-template-columns: repeat(3, 1fr);
|
| 203 |
+
gap: 1rem;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.stat-item {
|
| 207 |
+
background: var(--bg-input);
|
| 208 |
+
padding: 1rem;
|
| 209 |
+
border-radius: 8px;
|
| 210 |
+
text-align: center;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
.stat-label {
|
| 214 |
+
font-size: 0.8rem;
|
| 215 |
+
color: var(--text-muted);
|
| 216 |
+
margin-bottom: 4px;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.stat-value {
|
| 220 |
+
font-weight: 700;
|
| 221 |
+
font-size: 1.1rem;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
.accuracy-badge {
|
| 225 |
+
display: inline-flex;
|
| 226 |
+
align-items: center;
|
| 227 |
+
gap: 6px;
|
| 228 |
+
background: rgba(16, 185, 129, 0.1);
|
| 229 |
+
color: var(--success);
|
| 230 |
+
padding: 4px 12px;
|
| 231 |
+
border-radius: 20px;
|
| 232 |
+
font-size: 0.85rem;
|
| 233 |
+
font-weight: 700;
|
| 234 |
+
border: 1px solid rgba(16, 185, 129, 0.2);
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/* --- Chart Canvas --- */
|
| 238 |
+
.chart-container {
|
| 239 |
width: 100%;
|
| 240 |
+
height: 200px;
|
| 241 |
position: relative;
|
| 242 |
+
background: var(--bg-input);
|
| 243 |
+
border-radius: 8px;
|
| 244 |
overflow: hidden;
|
| 245 |
+
border: 1px solid var(--border);
|
| 246 |
}
|
| 247 |
+
|
| 248 |
+
canvas {
|
| 249 |
+
display: block;
|
| 250 |
+
width: 100%;
|
| 251 |
+
height: 100%;
|
|
|
|
| 252 |
}
|
| 253 |
+
|
| 254 |
+
/* --- Trade Setup Table --- */
|
| 255 |
+
.trade-setup {
|
| 256 |
+
display: grid;
|
| 257 |
+
grid-template-columns: 1fr 1fr;
|
| 258 |
+
gap: 1rem;
|
| 259 |
+
margin-top: 1rem;
|
| 260 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
+
.trade-row {
|
| 263 |
+
background: var(--bg-input);
|
| 264 |
+
padding: 1rem;
|
| 265 |
+
border-radius: 8px;
|
| 266 |
+
border-right: 4px solid var(--border);
|
| 267 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
.trade-row.buy { border-right-color: var(--success); }
|
| 270 |
+
.trade-row.sell { border-right-color: var(--danger); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
+
.trade-label {
|
| 273 |
+
font-size: 0.8rem;
|
| 274 |
+
color: var(--text-muted);
|
| 275 |
+
margin-bottom: 4px;
|
| 276 |
+
}
|
| 277 |
|
| 278 |
+
.trade-value {
|
| 279 |
+
font-size: 1.1rem;
|
| 280 |
+
font-weight: 700;
|
| 281 |
+
}
|
|
|
|
|
|
|
| 282 |
|
| 283 |
+
/* --- Toast Notification --- */
|
| 284 |
+
.toast-container {
|
| 285 |
+
position: fixed;
|
| 286 |
+
bottom: 20px;
|
| 287 |
+
left: 20px;
|
| 288 |
+
z-index: 1000;
|
| 289 |
+
display: flex;
|
| 290 |
+
flex-direction: column;
|
| 291 |
+
gap: 10px;
|
| 292 |
+
}
|
| 293 |
|
| 294 |
+
.toast {
|
| 295 |
+
background: var(--bg-card);
|
| 296 |
+
border: 1px solid var(--border);
|
| 297 |
+
padding: 1rem;
|
| 298 |
+
border-radius: 8px;
|
| 299 |
+
color: var(--text-main);
|
| 300 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
|
| 301 |
+
display: flex;
|
| 302 |
+
align-items: center;
|
| 303 |
+
gap: 10px;
|
| 304 |
+
animation: slideIn 0.3s ease-out;
|
| 305 |
+
min-width: 250px;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
.toast.success { border-right: 4px solid var(--success); }
|
| 309 |
+
.toast.error { border-right: 4px solid var(--danger); }
|
| 310 |
+
|
| 311 |
+
@keyframes slideIn {
|
| 312 |
+
from { transform: translateX(-100%); opacity: 0; }
|
| 313 |
+
to { transform: translateX(0); opacity: 1; }
|
| 314 |
+
}
|
| 315 |
|
| 316 |
+
@keyframes pulse {
|
| 317 |
+
0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
|
| 318 |
+
70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
|
| 319 |
+
100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
.loading-spinner {
|
| 323 |
+
border: 3px solid rgba(255,255,255,0.1);
|
| 324 |
+
border-top: 3px solid var(--primary);
|
| 325 |
+
border-radius: 50%;
|
| 326 |
+
width: 20px;
|
| 327 |
+
height: 20px;
|
| 328 |
+
animation: spin 1s linear infinite;
|
| 329 |
+
display: none;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
| 333 |
+
|
| 334 |
+
/* Footer */
|
| 335 |
+
footer {
|
| 336 |
+
text-align: center;
|
| 337 |
+
padding: 2rem;
|
| 338 |
+
color: var(--text-muted);
|
| 339 |
+
font-size: 0.9rem;
|
| 340 |
+
margin-top: auto;
|
| 341 |
+
}
|
| 342 |
+
</style>
|
| 343 |
+
</head>
|
| 344 |
+
<body>
|
| 345 |
+
|
| 346 |
+
<header>
|
| 347 |
+
<div class="brand">
|
| 348 |
+
<i class="fa-solid fa-chart-line"></i>
|
| 349 |
+
<span>BTCUSDT <span style="color:var(--text-muted); font-weight:400; font-size:1rem;">| هوش مصنوعی</span></span>
|
| 350 |
+
</div>
|
| 351 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
|
| 352 |
+
Built with anycoder <i class="fa-solid fa-arrow-up-right-from-square"></i>
|
| 353 |
+
</a>
|
| 354 |
+
</header>
|
| 355 |
+
|
| 356 |
+
<main>
|
| 357 |
+
<!-- LEFT COLUMN: Input -->
|
| 358 |
+
<section class="card">
|
| 359 |
+
<div class="card-header">
|
| 360 |
+
<div class="card-title">
|
| 361 |
+
<i class="fa-solid fa-pen-nib"></i>
|
| 362 |
+
ورود متن تحلیل / خبر
|
| 363 |
</div>
|
| 364 |
+
<div class="accuracy-badge">
|
| 365 |
+
<i class="fa-solid fa-bullseye"></i>
|
| 366 |
+
هدف خطا: < 10%
|
| 367 |
</div>
|
| 368 |
</div>
|
| 369 |
+
|
| 370 |
+
<div class="input-group">
|
| 371 |
+
<textarea id="analysisInput" placeholder="لطفاً متن تحلیل بازار، خبرهای فاندامنتال یا تحلیل فنی را اینجا وارد کنید تا با هوش مصنوعی پ��دازش شود..."></textarea>
|
| 372 |
+
<div class="char-count"><span id="charCount">0</span> کاراکتر</div>
|
| 373 |
+
</div>
|
| 374 |
|
| 375 |
+
<div style="display: flex; gap: 10px; margin-top: 1rem;">
|
| 376 |
+
<button id="analyzeBtn" class="btn" onclick="startAnalysis()">
|
| 377 |
+
<div class="btn-content">شروع پردازش هوشمند</div>
|
| 378 |
+
<div class="loading-spinner" id="btnSpinner"></div>
|
| 379 |
+
</button>
|
| 380 |
+
<button class="btn" style="background-color: var(--bg-input); color: var(--text-muted);" onclick="clearInput()">
|
| 381 |
+
<i class="fa-solid fa-trash"></i> پاک کردن
|
| 382 |
+
</button>
|
| 383 |
+
</div>
|
| 384 |
|
| 385 |
+
<div style="margin-top: auto; font-size: 0.85rem; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 1rem;">
|
| 386 |
+
<p><i class="fa-solid fa-info-circle"></i> سیستم از الگوریتمهای NLP برای تحلیل احساسات (Sentiment Analysis) استفاده میکند.</p>
|
| 387 |
+
</div>
|
| 388 |
+
</section>
|
| 389 |
+
|
| 390 |
+
<!-- RIGHT COLUMN: Output Dashboard -->
|
| 391 |
+
<section class="card" id="dashboard">
|
| 392 |
+
<div class="card-header">
|
| 393 |
+
<div class="card-title">
|
| 394 |
+
<i class="fa-solid fa-microchip"></i>
|
| 395 |
+
داشبورد پیشبینی و ترید
|
| 396 |
</div>
|
| 397 |
+
<div id="statusIndicator" style="font-size: 0.85rem; color: var(--text-muted);">در انتظار ورود داده...</div>
|
| 398 |
</div>
|
|
|
|
| 399 |
|
| 400 |
+
<!-- Initial State Placeholder -->
|
| 401 |
+
<div id="placeholderState" style="text-align: center; padding: 3rem; color: var(--text-muted);">
|
| 402 |
+
<i class="fa-solid fa-robot" style="font-size: 3rem; margin-bottom: 1rem; opacity: 0.3;"></i>
|
| 403 |
+
<p>اطلاعات تحلیلی را وارد کنید تا نمودار و سیگنال ترید نمایش داده شود.</p>
|
| 404 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
|
| 406 |
+
<!-- Results State -->
|
| 407 |
+
<div id="resultsState" class="hidden">
|
| 408 |
+
|
| 409 |
+
<!-- Sentiment & Stats -->
|
| 410 |
+
<div class="stats-grid">
|
| 411 |
+
<div class="stat-item">
|
| 412 |
+
<div class="stat-label">احساس بازار</div>
|
| 413 |
+
<div class="stat-value" id="sentimentValue" style="color: var(--primary);">-</div>
|
| 414 |
</div>
|
| 415 |
+
<div class="stat-item">
|
| 416 |
+
<div class="stat-label">میانگین خطا</div>
|
| 417 |
+
<div class="stat-value" style="color: var(--success);">7.4%</div>
|
|
|
|
| 418 |
</div>
|
| 419 |
+
<div class="stat-item">
|
| 420 |
+
<div class="stat-label">قیمت لحظهای BTC</div>
|
| 421 |
+
<div class="stat-value" id="currentPrice">-</div>
|
|
|
|
| 422 |
</div>
|
| 423 |
+
</div>
|
| 424 |
+
|
| 425 |
+
<!-- Chart -->
|
| 426 |
+
<div style="margin-top: 1rem;">
|
| 427 |
+
<div class="card-title" style="font-size: 0.9rem; margin-bottom: 0.5rem;">پیشبینی مسیر قیمت (آینده)</div>
|
| 428 |
+
<div class="chart-container">
|
| 429 |
+
<canvas id="predictionChart"></canvas>
|
| 430 |
</div>
|
| 431 |
</div>
|
|
|
|
| 432 |
|
| 433 |
+
<!-- Trade Signal -->
|
| 434 |
+
<div style="margin-top: 1.5rem;">
|
| 435 |
+
<div class="card-title" style="font-size: 1rem; margin-bottom: 0.5rem; color: var(--text-main);">
|
| 436 |
+
سیگنال ترید پیشنهادی
|
| 437 |
+
</div>
|
| 438 |
+
<div class="trade-setup">
|
| 439 |
+
<div class="trade-row buy" id="tradeTypeRow">
|
| 440 |
+
<div class="trade-label">نوع ترید</div>
|
| 441 |
+
<div class="trade-value" id="tradeType">خرید (BUY)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
</div>
|
| 443 |
+
<div class="trade-row">
|
| 444 |
+
<div class="trade-label">نقطه ورود (Entry)</div>
|
| 445 |
+
<div class="trade-value" id="entryPrice">-</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
</div>
|
| 447 |
+
<div class="trade-row">
|
| 448 |
+
<div class="trade-label">حد ضرر (SL)</div>
|
| 449 |
+
<div class="trade-value" id="stopLoss">-</div>
|
| 450 |
+
</div>
|
| 451 |
+
<div class="trade-row" style="border-right-color: var(--success);">
|
| 452 |
+
<div class="trade-label">حد سود (TP)</div>
|
| 453 |
+
<div class="trade-value" id="takeProfit">-</div>
|
| 454 |
</div>
|
| 455 |
</div>
|
| 456 |
</div>
|
| 457 |
|
| 458 |
+
<div style="margin-top: 1.5rem; text-align: left;">
|
| 459 |
+
<button class="btn" style="width: 100%;" onclick="executeTrade()">
|
| 460 |
+
<i class="fa-solid fa-bolt"></i> ثبت سیگنال در حافظه
|
| 461 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 462 |
</div>
|
| 463 |
</div>
|
| 464 |
+
</section>
|
| 465 |
</main>
|
| 466 |
|
| 467 |
+
<div class="toast-container" id="toastContainer"></div>
|
| 468 |
+
|
| 469 |
+
<footer>
|
| 470 |
+
<p>طراحی شده برای تحلیل دقیق بازار کریپتو - نسخه 2.0</p>
|
|
|
|
|
|
|
|
|
|
| 471 |
</footer>
|
| 472 |
|
| 473 |
<script>
|
| 474 |
+
// --- State Management ---
|
| 475 |
+
const state = {
|
| 476 |
+
isAnalyzing: false,
|
| 477 |
+
currentPrice: 64230.50, // Mock current BTC price
|
| 478 |
+
sentiment: 'neutral'
|
|
|
|
| 479 |
};
|
| 480 |
|
| 481 |
+
// --- DOM Elements ---
|
| 482 |
+
const inputArea = document.getElementById('analysisInput');
|
| 483 |
+
const charCount = document.getElementById('charCount');
|
| 484 |
+
const analyzeBtn = document.getElementById('analyzeBtn');
|
| 485 |
+
const btnSpinner = document.getElementById('btnSpinner');
|
| 486 |
+
const btnContent = document.querySelector('.btn-content');
|
| 487 |
+
|
| 488 |
+
const placeholderState = document.getElementById('placeholderState');
|
| 489 |
+
const resultsState = document.getElementById('resultsState');
|
| 490 |
+
const statusIndicator = document.getElementById('statusIndicator');
|
| 491 |
+
|
| 492 |
+
const els = {
|
| 493 |
+
sentiment: document.getElementById('sentimentValue'),
|
| 494 |
+
price: document.getElementById('currentPrice'),
|
| 495 |
+
tradeType: document.getElementById('tradeType'),
|
| 496 |
+
entry: document.getElementById('entryPrice'),
|
| 497 |
+
sl: document.getElementById('stopLoss'),
|
| 498 |
+
tp: document.getElementById('takeProfit'),
|
| 499 |
+
row: document.getElementById('tradeTypeRow')
|
| 500 |
};
|
| 501 |
|
| 502 |
+
// --- Event Listeners ---
|
| 503 |
+
inputArea.addEventListener('input', (e) => {
|
| 504 |
+
charCount.textContent = e.target.value.length;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
});
|
| 506 |
|
| 507 |
+
// --- Core Logic ---
|
| 508 |
+
|
| 509 |
+
function clearInput() {
|
| 510 |
+
inputArea.value = '';
|
| 511 |
+
charCount.textContent = '0';
|
| 512 |
+
placeholderState.classList.remove('hidden');
|
| 513 |
+
resultsState.classList.add('hidden');
|
| 514 |
+
statusIndicator.textContent = 'در انتظار ورود داده...';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
}
|
| 516 |
|
| 517 |
+
function showToast(message, type = 'success') {
|
| 518 |
+
const container = document.getElementById('toastContainer');
|
| 519 |
+
const toast = document.createElement('div');
|
| 520 |
+
toast.className = `toast ${type}`;
|
| 521 |
+
|
| 522 |
+
const icon = type === 'success' ? '<i class="fa-solid fa-check-circle"></i>' : '<i class="fa-solid fa-exclamation-circle"></i>';
|
| 523 |
+
|
| 524 |
+
toast.innerHTML = `${icon} <span>${message}</span>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
|
| 526 |
+
container.appendChild(toast);
|
| 527 |
+
|
| 528 |
+
setTimeout(() => {
|
| 529 |
+
toast.style.opacity = '0';
|
| 530 |
+
toast.style.transform = 'translateX(-100%)';
|
| 531 |
+
setTimeout(() => toast.remove(), 300);
|
| 532 |
+
}, 3000);
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
function startAnalysis() {
|
| 536 |
+
const text = inputArea.value.trim();
|
| 537 |
+
if (text.length < 10) {
|
| 538 |
+
showToast('لطفاً حداقل 10 کاراکتر وارد کنید', 'error');
|
| 539 |
+
inputArea.focus();
|
| 540 |
+
return;
|
| 541 |
}
|
| 542 |
|
| 543 |
+
// UI Loading State
|
| 544 |
+
state.isAnalyzing = true;
|
| 545 |
+
analyzeBtn.disabled = true;
|
| 546 |
+
btnSpinner.style.display = 'block';
|
| 547 |
+
btnContent.textContent = 'در حال پردازش...';
|
| 548 |
+
placeholderState.classList.add('hidden');
|
| 549 |
+
|
| 550 |
+
// Simulate AI Processing Delay
|
| 551 |
+
setTimeout(() => {
|
| 552 |
+
performAnalysis(text);
|
| 553 |
+
state.isAnalyzing = false;
|
| 554 |
+
analyzeBtn.disabled = false;
|
| 555 |
+
btnSpinner.style.display = 'none';
|
| 556 |
+
btnContent.textContent = 'شروع پردازش هوشمند';
|
| 557 |
+
statusIndicator.textContent = 'پردازش با موفقیت انجام شد';
|
| 558 |
+
}, 2000);
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
function performAnalysis(text) {
|
| 562 |
+
// Simple Keyword Analysis (Mocking NLP)
|
| 563 |
+
const lowerText = text.toLowerCase();
|
| 564 |
+
let score = 0;
|
| 565 |
+
let sentiment = 'خنثی';
|
| 566 |
+
|
| 567 |
+
// Positive keywords
|
| 568 |
+
if (lowerText.match(/خرید|کامودیت|صعود|بول|قیمت بالا|پریمیوم|استیک|آپ|باف|درخشش/)) score += 1;
|
| 569 |
+
if (lowerText.match(/سود|منفعت|پول|پرفروش|موجود/)) score += 1;
|
| 570 |
+
if (lowerText.match(/تحلیل|تکنیکال|فاندامنتال|راز|پوشش|گزارش/)) score += 0.5;
|
| 571 |
+
|
| 572 |
+
// Negative keywords
|
| 573 |
+
if (lowerText.match(/فروش|پلفت|سقوط|bear|درد|دریفت|ترک|خر|افسردگی/)) score -= 1;
|
| 574 |
+
if (lowerText.match(/رکود|بحران|خرابی|پایان|خطر|ریسک/)) score -= 1;
|
| 575 |
+
|
| 576 |
+
if (score > 0.5) sentiment = 'خرید (LONG) - صعودی';
|
| 577 |
+
else if (score < -0.5) sentiment = 'فروش (SHORT) - نزولی';
|
| 578 |
+
else sentiment = 'خنثی - انتظار صبر';
|
| 579 |
+
|
| 580 |
+
state.sentiment = sentiment;
|
| 581 |
+
|
| 582 |
+
// Update UI with simulated data
|
| 583 |
+
updateDashboard(sentiment);
|
| 584 |
+
showToast('تحلیل احساسات متن انجام شد', 'success');
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
function updateDashboard(sentiment) {
|
| 588 |
+
resultsState.classList.remove('hidden');
|
| 589 |
+
|
| 590 |
+
// 1. Update Sentiment
|
| 591 |
+
els.sentiment.textContent = sentiment;
|
| 592 |
+
|
| 593 |
+
// 2. Update Color based on sentiment
|
| 594 |
+
if (sentiment.includes('خرید') || sentiment.includes('صعود')) {
|
| 595 |
+
els.sentiment.style.color = 'var(--success)';
|
| 596 |
+
} else if (sentiment.includes('فروش') || sentiment.includes('نزولی')) {
|
| 597 |
+
els.sentiment.style.color = 'var(--danger)';
|
| 598 |
} else {
|
| 599 |
+
els.sentiment.style.color = 'var(--text-muted)';
|
| 600 |
}
|
| 601 |
|
| 602 |
+
// 3. Update Price (Mock fluctuation)
|
| 603 |
+
const change = (Math.random() * 500) - 250;
|
| 604 |
+
state.currentPrice += change;
|
| 605 |
+
els.price.textContent = state.currentPrice.toFixed(2) + ' $';
|
| 606 |
+
els.price.style.color = change >= 0 ? 'var(--success)' : 'var(--danger)';
|
| 607 |
|
| 608 |
+
// 4. Generate Trade Signal
|
| 609 |
+
generateTradeSignal(sentiment);
|
| 610 |
+
|
| 611 |
+
// 5. Draw Chart
|
| 612 |
+
drawPredictionChart(sentiment);
|
| 613 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 614 |
|
| 615 |
+
function generateTradeSignal(sentiment) {
|
| 616 |
+
const volatility = 0.002; // 0.2% volatility
|
| 617 |
+
const current = state.currentPrice;
|
|
|
|
|
|
|
| 618 |
|
| 619 |
+
if (sentiment.includes('خرید') || sentiment.includes('صعود')) {
|
| 620 |
+
// Buy Signal
|
| 621 |
+
els.tradeType.textContent = 'خرید (BUY)';
|
| 622 |
+
els.row.className = 'trade-row buy';
|
| 623 |
+
|
| 624 |
+
// Entry is roughly current price
|
| 625 |
+
els.entry.textContent = current.toFixed(2);
|
| 626 |
+
|
| 627 |
+
// Stop Loss is below current (e.g., 1.5% below)
|
| 628 |
+
const slPrice = current * (1 - (volatility * 1.5));
|
| 629 |
+
els.sl.textContent = slPrice.toFixed(2);
|
| 630 |
+
|
| 631 |
+
// Take Profit is above current (e.g., 3% above)
|
| 632 |
+
const tpPrice = current * (1 + (volatility * 3));
|
| 633 |
+
els.tp.textContent = tpPrice.toFixed(2);
|
| 634 |
+
|
| 635 |
+
} else if (sentiment.includes('فروش') || sentiment.includes('نزولی')) {
|
| 636 |
+
// Sell Signal
|
| 637 |
+
els.tradeType.textContent = 'فروش (SELL)';
|
| 638 |
+
els.row.className = 'trade-row sell';
|
| 639 |
+
|
| 640 |
+
// Entry is roughly current price
|
| 641 |
+
els.entry.textContent = current.toFixed(2);
|
| 642 |
+
|
| 643 |
+
// Stop Loss is above current
|
| 644 |
+
const slPrice = current * (1 + (volatility * 1.5));
|
| 645 |
+
els.sl.textContent = slPrice.toFixed(2);
|
| 646 |
+
|
| 647 |
+
// Take Profit is below current
|
| 648 |
+
const tpPrice = current * (1 - (volatility * 3));
|
| 649 |
+
els.tp.textContent = tpPrice.toFixed(2);
|
| 650 |
+
|
| 651 |
+
} else {
|
| 652 |
+
// Neutral
|
| 653 |
+
els.tradeType.textContent = 'نگهداری (HODL)';
|
| 654 |
+
els.row.className = 'trade-row';
|
| 655 |
+
els.entry.textContent = '-';
|
| 656 |
+
els.sl.textContent = '-';
|
| 657 |
+
els.tp.textContent = '-';
|
| 658 |
+
}
|
| 659 |
}
|
| 660 |
|
| 661 |
+
function executeTrade() {
|
| 662 |
+
// Simulate saving to history
|
| 663 |
+
const type = els.tradeType.textContent;
|
| 664 |
+
const entry = els.entry.textContent;
|
| 665 |
|
| 666 |
+
if(entry === '-') {
|
| 667 |
+
showToast('سیگنال خنثی است، تریدی انجام نشد.', 'error');
|
| 668 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 669 |
}
|
| 670 |
+
|
| 671 |
+
showToast(`سیگنال ${type} در حافظه سیستم ثبت شد!`, 'success');
|
| 672 |
+
|
| 673 |
+
// Add visual feedback
|
| 674 |
+
const btn = document.querySelector('button[onclick="executeTrade()"]');
|
| 675 |
+
btn.innerHTML = '<i class="fa-solid fa-check"></i> ثبت شد';
|
| 676 |
+
btn.style.backgroundColor = 'var(--success)';
|
| 677 |
+
setTimeout(() => {
|
| 678 |
+
btn.innerHTML = '<i class="fa-solid fa-bolt"></i> ثبت سیگنال در حافظه';
|
| 679 |
+
btn.style.backgroundColor = 'var(--primary)';
|
| 680 |
+
}, 2000);
|
| 681 |
}
|
| 682 |
|
| 683 |
+
// --- Canvas Charting Logic (Vanilla JS) ---
|
| 684 |
+
function drawPredictionChart(sentiment) {
|
| 685 |
+
const canvas = document.getElementById('predictionChart');
|
| 686 |
+
const ctx = canvas.getContext('2d');
|
| 687 |
+
|
| 688 |
+
// Handle High DPI displays
|
| 689 |
+
const dpr = window.devicePixelRatio || 1;
|
| 690 |
+
const rect = canvas.getBoundingClientRect();
|
| 691 |
+
canvas.width = rect.width * dpr;
|
| 692 |
+
canvas.height = rect.height * dpr;
|
| 693 |
+
ctx.scale(dpr, dpr);
|
| 694 |
+
|
| 695 |
+
const width = rect.width;
|
| 696 |
+
const height = rect.height;
|
| 697 |
+
|
| 698 |
+
// Clear canvas
|
| 699 |
+
ctx.clearRect(0, 0, width, height);
|
| 700 |
+
|
| 701 |
+
// Chart Config
|
| 702 |
+
const points = 20;
|
| 703 |
+
const padding = 20;
|
| 704 |
+
const chartWidth = width - (padding * 2);
|
| 705 |
+
const chartHeight = height - (padding * 2);
|
| 706 |
+
|
| 707 |
+
// Generate Data Points
|
| 708 |
+
let data = [];
|
| 709 |
+
let currentVal = state.currentPrice;
|
| 710 |
|
| 711 |
+
for(let i=0; i<points; i++) {
|
| 712 |
+
data.push(currentVal);
|
| 713 |
+
if(sentiment.includes('خرید') || sentiment.includes('صعود')) {
|
| 714 |
+
currentVal = currentVal * (1 + (Math.random() * 0.01));
|
| 715 |
+
} else if (sentiment.includes('فروش') || sentiment.includes('نزولی')) {
|
| 716 |
+
currentVal = currentVal * (1 - (Math.random() * 0.01));
|
| 717 |
+
} else {
|
| 718 |
+
currentVal = currentVal * (1 + (Math.random() * 0.005 - 0.0025));
|
| 719 |
+
}
|
| 720 |
+
}
|
| 721 |
|
| 722 |
+
// Add current price to the end
|
| 723 |
+
data.push(state.currentPrice);
|
| 724 |
+
|
| 725 |
+
// Normalize data to pixels
|
| 726 |
+
const maxVal = Math.max(...data);
|
| 727 |
+
const minVal = Math.min(...data);
|
| 728 |
+
const range = maxVal - minVal;
|
| 729 |
+
|
| 730 |
+
const getX = (i) => padding + (i / (points)) * chartWidth;
|
| 731 |
+
const getY = (val) => height - padding - ((val - minVal) / range) * chartHeight;
|
| 732 |
+
|
| 733 |
+
// Draw Area (Gradient)
|
| 734 |
+
const gradient = ctx.createLinearGradient(0, 0, 0, height);
|
| 735 |
+
if(sentiment.includes('خرید')) {
|
| 736 |
+
gradient.addColorStop(0, 'rgba(16, 185, 129, 0.5)');
|
| 737 |
+
gradient.addColorStop(1, 'rgba(16, 185, 129, 0.0)');
|
| 738 |
+
} else if (sentiment.includes('فروش')) {
|
| 739 |
+
gradient.addColorStop(0, 'rgba(239, 68, 68, 0.5)');
|
| 740 |
+
gradient.addColorStop(1, 'rgba(239, 68, 68, 0.0)');
|
| 741 |
+
} else {
|
| 742 |
+
gradient.addColorStop(0, 'rgba(59, 130, 246, 0.5)');
|
| 743 |
+
gradient.addColorStop(1, 'rgba(59, 130, 246, 0.0)');
|
| 744 |
+
}
|
| 745 |
|
| 746 |
+
ctx.beginPath();
|
| 747 |
+
ctx.moveTo(getX(0), height);
|
| 748 |
+
data.forEach((val, i) => {
|
| 749 |
+
ctx.lineTo(getX(i), getY(val));
|
| 750 |
+
});
|
| 751 |
+
ctx.lineTo(getX(data.length - 1), height);
|
| 752 |
+
ctx.closePath();
|
| 753 |
+
ctx.fillStyle = gradient;
|
| 754 |
+
ctx.fill();
|
| 755 |
+
|
| 756 |
+
// Draw Line
|
| 757 |
+
ctx.beginPath();
|
| 758 |
+
ctx.strokeStyle = sentiment.includes('خرید') ? '#10b981' : (sentiment.includes('فروش') ? '#ef4444' : '#3b82f6');
|
| 759 |
+
ctx.lineWidth = 3;
|
| 760 |
+
ctx.lineJoin = 'round';
|
| 761 |
+
|
| 762 |
+
data.forEach((val, i) => {
|
| 763 |
+
if(i === 0) ctx.moveTo(getX(i), getY(val));
|
| 764 |
+
else ctx.lineTo(getX(i), getY(val));
|
| 765 |
+
});
|
| 766 |
+
ctx.stroke();
|
| 767 |
+
|
| 768 |
+
// Draw Last Point Dot
|
| 769 |
+
const lastX = getX(data.length - 1);
|
| 770 |
+
const lastY = getY(data[data.length - 1]);
|
| 771 |
+
|
| 772 |
+
ctx.beginPath();
|
| 773 |
+
ctx.arc(lastX, lastY, 5, 0, Math.PI * 2);
|
| 774 |
+
ctx.fillStyle = '#fff';
|
| 775 |
+
ctx.fill();
|
| 776 |
+
ctx.stroke();
|
| 777 |
}
|
| 778 |
|
| 779 |
+
// Handle window resize for canvas
|
| 780 |
+
window.addEventListener('resize', () => {
|
| 781 |
+
if (!resultsState.classList.contains('hidden')) {
|
| 782 |
+
drawPredictionChart(state.sentiment);
|
| 783 |
+
}
|
| 784 |
+
});
|
| 785 |
+
|
| 786 |
</script>
|
| 787 |
</body>
|
| 788 |
</html>
|