Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +238 -285
index.html
CHANGED
|
@@ -7,6 +7,7 @@
|
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
| 10 |
<script>
|
| 11 |
tailwind.config = {
|
| 12 |
darkMode: 'class',
|
|
@@ -54,7 +55,6 @@
|
|
| 54 |
</div>
|
| 55 |
<h1 class="text-2xl font-bold text-gray-800 dark:text-white">Nakhoda4X <span class="text-primary">Pro</span></h1>
|
| 56 |
</div>
|
| 57 |
-
|
| 58 |
<div class="flex items-center space-x-6">
|
| 59 |
<button id="theme-toggle" class="text-gray-600 dark:text-gray-300">
|
| 60 |
<i class="fas fa-moon dark:hidden"></i>
|
|
@@ -86,7 +86,7 @@
|
|
| 86 |
<p class="text-gray-500 mt-1 dark:text-gray-400">Connected to BingX via API</p>
|
| 87 |
</div>
|
| 88 |
<div class="flex space-x-4">
|
| 89 |
-
<button class="px-4 py-2 bg-white dark:bg-darkCard rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 flex items-center">
|
| 90 |
<i class="fas fa-sync mr-2"></i> Refresh
|
| 91 |
</button>
|
| 92 |
<button class="px-4 py-2 bg-primary text-white rounded-lg flex items-center">
|
|
@@ -101,65 +101,62 @@
|
|
| 101 |
<div class="flex justify-between">
|
| 102 |
<div>
|
| 103 |
<p class="text-gray-500 dark:text-gray-400">Total Balance</p>
|
| 104 |
-
<h3 class="text-2xl font-bold mt-2 dark:text-white">$
|
| 105 |
</div>
|
| 106 |
<div class="w-12 h-12 rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center">
|
| 107 |
<i class="fas fa-wallet text-blue-500 text-xl"></i>
|
| 108 |
</div>
|
| 109 |
</div>
|
| 110 |
-
<div class="mt-4 flex items-center text-green-500">
|
| 111 |
<i class="fas fa-caret-up mr-1"></i>
|
| 112 |
-
<span class="font-medium">
|
| 113 |
<span class="text-gray-500 ml-2 dark:text-gray-400">last 24h</span>
|
| 114 |
</div>
|
| 115 |
</div>
|
| 116 |
-
|
| 117 |
<div class="trading-card bg-white dark:bg-darkCard rounded-2xl shadow-md p-6 transition-all duration-300">
|
| 118 |
<div class="flex justify-between">
|
| 119 |
<div>
|
| 120 |
<p class="text-gray-500 dark:text-gray-400">Open Trades</p>
|
| 121 |
-
<h3 class="text-2xl font-bold mt-2 dark:text-white">
|
| 122 |
</div>
|
| 123 |
<div class="w-12 h-12 rounded-xl bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center">
|
| 124 |
<i class="fas fa-exchange-alt text-purple-500 text-xl"></i>
|
| 125 |
</div>
|
| 126 |
</div>
|
| 127 |
-
<div class="mt-4 flex items-center text-blue-500">
|
| 128 |
-
<span class="font-medium">
|
| 129 |
<span class="text-gray-500 mx-2 dark:text-gray-400">β’</span>
|
| 130 |
-
<span class="font-medium">
|
| 131 |
</div>
|
| 132 |
</div>
|
| 133 |
-
|
| 134 |
<div class="trading-card bg-white dark:bg-darkCard rounded-2xl shadow-md p-6 transition-all duration-300">
|
| 135 |
<div class="flex justify-between">
|
| 136 |
<div>
|
| 137 |
<p class="text-gray-500 dark:text-gray-400">Today's Profit</p>
|
| 138 |
-
<h3 class="text-2xl font-bold mt-2 dark:text-white">$
|
| 139 |
</div>
|
| 140 |
<div class="w-12 h-12 rounded-xl bg-green-100 dark:bg-green-900/30 flex items-center justify-center">
|
| 141 |
<i class="fas fa-chart-bar text-green-500 text-xl"></i>
|
| 142 |
</div>
|
| 143 |
</div>
|
| 144 |
-
<div class="mt-4 flex items-center text-green-500">
|
| 145 |
<i class="fas fa-caret-up mr-1"></i>
|
| 146 |
-
<span class="font-medium">
|
| 147 |
<span class="text-gray-500 ml-2 dark:text-gray-400">vs yesterday</span>
|
| 148 |
</div>
|
| 149 |
</div>
|
| 150 |
-
|
| 151 |
<div class="trading-card bg-white dark:bg-darkCard rounded-2xl shadow-md p-6 transition-all duration-300">
|
| 152 |
<div class="flex justify-between">
|
| 153 |
<div>
|
| 154 |
<p class="text-gray-500 dark:text-gray-400">Risk Exposure</p>
|
| 155 |
-
<h3 class="text-2xl font-bold mt-2 dark:text-white">
|
| 156 |
</div>
|
| 157 |
<div class="w-12 h-12 rounded-xl bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center">
|
| 158 |
<i class="fas fa-exclamation-triangle text-yellow-500 text-xl"></i>
|
| 159 |
</div>
|
| 160 |
</div>
|
| 161 |
-
<div class="mt-4 flex items-center text-gray-500 dark:text-gray-400">
|
| 162 |
-
<span class="font-medium">
|
| 163 |
<span class="ml-2">of balance</span>
|
| 164 |
</div>
|
| 165 |
</div>
|
|
@@ -167,7 +164,6 @@
|
|
| 167 |
|
| 168 |
<!-- Charts and Statistics Section -->
|
| 169 |
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
|
| 170 |
-
<!-- Monthly Performance -->
|
| 171 |
<div class="lg:col-span-2 bg-white dark:bg-darkCard rounded-2xl shadow-md p-6">
|
| 172 |
<div class="flex justify-between items-center mb-6">
|
| 173 |
<h3 class="text-lg font-bold text-gray-800 dark:text-white">Monthly Performance</h3>
|
|
@@ -180,56 +176,10 @@
|
|
| 180 |
</div>
|
| 181 |
<canvas id="performanceChart"></canvas>
|
| 182 |
</div>
|
| 183 |
-
|
| 184 |
-
<!-- Advanced Stats -->
|
| 185 |
<div class="bg-white dark:bg-darkCard rounded-2xl shadow-md p-6">
|
| 186 |
<h3 class="text-lg font-bold text-gray-800 dark:text-white mb-6">Advanced Statistics</h3>
|
| 187 |
-
<div class="space-y-5">
|
| 188 |
-
|
| 189 |
-
<div class="flex justify-between mb-1">
|
| 190 |
-
<span class="text-gray-500 dark:text-gray-400">Profit Factor</span>
|
| 191 |
-
<span class="font-bold text-green-500">2.75</span>
|
| 192 |
-
</div>
|
| 193 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 194 |
-
<div class="bg-green-600 h-2 rounded-full" style="width: 75%"></div>
|
| 195 |
-
</div>
|
| 196 |
-
</div>
|
| 197 |
-
<div>
|
| 198 |
-
<div class="flex justify-between mb-1">
|
| 199 |
-
<span class="text-gray-500 dark:text-gray-400">Sharpe Ratio</span>
|
| 200 |
-
<span class="font-bold text-blue-500">1.92</span>
|
| 201 |
-
</div>
|
| 202 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 203 |
-
<div class="bg-blue-600 h-2 rounded-full" style="width: 64%"></div>
|
| 204 |
-
</div>
|
| 205 |
-
</div>
|
| 206 |
-
<div>
|
| 207 |
-
<div class="flex justify-between mb-1">
|
| 208 |
-
<span class="text-gray-500 dark:text-gray-400">Win Rate</span>
|
| 209 |
-
<span class="font-bold text-purple-500">63.4%</span>
|
| 210 |
-
</div>
|
| 211 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 212 |
-
<div class="bg-purple-600 h-2 rounded-full" style="width: 63%"></div>
|
| 213 |
-
</div>
|
| 214 |
-
</div>
|
| 215 |
-
<div>
|
| 216 |
-
<div class="flex justify-between mb-1">
|
| 217 |
-
<span class="text-gray-500 dark:text-gray-400">Max Drawdown</span>
|
| 218 |
-
<span class="font-bold text-yellow-500">-12.3%</span>
|
| 219 |
-
</div>
|
| 220 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 221 |
-
<div class="bg-yellow-600 h-2 rounded-full" style="width: 34%"></div>
|
| 222 |
-
</div>
|
| 223 |
-
</div>
|
| 224 |
-
<div>
|
| 225 |
-
<div class="flex justify-between mb-1">
|
| 226 |
-
<span class="text-gray-500 dark:text-gray-400">Risk/Reward Ratio</span>
|
| 227 |
-
<span class="font-bold text-primary">1:2.8</span>
|
| 228 |
-
</div>
|
| 229 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 230 |
-
<div class="bg-primary h-2 rounded-full" style="width: 82%"></div>
|
| 231 |
-
</div>
|
| 232 |
-
</div>
|
| 233 |
</div>
|
| 234 |
</div>
|
| 235 |
</div>
|
|
@@ -244,7 +194,6 @@
|
|
| 244 |
<button class="px-3 py-1 rounded-lg text-sm bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-white">Closed</button>
|
| 245 |
</div>
|
| 246 |
</div>
|
| 247 |
-
|
| 248 |
<div class="overflow-x-auto">
|
| 249 |
<table class="w-full">
|
| 250 |
<thead>
|
|
@@ -259,99 +208,8 @@
|
|
| 259 |
<th class="pb-4"></th>
|
| 260 |
</tr>
|
| 261 |
</thead>
|
| 262 |
-
<tbody class="text-sm">
|
| 263 |
-
|
| 264 |
-
<td class="py-4">
|
| 265 |
-
<div class="flex items-center">
|
| 266 |
-
<img src="https://cryptologos.cc/logos/bitcoin-btc-logo.png?v=029" class="h-6 w-6 mr-2" alt="Bitcoin">
|
| 267 |
-
BTC/USDT
|
| 268 |
-
</div>
|
| 269 |
-
</td>
|
| 270 |
-
<td class="py-4">
|
| 271 |
-
<span class="px-2 py-1 rounded bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300">Long</span>
|
| 272 |
-
</td>
|
| 273 |
-
<td class="py-4">0.85</td>
|
| 274 |
-
<td class="py-4">$42,156.30</td>
|
| 275 |
-
<td class="py-4 font-medium">$43,287.15</td>
|
| 276 |
-
<td class="py-4 font-bold text-green-500">+$961.22</td>
|
| 277 |
-
<td class="py-4">
|
| 278 |
-
<span class="px-2 py-1 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300">Open</span>
|
| 279 |
-
</td>
|
| 280 |
-
<td class="py-4 text-right">
|
| 281 |
-
<button class="text-gray-400 hover:text-primary">
|
| 282 |
-
<i class="fas fa-ellipsis-v"></i>
|
| 283 |
-
</button>
|
| 284 |
-
</td>
|
| 285 |
-
</tr>
|
| 286 |
-
<tr class="border-b border-gray-200 dark:border-gray-700">
|
| 287 |
-
<td class="py-4">
|
| 288 |
-
<div class="flex items-center">
|
| 289 |
-
<img src="https://cryptologos.cc/logos/ethereum-eth-logo.png?v=029" class="h-6 w-6 mr-2" alt="Ethereum">
|
| 290 |
-
ETH/USDT
|
| 291 |
-
</div>
|
| 292 |
-
</td>
|
| 293 |
-
<td class="py-4">
|
| 294 |
-
<span class="px-2 py-1 rounded bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300">Short</span>
|
| 295 |
-
</td>
|
| 296 |
-
<td class="py-4">2.75</td>
|
| 297 |
-
<td class="py-4">$2,312.40</td>
|
| 298 |
-
<td class="py-4 font-medium">$2,281.75</td>
|
| 299 |
-
<td class="py-4 font-bold text-green-500">+$842.63</td>
|
| 300 |
-
<td class="py-4">
|
| 301 |
-
<span class="px-2 py-1 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300">Open</span>
|
| 302 |
-
</td>
|
| 303 |
-
<td class="py-4 text-right">
|
| 304 |
-
<button class="text-gray-400 hover:text-primary">
|
| 305 |
-
<i class="fas fa-ellipsis-v"></i>
|
| 306 |
-
</button>
|
| 307 |
-
</td>
|
| 308 |
-
</tr>
|
| 309 |
-
<tr class="border-b border-gray-200 dark:border-gray-700">
|
| 310 |
-
<td class="py-4">
|
| 311 |
-
<div class="flex items-center">
|
| 312 |
-
<img src="https://cryptologos.cc/logos/binance-coin-bnb-logo.png?v=029" class="h-6 w-6 mr-2" alt="BNB">
|
| 313 |
-
BNB/USDT
|
| 314 |
-
</div>
|
| 315 |
-
</td>
|
| 316 |
-
<td class="py-4">
|
| 317 |
-
<span class="px-2 py-1 rounded bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300">Short</span>
|
| 318 |
-
</td>
|
| 319 |
-
<td class="py-4">3.20</td>
|
| 320 |
-
<td class="py-4">$305.75</td>
|
| 321 |
-
<td class="py-4 font-medium">$312.85</td>
|
| 322 |
-
<td class="py-4 font-bold text-red-500">-$227.20</td>
|
| 323 |
-
<td class="py-4">
|
| 324 |
-
<span class="px-2 py-1 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300">Open</span>
|
| 325 |
-
</td>
|
| 326 |
-
<td class="py-4 text-right">
|
| 327 |
-
<button class="text-gray-400 hover:text-primary">
|
| 328 |
-
<i class="fas fa-ellipsis-v"></i>
|
| 329 |
-
</button>
|
| 330 |
-
</td>
|
| 331 |
-
</tr>
|
| 332 |
-
<tr>
|
| 333 |
-
<td class="py-4">
|
| 334 |
-
<div class="flex items-center">
|
| 335 |
-
<img src="https://cryptologos.cc/logos/solana-sol-logo.png?v=029" class="h-6 w-6 mr-2" alt="Solana">
|
| 336 |
-
SOL/USDT
|
| 337 |
-
</div>
|
| 338 |
-
</td>
|
| 339 |
-
<td class="py-4">
|
| 340 |
-
<span class="px-2 py-1 rounded bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300">Long</span>
|
| 341 |
-
</td>
|
| 342 |
-
<td class="py-4">15.50</td>
|
| 343 |
-
<td class="py-4">$96.35</td>
|
| 344 |
-
<td class="py-4 font-medium">$101.20</td>
|
| 345 |
-
<td class="py-4 font-bold text-green-500">+$751.75</td>
|
| 346 |
-
<td class="py-4">
|
| 347 |
-
<span class="px-2 py-1 rounded bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-300">Closed</span>
|
| 348 |
-
</td>
|
| 349 |
-
<td class="py-4 text-right">
|
| 350 |
-
<button class="text-gray-400 hover:text-primary">
|
| 351 |
-
<i class="fas fa-ellipsis-v"></i>
|
| 352 |
-
</button>
|
| 353 |
-
</td>
|
| 354 |
-
</tr>
|
| 355 |
</tbody>
|
| 356 |
</table>
|
| 357 |
</div>
|
|
@@ -368,74 +226,26 @@
|
|
| 368 |
</div>
|
| 369 |
<div>
|
| 370 |
<h3 class="text-lg font-bold text-white">BingX API Connected</h3>
|
| 371 |
-
<p class="text-blue-100">Last synced
|
| 372 |
</div>
|
| 373 |
</div>
|
| 374 |
-
<button class="mt-6 w-full py-3 bg-white rounded-xl text-primary font-bold flex items-center justify-center">
|
| 375 |
<i class="fas fa-sync mr-2"></i> Sync Now
|
| 376 |
</button>
|
| 377 |
</div>
|
| 378 |
-
|
| 379 |
<div class="lg:col-span-2 bg-white dark:bg-darkCard rounded-2xl shadow-md p-6">
|
| 380 |
<div class="flex justify-between items-center mb-6">
|
| 381 |
<h3 class="text-lg font-bold text-gray-800 dark:text-white">Portfolio Allocation</h3>
|
| 382 |
<div>
|
| 383 |
-
<span class="text-gray-500 dark:text-gray-400 text-sm">Last updated:
|
| 384 |
</div>
|
| 385 |
</div>
|
| 386 |
<div class="flex items-center">
|
| 387 |
<div class="w-40 h-40 mr-8">
|
| 388 |
<canvas id="allocationChart"></canvas>
|
| 389 |
</div>
|
| 390 |
-
<div class="flex-grow">
|
| 391 |
-
|
| 392 |
-
<div class="flex justify-between mb-1">
|
| 393 |
-
<span class="text-gray-500 dark:text-gray-400 flex items-center">
|
| 394 |
-
<span class="h-3 w-3 bg-primary rounded-full mr-2"></span>
|
| 395 |
-
Cryptocurrencies
|
| 396 |
-
</span>
|
| 397 |
-
<span class="font-medium dark:text-white">68%</span>
|
| 398 |
-
</div>
|
| 399 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 400 |
-
<div class="bg-primary h-2 rounded-full" style="width: 68%"></div>
|
| 401 |
-
</div>
|
| 402 |
-
</div>
|
| 403 |
-
<div class="mb-3">
|
| 404 |
-
<div class="flex justify-between mb-1">
|
| 405 |
-
<span class="text-gray-500 dark:text-gray-400 flex items-center">
|
| 406 |
-
<span class="h-3 w-3 bg-green-500 rounded-full mr-2"></span>
|
| 407 |
-
Stocks
|
| 408 |
-
</span>
|
| 409 |
-
<span class="font-medium dark:text-white">14%</span>
|
| 410 |
-
</div>
|
| 411 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 412 |
-
<div class="bg-green-500 h-2 rounded-full" style="width: 14%"></div>
|
| 413 |
-
</div>
|
| 414 |
-
</div>
|
| 415 |
-
<div class="mb-3">
|
| 416 |
-
<div class="flex justify-between mb-1">
|
| 417 |
-
<span class="text-gray-500 dark:text-gray-400 flex items-center">
|
| 418 |
-
<span class="h-3 w-3 bg-purple-500 rounded-full mr-2"></span>
|
| 419 |
-
Forex
|
| 420 |
-
</span>
|
| 421 |
-
<span class="font-medium dark:text-white">12%</span>
|
| 422 |
-
</div>
|
| 423 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 424 |
-
<div class="bg-purple-500 h-2 rounded-full" style="width: 12%"></div>
|
| 425 |
-
</div>
|
| 426 |
-
</div>
|
| 427 |
-
<div>
|
| 428 |
-
<div class="flex justify-between mb-1">
|
| 429 |
-
<span class="text-gray-500 dark:text-gray-400 flex items-center">
|
| 430 |
-
<span class="h-3 w-3 bg-yellow-500 rounded-full mr-2"></span>
|
| 431 |
-
Commodities
|
| 432 |
-
</span>
|
| 433 |
-
<span class="font-medium dark:text-white">6%</span>
|
| 434 |
-
</div>
|
| 435 |
-
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 436 |
-
<div class="bg-yellow-500 h-2 rounded-full" style="width: 6%"></div>
|
| 437 |
-
</div>
|
| 438 |
-
</div>
|
| 439 |
</div>
|
| 440 |
</div>
|
| 441 |
</div>
|
|
@@ -449,15 +259,15 @@
|
|
| 449 |
document.documentElement.classList.toggle('dark');
|
| 450 |
});
|
| 451 |
|
| 452 |
-
//
|
| 453 |
const performanceCtx = document.getElementById('performanceChart').getContext('2d');
|
| 454 |
const performanceChart = new Chart(performanceCtx, {
|
| 455 |
type: 'line',
|
| 456 |
data: {
|
| 457 |
-
labels: [
|
| 458 |
datasets: [{
|
| 459 |
label: 'Profit/Loss',
|
| 460 |
-
data: [
|
| 461 |
borderColor: '#3b82f6',
|
| 462 |
backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
| 463 |
tension: 0.4,
|
|
@@ -466,93 +276,236 @@
|
|
| 466 |
},
|
| 467 |
options: {
|
| 468 |
responsive: true,
|
| 469 |
-
plugins: {
|
| 470 |
-
legend: {
|
| 471 |
-
display: false
|
| 472 |
-
}
|
| 473 |
-
},
|
| 474 |
scales: {
|
| 475 |
-
y: {
|
| 476 |
-
|
| 477 |
-
color: 'rgba(0, 0, 0, 0.05)',
|
| 478 |
-
borderDash: [5]
|
| 479 |
-
},
|
| 480 |
-
ticks: {
|
| 481 |
-
callback: function(value) {
|
| 482 |
-
return '$' + value;
|
| 483 |
-
}
|
| 484 |
-
}
|
| 485 |
-
},
|
| 486 |
-
x: {
|
| 487 |
-
grid: {
|
| 488 |
-
display: false
|
| 489 |
-
}
|
| 490 |
-
}
|
| 491 |
}
|
| 492 |
}
|
| 493 |
});
|
| 494 |
|
| 495 |
-
// Portfolio Allocation Chart
|
| 496 |
const allocationCtx = document.getElementById('allocationChart').getContext('2d');
|
| 497 |
const allocationChart = new Chart(allocationCtx, {
|
| 498 |
type: 'doughnut',
|
| 499 |
data: {
|
| 500 |
-
labels: [
|
| 501 |
datasets: [{
|
| 502 |
-
data: [
|
| 503 |
-
backgroundColor: [
|
| 504 |
-
|
| 505 |
-
'#10b981',
|
| 506 |
-
'#8b5cf6',
|
| 507 |
-
'#f59e0b'
|
| 508 |
-
],
|
| 509 |
-
borderWidth: 0,
|
| 510 |
}]
|
| 511 |
},
|
| 512 |
options: {
|
| 513 |
responsive: true,
|
| 514 |
cutout: '65%',
|
| 515 |
-
plugins: {
|
| 516 |
-
legend: {
|
| 517 |
-
display: false
|
| 518 |
-
},
|
| 519 |
-
tooltip: {
|
| 520 |
-
callbacks: {
|
| 521 |
-
label: function(context) {
|
| 522 |
-
return `${context.label}: ${context.parsed}%`;
|
| 523 |
-
}
|
| 524 |
-
}
|
| 525 |
-
}
|
| 526 |
-
}
|
| 527 |
}
|
| 528 |
});
|
| 529 |
|
| 530 |
-
//
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
} else if (changePercent < 0) {
|
| 550 |
-
price.classList.add('text-red-500');
|
| 551 |
-
}
|
| 552 |
});
|
|
|
|
|
|
|
| 553 |
}
|
| 554 |
-
|
| 555 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
</script>
|
| 557 |
-
<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"
|
|
|
|
| 558 |
</html>
|
|
|
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 10 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
|
| 11 |
<script>
|
| 12 |
tailwind.config = {
|
| 13 |
darkMode: 'class',
|
|
|
|
| 55 |
</div>
|
| 56 |
<h1 class="text-2xl font-bold text-gray-800 dark:text-white">Nakhoda4X <span class="text-primary">Pro</span></h1>
|
| 57 |
</div>
|
|
|
|
| 58 |
<div class="flex items-center space-x-6">
|
| 59 |
<button id="theme-toggle" class="text-gray-600 dark:text-gray-300">
|
| 60 |
<i class="fas fa-moon dark:hidden"></i>
|
|
|
|
| 86 |
<p class="text-gray-500 mt-1 dark:text-gray-400">Connected to BingX via API</p>
|
| 87 |
</div>
|
| 88 |
<div class="flex space-x-4">
|
| 89 |
+
<button id="refresh-btn" class="px-4 py-2 bg-white dark:bg-darkCard rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 flex items-center">
|
| 90 |
<i class="fas fa-sync mr-2"></i> Refresh
|
| 91 |
</button>
|
| 92 |
<button class="px-4 py-2 bg-primary text-white rounded-lg flex items-center">
|
|
|
|
| 101 |
<div class="flex justify-between">
|
| 102 |
<div>
|
| 103 |
<p class="text-gray-500 dark:text-gray-400">Total Balance</p>
|
| 104 |
+
<h3 id="total-balance" class="text-2xl font-bold mt-2 dark:text-white">$0.00</h3>
|
| 105 |
</div>
|
| 106 |
<div class="w-12 h-12 rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center">
|
| 107 |
<i class="fas fa-wallet text-blue-500 text-xl"></i>
|
| 108 |
</div>
|
| 109 |
</div>
|
| 110 |
+
<div id="balance-change" class="mt-4 flex items-center text-green-500">
|
| 111 |
<i class="fas fa-caret-up mr-1"></i>
|
| 112 |
+
<span class="font-medium">0.0%</span>
|
| 113 |
<span class="text-gray-500 ml-2 dark:text-gray-400">last 24h</span>
|
| 114 |
</div>
|
| 115 |
</div>
|
|
|
|
| 116 |
<div class="trading-card bg-white dark:bg-darkCard rounded-2xl shadow-md p-6 transition-all duration-300">
|
| 117 |
<div class="flex justify-between">
|
| 118 |
<div>
|
| 119 |
<p class="text-gray-500 dark:text-gray-400">Open Trades</p>
|
| 120 |
+
<h3 id="open-trades" class="text-2xl font-bold mt-2 dark:text-white">0</h3>
|
| 121 |
</div>
|
| 122 |
<div class="w-12 h-12 rounded-xl bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center">
|
| 123 |
<i class="fas fa-exchange-alt text-purple-500 text-xl"></i>
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
+
<div id="trade-types" class="mt-4 flex items-center text-blue-500">
|
| 127 |
+
<span class="font-medium">0 Long</span>
|
| 128 |
<span class="text-gray-500 mx-2 dark:text-gray-400">β’</span>
|
| 129 |
+
<span class="font-medium">0 Short</span>
|
| 130 |
</div>
|
| 131 |
</div>
|
|
|
|
| 132 |
<div class="trading-card bg-white dark:bg-darkCard rounded-2xl shadow-md p-6 transition-all duration-300">
|
| 133 |
<div class="flex justify-between">
|
| 134 |
<div>
|
| 135 |
<p class="text-gray-500 dark:text-gray-400">Today's Profit</p>
|
| 136 |
+
<h3 id="today-profit" class="text-2xl font-bold mt-2 dark:text-white">$0.00</h3>
|
| 137 |
</div>
|
| 138 |
<div class="w-12 h-12 rounded-xl bg-green-100 dark:bg-green-900/30 flex items-center justify-center">
|
| 139 |
<i class="fas fa-chart-bar text-green-500 text-xl"></i>
|
| 140 |
</div>
|
| 141 |
</div>
|
| 142 |
+
<div id="profit-change" class="mt-4 flex items-center text-green-500">
|
| 143 |
<i class="fas fa-caret-up mr-1"></i>
|
| 144 |
+
<span class="font-medium">0.0%</span>
|
| 145 |
<span class="text-gray-500 ml-2 dark:text-gray-400">vs yesterday</span>
|
| 146 |
</div>
|
| 147 |
</div>
|
|
|
|
| 148 |
<div class="trading-card bg-white dark:bg-darkCard rounded-2xl shadow-md p-6 transition-all duration-300">
|
| 149 |
<div class="flex justify-between">
|
| 150 |
<div>
|
| 151 |
<p class="text-gray-500 dark:text-gray-400">Risk Exposure</p>
|
| 152 |
+
<h3 id="risk-exposure" class="text-2xl font-bold mt-2 dark:text-white">Low</h3>
|
| 153 |
</div>
|
| 154 |
<div class="w-12 h-12 rounded-xl bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center">
|
| 155 |
<i class="fas fa-exclamation-triangle text-yellow-500 text-xl"></i>
|
| 156 |
</div>
|
| 157 |
</div>
|
| 158 |
+
<div id="exposure-percent" class="mt-4 flex items-center text-gray-500 dark:text-gray-400">
|
| 159 |
+
<span class="font-medium">0%</span>
|
| 160 |
<span class="ml-2">of balance</span>
|
| 161 |
</div>
|
| 162 |
</div>
|
|
|
|
| 164 |
|
| 165 |
<!-- Charts and Statistics Section -->
|
| 166 |
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
|
|
|
|
| 167 |
<div class="lg:col-span-2 bg-white dark:bg-darkCard rounded-2xl shadow-md p-6">
|
| 168 |
<div class="flex justify-between items-center mb-6">
|
| 169 |
<h3 class="text-lg font-bold text-gray-800 dark:text-white">Monthly Performance</h3>
|
|
|
|
| 176 |
</div>
|
| 177 |
<canvas id="performanceChart"></canvas>
|
| 178 |
</div>
|
|
|
|
|
|
|
| 179 |
<div class="bg-white dark:bg-darkCard rounded-2xl shadow-md p-6">
|
| 180 |
<h3 class="text-lg font-bold text-gray-800 dark:text-white mb-6">Advanced Statistics</h3>
|
| 181 |
+
<div id="advanced-stats" class="space-y-5">
|
| 182 |
+
<!-- Dynamically populated -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
</div>
|
| 184 |
</div>
|
| 185 |
</div>
|
|
|
|
| 194 |
<button class="px-3 py-1 rounded-lg text-sm bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-white">Closed</button>
|
| 195 |
</div>
|
| 196 |
</div>
|
|
|
|
| 197 |
<div class="overflow-x-auto">
|
| 198 |
<table class="w-full">
|
| 199 |
<thead>
|
|
|
|
| 208 |
<th class="pb-4"></th>
|
| 209 |
</tr>
|
| 210 |
</thead>
|
| 211 |
+
<tbody id="trading-table-body" class="text-sm">
|
| 212 |
+
<!-- Dynamically populated -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
</tbody>
|
| 214 |
</table>
|
| 215 |
</div>
|
|
|
|
| 226 |
</div>
|
| 227 |
<div>
|
| 228 |
<h3 class="text-lg font-bold text-white">BingX API Connected</h3>
|
| 229 |
+
<p id="last-sync" class="text-blue-100">Last synced: Just now</p>
|
| 230 |
</div>
|
| 231 |
</div>
|
| 232 |
+
<button id="sync-now" class="mt-6 w-full py-3 bg-white rounded-xl text-primary font-bold flex items-center justify-center">
|
| 233 |
<i class="fas fa-sync mr-2"></i> Sync Now
|
| 234 |
</button>
|
| 235 |
</div>
|
|
|
|
| 236 |
<div class="lg:col-span-2 bg-white dark:bg-darkCard rounded-2xl shadow-md p-6">
|
| 237 |
<div class="flex justify-between items-center mb-6">
|
| 238 |
<h3 class="text-lg font-bold text-gray-800 dark:text-white">Portfolio Allocation</h3>
|
| 239 |
<div>
|
| 240 |
+
<span id="allocation-update" class="text-gray-500 dark:text-gray-400 text-sm">Last updated: Just now</span>
|
| 241 |
</div>
|
| 242 |
</div>
|
| 243 |
<div class="flex items-center">
|
| 244 |
<div class="w-40 h-40 mr-8">
|
| 245 |
<canvas id="allocationChart"></canvas>
|
| 246 |
</div>
|
| 247 |
+
<div id="allocation-legend" class="flex-grow">
|
| 248 |
+
<!-- Dynamically populated -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
</div>
|
| 250 |
</div>
|
| 251 |
</div>
|
|
|
|
| 259 |
document.documentElement.classList.toggle('dark');
|
| 260 |
});
|
| 261 |
|
| 262 |
+
// Chart Initialization
|
| 263 |
const performanceCtx = document.getElementById('performanceChart').getContext('2d');
|
| 264 |
const performanceChart = new Chart(performanceCtx, {
|
| 265 |
type: 'line',
|
| 266 |
data: {
|
| 267 |
+
labels: [],
|
| 268 |
datasets: [{
|
| 269 |
label: 'Profit/Loss',
|
| 270 |
+
data: [],
|
| 271 |
borderColor: '#3b82f6',
|
| 272 |
backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
| 273 |
tension: 0.4,
|
|
|
|
| 276 |
},
|
| 277 |
options: {
|
| 278 |
responsive: true,
|
| 279 |
+
plugins: { legend: { display: false } },
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
scales: {
|
| 281 |
+
y: { grid: { color: 'rgba(0, 0, 0, 0 β05)', borderDash: [5] }, ticks: { callback: value => '$' + value } },
|
| 282 |
+
x: { grid: { display: false } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
}
|
| 284 |
}
|
| 285 |
});
|
| 286 |
|
|
|
|
| 287 |
const allocationCtx = document.getElementById('allocationChart').getContext('2d');
|
| 288 |
const allocationChart = new Chart(allocationCtx, {
|
| 289 |
type: 'doughnut',
|
| 290 |
data: {
|
| 291 |
+
labels: [],
|
| 292 |
datasets: [{
|
| 293 |
+
data: [],
|
| 294 |
+
backgroundColor: ['#3b82f6', '#10b981', '#8b5cf6', '#f59e0b'],
|
| 295 |
+
borderWidth: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
}]
|
| 297 |
},
|
| 298 |
options: {
|
| 299 |
responsive: true,
|
| 300 |
cutout: '65%',
|
| 301 |
+
plugins: { legend: { display: false }, tooltip: { callbacks: { label: context => `${context.label}: ${context.parsed}%` } } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
}
|
| 303 |
});
|
| 304 |
|
| 305 |
+
// API Configuration (Replace with your actual keys in a secure manner)
|
| 306 |
+
const API_KEY = 'EXW9448ytbIhsoaEIqomKqVziRmWCAZ88OhLKmyMoPb7jFTtDnWjO1DFATt3sizsKi2hgn7SxQ06ALTDmU9w';
|
| 307 |
+
const API_SECRET = 'PCEzaYObtvi1DB3fmQy3XfFGl9ybRlFI6eVjpjSWykE1mJQ5mEDYlPsuJJ9mXfr2wjaxprMKzBCeitcY7xGdKQ';
|
| 308 |
+
const API_BASE_URL = 'https://api.bingx.com';
|
| 309 |
+
|
| 310 |
+
// Generate Signature for Authentication
|
| 311 |
+
function generateSignature(params) {
|
| 312 |
+
const queryString = new URLSearchParams(params).toString();
|
| 313 |
+
return CryptoJS.HmacSHA256(queryString, API_SECRET).toString(CryptoJS.enc.Hex);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
// Generic API Fetch Function
|
| 317 |
+
async function fetchFromAPI(endpoint, params = {}) {
|
| 318 |
+
params.timestamp = Date.now();
|
| 319 |
+
params.signature = generateSignature(params);
|
| 320 |
+
const url = `${API_BASE_URL}${endpoint}?${new URLSearchParams(params)}`;
|
| 321 |
+
const response = await fetch(url, {
|
| 322 |
+
method: 'GET',
|
| 323 |
+
headers: { 'X-BX-APIKEY': API_KEY }
|
|
|
|
|
|
|
|
|
|
| 324 |
});
|
| 325 |
+
if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
|
| 326 |
+
return response.json();
|
| 327 |
}
|
| 328 |
+
|
| 329 |
+
// Fetch Specific Data
|
| 330 |
+
async function fetchBalance() {
|
| 331 |
+
const data = await fetchFromAPI('/api/v1/account/balance');
|
| 332 |
+
return data.data.balance; // Adjust based on actual API response structure
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
async function fetchOpenPositions() {
|
| 336 |
+
const data = await fetchFromAPI('/api/v1/positions');
|
| 337 |
+
return data.data.positions; // Adjust based on actual API response structure
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
async function fetchTradeHistory() {
|
| 341 |
+
const data = await fetchFromAPI('/api/v1/trades', { limit: 100 });
|
| 342 |
+
return data.data.trades; // Adjust based on actual API response structure
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
// Helper Functions
|
| 346 |
+
function calculateTodayProfit(trades) {
|
| 347 |
+
const today = new Date().toDateString();
|
| 348 |
+
return trades
|
| 349 |
+
.filter(trade => new Date(trade.closeTime).toDateString() === today)
|
| 350 |
+
.reduce((sum, trade) => sum + (trade.realizedProfit || 0), 0);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
function calculateAdvancedStats(trades) {
|
| 354 |
+
let totalProfit = 0, totalLoss = 0, wins = 0;
|
| 355 |
+
trades.forEach(trade => {
|
| 356 |
+
const pl = trade.realizedProfit || 0;
|
| 357 |
+
if (pl > 0) { totalProfit += pl; wins++; }
|
| 358 |
+
else { totalLoss += Math.abs(pl); }
|
| 359 |
+
});
|
| 360 |
+
const profitFactor = totalLoss ? (totalProfit / totalLoss) : 0;
|
| 361 |
+
const winRate = trades.length ? (wins / trades.length * 100) : 0;
|
| 362 |
+
return { profitFactor: profitFactor.toFixed(2), winRate: winRate.toFixed(1) };
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
function calculatePortfolioAllocation(positions) {
|
| 366 |
+
const totalValue = positions.reduce((sum, pos) => sum + (pos.value || 0), 0);
|
| 367 |
+
const bySymbol = positions.reduce((acc, pos) => {
|
| 368 |
+
acc[pos.symbol] = (acc[pos.symbol] || 0) + (pos.value || 0);
|
| 369 |
+
return acc;
|
| 370 |
+
}, {});
|
| 371 |
+
return {
|
| 372 |
+
labels: Object.keys(bySymbol),
|
| 373 |
+
data: Object.values(bySymbol).map(val => totalValue ? (val / totalValue * 100) : 0)
|
| 374 |
+
};
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// Update UI Functions
|
| 378 |
+
function updateTradingTable(positions, trades) {
|
| 379 |
+
const tbody = document.getElementById('trading-table-body');
|
| 380 |
+
tbody.innerHTML = '';
|
| 381 |
+
positions.forEach(pos => {
|
| 382 |
+
tbody.innerHTML += `
|
| 383 |
+
<tr class="border-b border-gray-200 dark:border-gray-700">
|
| 384 |
+
<td class="py-4">${pos.symbol}</td>
|
| 385 |
+
<td class="py-4"><span class="${pos.side === 'Long' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'} px-2 py-1 rounded">${pos.side}</span></td>
|
| 386 |
+
<td class="py-4">${pos.size}</td>
|
| 387 |
+
<td class="py-4">$${pos.entryPrice.toFixed(2)}</td>
|
| 388 |
+
<td class="py-4 font-medium">$${pos.currentPrice.toFixed(2)}</td>
|
| 389 |
+
<td class="py-4 font-bold ${pos.unrealizedPL > 0 ? 'text-green-500' : 'text-red-500'}">$${pos.unrealizedPL.toFixed(2)}</td>
|
| 390 |
+
<td class="py-4"><span class="px-2 py-1 rounded bg-blue-100 text-blue-800">Open</span></td>
|
| 391 |
+
<td class="py-4 text-right"><button class="text-gray-400 hover:text-primary"><i class="fas fa-ellipsis-v"></i></button></td>
|
| 392 |
+
</tr>`;
|
| 393 |
+
});
|
| 394 |
+
trades.slice(0, 5).forEach(trade => {
|
| 395 |
+
tbody.innerHTML += `
|
| 396 |
+
<tr class="border-b border-gray-200 dark:border-gray-700">
|
| 397 |
+
<td class="py-4">${trade.symbol}</td>
|
| 398 |
+
<td class="py-4"><span class="${trade.side === 'Long' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'} px-2 py-1 rounded">${trade.side}</span></td>
|
| 399 |
+
<td class="py-4">${trade.size}</td>
|
| 400 |
+
<td class="py-4">$${trade.entryPrice.toFixed(2)}</td>
|
| 401 |
+
<td class="py-4 font-medium">$${trade.exitPrice.toFixed(2)}</td>
|
| 402 |
+
<td class="py-4 font-bold ${trade.realizedProfit > 0 ? 'text-green-500' : 'text-red-500'}">$${trade.realizedProfit.toFixed(2)}</td>
|
| 403 |
+
<td class="py-4"><span class="px-2 py-1 rounded bg-gray-100 text-gray-800">Closed</span></td>
|
| 404 |
+
<td class="py-4 text-right"><button class="text-gray-400 hover:text-primary"><i class="fas fa-ellipsis-v"></i></button></td>
|
| 405 |
+
</tr>`;
|
| 406 |
+
});
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
function updateAdvancedStats(stats) {
|
| 410 |
+
document.getElementById('advanced-stats').innerHTML = `
|
| 411 |
+
<div>
|
| 412 |
+
<div class="flex justify-between mb-1">
|
| 413 |
+
<span class="text-gray-500 dark:text-gray-400">Profit Factor</span>
|
| 414 |
+
<span class="font-bold text-green-500">${stats.profitFactor}</span>
|
| 415 |
+
</div>
|
| 416 |
+
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 417 |
+
<div class="bg-green-600 h-2 rounded-full" style="width: ${Math.min(stats.profitFactor * 25, 100)}%"></div>
|
| 418 |
+
</div>
|
| 419 |
+
</div>
|
| 420 |
+
<div>
|
| 421 |
+
<div class="flex justify-between mb-1">
|
| 422 |
+
<span class="text-gray-500 dark:text-gray-400">Win Rate</span>
|
| 423 |
+
<span class="font-bold text-purple-500">${stats.winRate}%</span>
|
| 424 |
+
</div>
|
| 425 |
+
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 426 |
+
<div class="bg-purple-600 h-2 rounded-full" style="width: ${stats.winRate}%"></div>
|
| 427 |
+
</div>
|
| 428 |
+
</div>`;
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
function updatePerformanceChart(trades) {
|
| 432 |
+
const monthlyPL = trades.reduce((acc, trade) => {
|
| 433 |
+
const month = new Date(trade.closeTime).toLocaleString('default', { month: 'short' });
|
| 434 |
+
acc[month] = (acc[month] || 0) + (trade.realizedProfit || 0);
|
| 435 |
+
return acc;
|
| 436 |
+
}, {});
|
| 437 |
+
performanceChart.data.labels = Object.keys(monthlyPL);
|
| 438 |
+
performanceChart.data.datasets[0].data = Object.values(monthlyPL);
|
| 439 |
+
performanceChart.update();
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
function updateAllocationChart(allocation) {
|
| 443 |
+
allocationChart.data.labels = allocation.labels;
|
| 444 |
+
allocationChart.data.datasets[0].data = allocation.data;
|
| 445 |
+
allocationChart.update();
|
| 446 |
+
const legend = document.getElementById('allocation-legend');
|
| 447 |
+
legend.innerHTML = allocation.labels.map((label, i) => `
|
| 448 |
+
<div class="mb-3">
|
| 449 |
+
<div class="flex justify-between mb-1">
|
| 450 |
+
<span class="text-gray-500 dark:text-gray-400 flex items-center">
|
| 451 |
+
<span class="h-3 w-3 bg-[${allocationChart.data.datasets[0].backgroundColor[i]}] rounded-full mr-2"></span>
|
| 452 |
+
${label}
|
| 453 |
+
</span>
|
| 454 |
+
<span class="font-medium dark:text-white">${allocation.data[i].toFixed(1)}%</span>
|
| 455 |
+
</div>
|
| 456 |
+
<div class="w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700">
|
| 457 |
+
<div class="bg-[${allocationChart.data.datasets[0].backgroundColor[i]}] h-2 rounded-full" style="width: ${allocation.data[i]}%"></div>
|
| 458 |
+
</div>
|
| 459 |
+
</div>`).join('');
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
// Main Data Fetch Function
|
| 463 |
+
async function fetchData() {
|
| 464 |
+
try {
|
| 465 |
+
// Show loading state
|
| 466 |
+
document.querySelectorAll('.trading-card h3').forEach(el => el.textContent = 'Loading...');
|
| 467 |
+
document.getElementById('trading-table-body').innerHTML = '<tr><td colspan="8" class="py-4 text-center">Loading...</td></tr>';
|
| 468 |
+
|
| 469 |
+
const [balance, positions, trades] = await Promise.all([
|
| 470 |
+
fetchBalance(),
|
| 471 |
+
fetchOpenPositions(),
|
| 472 |
+
fetchTradeHistory()
|
| 473 |
+
]);
|
| 474 |
+
|
| 475 |
+
// Update Stats Cards
|
| 476 |
+
document.getElementById('total-balance').textContent = `$${balance.toFixed(2)}`;
|
| 477 |
+
document.getElementById('open-trades').textContent = positions.length;
|
| 478 |
+
const longCount = positions.filter(p => p.side === 'Long').length;
|
| 479 |
+
document.getElementById('trade-types').innerHTML = `<span class="font-medium">${longCount} Long</span><span class="text-gray-500 mx-2 dark:text-gray-400">β’</span><span class="font-medium">${positions.length - longCount} Short</span>`;
|
| 480 |
+
const todayProfit = calculateTodayProfit(trades);
|
| 481 |
+
document.getElementById('today-profit').textContent = `$${todayProfit.toFixed(2)}`;
|
| 482 |
+
const riskPercent = balance ? (positions.reduce((sum, p) => sum + (p.value || 0), 0) / balance * 100) : 0;
|
| 483 |
+
document.getElementById('risk-exposure').textContent = riskPercent < 20 ? 'Low' : riskPercent < 50 ? 'Medium' : 'High';
|
| 484 |
+
document.getElementById('exposure-percent').innerHTML = `<span class="font-medium">${riskPercent.toFixed(1)}%</span><span class="ml-2">of balance</span>`;
|
| 485 |
+
|
| 486 |
+
// Update Other Sections
|
| 487 |
+
updateTradingTable(positions, trades);
|
| 488 |
+
const stats = calculateAdvancedStats(trades);
|
| 489 |
+
updateAdvancedStats(stats);
|
| 490 |
+
updatePerformanceChart(trades);
|
| 491 |
+
const allocation = calculatePortfolioAllocation(positions);
|
| 492 |
+
updateAllocationChart(allocation);
|
| 493 |
+
|
| 494 |
+
// Update sync time
|
| 495 |
+
document.getElementById('last-sync').textContent = 'Last synced: Just now';
|
| 496 |
+
document.getElementById('allocation-update').textContent = 'Last updated: Just now';
|
| 497 |
+
} catch (error) {
|
| 498 |
+
console.error('Error fetching data:', error);
|
| 499 |
+
alert('Failed to sync with BingX API. Please check your API credentials.');
|
| 500 |
+
}
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
// Event Listeners
|
| 504 |
+
document.getElementById('refresh-btn').addEventListener('click', fetchData);
|
| 505 |
+
document.getElementById('sync-now').addEventListener('click', fetchData);
|
| 506 |
+
window.addEventListener('load', fetchData);
|
| 507 |
+
setInterval(fetchData, 60000); // Refresh every 60 seconds
|
| 508 |
</script>
|
| 509 |
+
<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=EricSam/bingx-monitoring" style="color: #fff; text-decoration: underline;" target="_blank">Remix</a></p>
|
| 510 |
+
</body>
|
| 511 |
</html>
|