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
acbbed3
 
 
 
 
 
 
 
e74fc4b
bbce23f
1
2
3
4
5
6
7
8
9
10
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
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
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CryptoPulse Navigator - Intelligent CoinGlass Dashboard</title>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
    <link rel="stylesheet" href="/static/style.css">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CryptoPulse Navigator - Intelligent CoinGlass Dashboard</title>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#6366f1',
                        secondary: '#10b981',
                        dark: '#1e293b',
                        darker: '#0f172a'
                    }
                }
            }
        }
    </script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
        body {
            font-family: 'Space Grotesk', sans-serif;
        }
        .glass-card {
            backdrop-filter: blur(16px) saturate(180%);
            -webkit-backdrop-filter: blur(16px) saturate(180%);
            background-color: rgba(30, 41, 59, 0.75);
            border: 1px solid rgba(255, 255, 255, 0.125);
        }
        .phase-badge {
            transition: all 0.3s ease;
        }
        .phase-badge:hover {
            transform: scale(1.05);
        }
    </style>
</head>
<body class="bg-darker text-white min-h-screen">
    <div id="vanta-bg" class="fixed inset-0 -z-10"></div>
    
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="flex justify-between items-center mb-8">
            <div>
                <h1 class="text-3xl font-bold flex items-center">
                    <i data-feather="activity" class="mr-2 text-primary"></i>
                    CryptoPulse <span class="text-primary">Navigator</span>
                </h1>
                <p class="text-gray-400">Intelligent CoinGlass Dashboard</p>
            </div>
            <div class="flex items-center space-x-4">
                <div id="status-badge" class="px-3 py-1 rounded-full bg-opacity-20 bg-green-500 text-green-300 flex items-center">
                    <span class="w-2 h-2 rounded-full bg-green-500 mr-2"></span>
                    <span>Live</span>
                </div>
                <div id="last-updated" class="text-gray-400 text-sm">
                    <i data-feather="clock" class="w-4 h-4 inline mr-1"></i>
                    <span>Updating...</span>
                </div>
                <button id="refresh-btn" class="p-2 rounded-full hover:bg-gray-800 transition">
                    <i data-feather="refresh-cw" class="w-5 h-5"></i>
                </button>
            </div>
        </header>

        <!-- PHI Score and Market Phase -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
            <!-- PHI Score Card -->
            <div class="glass-card p-6 rounded-xl col-span-1 lg:col-span-2">
                <div class="flex justify-between items-start mb-4">
                    <div>
                        <h2 class="text-xl font-semibold">Market Health Index</h2>
                        <p class="text-gray-400 text-sm">PHI Score (Position Health Index)</p>
                    </div>
                    <div id="phase-badge" class="px-3 py-1 rounded-full bg-opacity-20 bg-secondary text-secondary phase-badge">
                        Loading...
                    </div>
                </div>
                <div class="flex items-center">
                    <div class="w-32 h-32 flex items-center justify-center relative">
                        <canvas id="phi-gauge" width="160" height="160"></canvas>
                        <div class="absolute text-center">
                            <div id="phi-score" class="text-4xl font-bold">--</div>
                            <div class="text-xs text-gray-400">PHI Score</div>
                        </div>
                    </div>
                    <div class="ml-6 flex-1">
                        <div class="mb-4">
                            <div class="flex justify-between text-sm mb-1">
                                <span>Volatility (VOLX)</span>
                                <span id="volx-value" class="font-medium">--</span>
                            </div>
                            <div class="w-full bg-gray-700 rounded-full h-2">
                                <div id="volx-bar" class="bg-yellow-500 h-2 rounded-full" style="width: 0%"></div>
                            </div>
                        </div>
                        <div class="mb-4">
                            <div class="flex justify-between text-sm mb-1">
                                <span>Momentum (MOMX)</span>
                                <span id="momx-value" class="font-medium">--</span>
                            </div>
                            <div class="w-full bg-gray-700 rounded-full h-2">
                                <div id="momx-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                            </div>
                        </div>
                        <div class="mb-4">
                            <div class="flex justify-between text-sm mb-1">
                                <span>Funding Bias (FBS)</span>
                                <span id="fbs-value" class="font-medium">--</span>
                            </div>
                            <div class="w-full bg-gray-700 rounded-full h-2">
                                <div id="fbs-bar" class="bg-purple-500 h-2 rounded-full" style="width: 0%"></div>
                            </div>
                        </div>
                        <div>
                            <div class="flex justify-between text-sm mb-1">
                                <span>Leverage (LPI)</span>
                                <span id="lpi-value" class="font-medium">--</span>
                            </div>
                            <div class="w-full bg-gray-700 rounded-full h-2">
                                <div id="lpi-bar" class="bg-red-500 h-2 rounded-full" style="width: 0%"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Market Overview -->
            <div class="glass-card p-6 rounded-xl">
                <h2 class="text-xl font-semibold mb-4">Market Overview</h2>
                <div class="space-y-4">
                    <div>
                        <div class="flex justify-between text-sm mb-1">
                            <span>Long/Short Ratio</span>
                            <span id="ls-ratio-value" class="font-medium">--</span>
                        </div>
                        <div class="w-full h-3 bg-gray-700 rounded-full overflow-hidden">
                            <div class="h-full flex">
                                <div id="long-bar" class="bg-green-500" style="width: 50%"></div>
                                <div id="short-bar" class="bg-red-500" style="width: 50%"></div>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="text-sm mb-1">Fear & Greed Index</div>
                        <div class="w-full bg-gray-700 rounded-full h-2">
                            <div id="fear-greed-bar" class="bg-gradient-to-r from-red-500 via-yellow-500 to-green-500 h-2 rounded-full" style="width: 50%"></div>
                        </div>
                        <div id="fear-greed-value" class="text-right text-xs mt-1">--</div>
                    </div>
                    <div class="pt-2">
                        <div class="text-sm mb-1">Market Phase</div>
                        <div id="phase-description" class="text-sm text-gray-300">
                            Loading market phase description...
                        </div>
                    </div>
                    <div class="pt-2">
                        <div class="text-sm mb-1">Risk Level</div>
                        <div id="risk-level" class="text-sm font-medium">
                            <span class="px-2 py-1 rounded bg-opacity-20 bg-gray-500">Calculating...</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- BTC/ETH Cards -->
        <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
            <!-- BTC Card -->
            <div class="glass-card p-6 rounded-xl">
                <div class="flex justify-between items-start mb-4">
                    <div class="flex items-center">
                        <img src="https://cryptologos.cc/logos/bitcoin-btc-logo.png" alt="BTC" class="w-8 h-8 mr-3">
                        <div>
                            <h2 class="text-xl font-semibold">Bitcoin</h2>
                            <div class="flex items-center">
                                <span id="btc-price" class="text-2xl font-bold">--</span>
                                <span id="btc-change" class="ml-2 px-2 py-1 rounded text-xs"></span>
                            </div>
                        </div>
                    </div>
                    <div class="text-xs text-gray-400">
                        Dominance: <span id="btc-dominance" class="font-medium">--%</span>
                    </div>
                </div>
                <div class="grid grid-cols-3 gap-4">
                    <div>
                        <div class="text-xs text-gray-400 mb-1">Funding Rate</div>
                        <div id="btc-funding" class="text-lg font-medium">--%</div>
                    </div>
                    <div>
                        <div class="text-xs text-gray-400 mb-1">Open Interest</div>
                        <div id="btc-oi" class="text-lg font-medium">--</div>
                    </div>
                    <div>
                        <div class="text-xs text-gray-400 mb-1">Liquidation</div>
                        <div class="flex items-center">
                            <span id="btc-liquidations" class="text-lg font-medium">--</span>
                            <span id="btc-liq-change" class="ml-1 text-xs"></span>
                        </div>
                    </div>
                </div>
                <div class="mt-4 h-20">
                    <canvas id="btc-chart"></canvas>
                </div>
            </div>

            <!-- ETH Card -->
            <div class="glass-card p-6 rounded-xl">
                <div class="flex justify-between items-start mb-4">
                    <div class="flex items-center">
                        <img src="https://cryptologos.cc/logos/ethereum-eth-logo.png" alt="ETH" class="w-8 h-8 mr-3">
                        <div>
                            <h2 class="text-xl font-semibold">Ethereum</h2>
                            <div class="flex items-center">
                                <span id="eth-price" class="text-2xl font-bold">--</span>
                                <span id="eth-change" class="ml-2 px-2 py-1 rounded text-xs"></span>
                            </div>
                        </div>
                    </div>
                    <div class="text-xs text-gray-400">
                        Dominance: <span id="eth-dominance" class="font-medium">--%</span>
                    </div>
                </div>
                <div class="grid grid-cols-3 gap-4">
                    <div>
                        <div class="text-xs text-gray-400 mb-1">Funding Rate</div>
                        <div id="eth-funding" class="text-lg font-medium">--%</div>
                    </div>
                    <div>
                        <div class="text-xs text-gray-400 mb-1">Open Interest</div>
                        <div id="eth-oi" class="text-lg font-medium">--</div>
                    </div>
                    <div>
                        <div class="text-xs text-gray-400 mb-1">Liquidation</div>
                        <div class="flex items-center">
                            <span id="eth-liquidations" class="text-lg font-medium">--</span>
                            <span id="eth-liq-change" class="ml-1 text-xs"></span>
                        </div>
                    </div>
                </div>
                <div class="mt-4 h-20">
                    <canvas id="eth-chart"></canvas>
                </div>
            </div>
        </div>

        <!-- Gainers & Losers -->
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
            <!-- Top Gainers -->
            <div class="glass-card p-6 rounded-xl">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold">Top Gainers</h2>
                    <span class="px-2 py-1 rounded-full bg-opacity-20 bg-green-500 text-green-300 text-xs">24h</span>
                </div>
                <div id="gainers-list" class="space-y-3">
                    <div class="flex items-center justify-between p-3 rounded-lg bg-gray-800 bg-opacity-50 animate-pulse">
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3"></div>
                            <div class="w-20 h-4 bg-gray-700 rounded"></div>
                        </div>
                        <div class="w-16 h-4 bg-gray-700 rounded"></div>
                    </div>
                    <div class="flex items-center justify-between p-3 rounded-lg bg-gray-800 bg-opacity-50 animate-pulse">
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3"></div>
                            <div class="w-20 h-4 bg-gray-700 rounded"></div>
                        </div>
                        <div class="w-16 h-4 bg-gray-700 rounded"></div>
                    </div>
                    <div class="flex items-center justify-between p-3 rounded-lg bg-gray-800 bg-opacity-50 animate-pulse">
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3"></div>
                            <div class="w-20 h-4 bg-gray-700 rounded"></div>
                        </div>
                        <div class="w-16 h-4 bg-gray-700 rounded"></div>
                    </div>
                </div>
            </div>

            <!-- Top Losers -->
            <div class="glass-card p-6 rounded-xl">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold">Top Losers</h2>
                    <span class="px-2 py-1 rounded-full bg-opacity-20 bg-red-500 text-red-300 text-xs">24h</span>
                </div>
                <div id="losers-list" class="space-y-3">
                    <div class="flex items-center justify-between p-3 rounded-lg bg-gray-800 bg-opacity-50 animate-pulse">
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3"></div>
                            <div class="w-20 h-4 bg-gray-700 rounded"></div>
                        </div>
                        <div class="w-16 h-4 bg-gray-700 rounded"></div>
                    </div>
                    <div class="flex items-center justify-between p-3 rounded-lg bg-gray-800 bg-opacity-50 animate-pulse">
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3"></div>
                            <div class="w-20 h-4 bg-gray-700 rounded"></div>
                        </div>
                        <div class="w-16 h-4 bg-gray-700 rounded"></div>
                    </div>
                    <div class="flex items-center justify-between p-3 rounded-lg bg-gray-800 bg-opacity-50 animate-pulse">
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3"></div>
                            <div class="w-20 h-4 bg-gray-700 rounded"></div>
                        </div>
                        <div class="w-16 h-4 bg-gray-700 rounded"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Funding Rates & Open Interest -->
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
            <!-- Funding Rates -->
            <div class="glass-card p-6 rounded-xl">
                <h2 class="text-xl font-semibold mb-4">Exchange Funding Rates</h2>
                <div class="h-64">
                    <canvas id="funding-chart"></canvas>
                </div>
            </div>

            <!-- Open Interest -->
            <div class="glass-card p-6 rounded-xl">
                <h2 class="text-xl font-semibold mb-4">Open Interest</h2>
                <div class="h-64">
                    <canvas id="oi-chart"></canvas>
                </div>
            </div>
        </div>

        <!-- Liquidation Heatmap -->
        <div class="glass-card p-6 rounded-xl mb-8">
            <h2 class="text-xl font-semibold mb-4">Liquidation Heatmap</h2>
            <div class="h-80">
                <canvas id="liquidation-chart"></canvas>
            </div>
        </div>

        <!-- Footer -->
        <footer class="text-center text-gray-500 text-sm py-6">
            <div class="flex justify-center space-x-4 mb-2">
                <a href="#" class="hover:text-primary transition"><i data-feather="github"></i></a>
                <a href="#" class="hover:text-primary transition"><i data-feather="twitter"></i></a>
                <a href="#" class="hover:text-primary transition"><i data-feather="discord"></i></a>
            </div>
            <p>CryptoPulse Navigator - Real-time Crypto Market Intelligence</p>
            <p class="text-xs mt-1">Data sourced from CoinGlass | Updates every 5 minutes</p>
        </footer>
    </div>
    <script>
        // Global config with direct API endpoints
        const CONFIG = {
            refreshInterval: 60 * 1000, // 1 minute
            apiEndpoints: {
                binance: {
                    price: 'https://api.binance.com/api/v3/ticker/24hr', 
                    klines: 'https://api.binance.com/api/v3/klines',
                    funding: 'https://fapi.binance.com/fapi/v1/premiumIndex'
                },
                coinGlass: {
                    openInterest: 'https://open-api.coinglass.com/api/pro/v1/futures/openInterest',
                    liquidation: 'https://open-api.coinglass.com/api/pro/v1/futures/liquidation',
                    fundingRates: 'https://open-api.coinglass.com/api/pro/v1/funding_rate',
                    longShort: 'https://open-api.coinglass.com/api/pro/v1/futures/longShort',
                    fearGreed: 'https://open-api.coinglass.com/api/pro/v1/fear_greed'
                }
            },
            coinGlassKey: 'YOUR_COINGLASS_API_KEY' // Replace with actual key
        };
// Initialize Vanta.js background
VANTA.NET({
            el: "#vanta-bg",
            mouseControls: true,
            touchControls: true,
            gyroControls: false,
            minHeight: 200.00,
            minWidth: 200.00,
            scale: 1.00,
            scaleMobile: 1.00,
            color: 0x6366f1,
            backgroundColor: 0x0f172a,
            points: 12.00,
            maxDistance: 22.00,
            spacing: 18.00
        });

        // Initialize charts
        const phiCtx = document.getElementById('phi-gauge').getContext('2d');
        const phiGauge = new Chart(phiCtx, {
            type: 'doughnut',
            data: {
                datasets: [{
                    data: [0, 100],
                    backgroundColor: ['#6366f1', 'rgba(30, 41, 59, 0.5)'],
                    borderWidth: 0
                }]
            },
            options: {
                cutout: '85%',
                rotation: -90,
                circumference: 180,
                responsive: false,
                plugins: {
                    legend: { display: false },
                    tooltip: { enabled: false }
                }
            }
        });

        // Initialize other charts
        const btcChart = new Chart(document.getElementById('btc-chart'), {
            type: 'line',
            data: {
                labels: Array(24).fill(''),
                datasets: [{
                    data: Array(24).fill(0),
                    borderColor: '#f59e0b',
                    borderWidth: 2,
                    tension: 0.3,
                    fill: true,
                    backgroundColor: 'rgba(245, 158, 11, 0.1)',
                    pointRadius: 0
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: { legend: { display: false } },
                scales: {
                    x: { display: false },
                    y: { display: false }
                }
            }
        });

        const ethChart = new Chart(document.getElementById('eth-chart'), {
            type: 'line',
            data: {
                labels: Array(24).fill(''),
                datasets: [{
                    data: Array(24).fill(0),
                    borderColor: '#8b5cf6',
                    borderWidth: 2,
                    tension: 0.3,
                    fill: true,
                    backgroundColor: 'rgba(139, 92, 246, 0.1)',
                    pointRadius: 0
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: { legend: { display: false } },
                scales: {
                    x: { display: false },
                    y: { display: false }
                }
            }
        });

        const fundingChart = new Chart(document.getElementById('funding-chart'), {
            type: 'bar',
            data: {
                labels: ['Binance', 'OKX', 'Bybit', 'Deribit', 'Bitget'],
                datasets: [{
                    label: 'Funding Rate',
                    data: [0.01, 0.005, 0.007, -0.002, 0.003],
                    backgroundColor: [
                        'rgba(99, 102, 241, 0.7)',
                        'rgba(99, 102, 241, 0.7)',
                        'rgba(99, 102, 241, 0.7)',
                        'rgba(99, 102, 241, 0.7)',
                        'rgba(99, 102, 241, 0.7)'
                    ],
                    borderColor: [
                        'rgba(99, 102, 241, 1)',
                        'rgba(99, 102, 241, 1)',
                        'rgba(99, 102, 241, 1)',
                        'rgba(99, 102, 241, 1)',
                        'rgba(99, 102, 241, 1)'
                    ],
                    borderWidth: 1
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: { display: false },
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                return (context.raw * 100).toFixed(4) + '%';
                            }
                        }
                    }
                },
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            callback: function(value) {
                                return (value * 100).toFixed(2) + '%';
                            }
                        }
                    }
                }
            }
        });

        const oiChart = new Chart(document.getElementById('oi-chart'), {
            type: 'line',
            data: {
                labels: ['6h ago', '5h ago', '4h ago', '3h ago', '2h ago', '1h ago', 'Now'],
                datasets: [
                    {
                        label: 'BTC',
                        data: [12000, 12500, 12300, 12800, 12700, 13000, 13200],
                        borderColor: '#f59e0b',
                        backgroundColor: 'rgba(245, 158, 11, 0.1)',
                        tension: 0.3,
                        fill: true
                    },
                    {
                        label: 'ETH',
                        data: [8000, 8200, 8100, 8300, 8250, 8400, 8500],
                        borderColor: '#8b5cf6',
                        backgroundColor: 'rgba(139, 92, 246, 0.1)',
                        tension: 0.3,
                        fill: true
                    }
                ]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                return context.dataset.label + ': $' + context.raw.toLocaleString();
                            }
                        }
                    }
                },
                scales: {
                    y: {
                        ticks: {
                            callback: function(value) {
                                return '$' + (value / 1000) + 'B';
                            }
                        }
                    }
                }
            }
        });

        const liquidationChart = new Chart(document.getElementById('liquidation-chart'), {
            type: 'bar',
            data: {
                labels: ['BTC', 'ETH', 'SOL', 'XRP', 'ADA', 'DOT', 'DOGE', 'MATIC'],
                datasets: [
                    {
                        label: 'Long',
                        data: [12000000, 8500000, 3200000, 1800000, 1500000, 1200000, 900000, 800000],
                        backgroundColor: 'rgba(16, 185, 129, 0.7)',
                        borderColor: 'rgba(16, 185, 129, 1)',
                        borderWidth: 1
                    },
                    {
                        label: 'Short',
                        data: [9500000, 7200000, 2800000, 1500000, 1200000, 900000, 700000, 600000],
                        backgroundColor: 'rgba(239, 68, 68, 0.7)',
                        borderColor: 'rgba(239, 68, 68, 1)',
                        borderWidth: 1
                    }
                ]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                return context.dataset.label + ': $' + (context.raw / 1000000).toFixed(2) + 'M';
                            }
                        }
                    }
                },
                scales: {
                    x: { stacked: true },
                    y: { 
                        stacked: true,
                        ticks: {
                            callback: function(value) {
                                return '$' + (value / 1000000) + 'M';
                            }
                        }
                    }
                }
            }
        });
        // Fetch live data from Binance and CoinGlass APIs
        async function fetchData() {
            try {
                document.getElementById('status-badge').className = 'px-3 py-1 rounded-full bg-opacity-20 bg-yellow-500 text-yellow-300 flex items-center';
                document.querySelector('#status-badge span:last-child').textContent = 'Updating';

                // Binance API requests
                const [binancePrices, btcFunding, ethFunding] = await Promise.all([
                    axios.get(`${CONFIG.apiEndpoints.binance.price}?symbols=["BTCUSDT","ETHUSDT"]`),
                    axios.get(`${CONFIG.apiEndpoints.binance.funding}?symbol=BTCUSDT`),
                    axios.get(`${CONFIG.apiEndpoints.binance.funding}?symbol=ETHUSDT`)
                ]);

                // CoinGlass API requests with headers
                const coinGlassHeaders = {
                    'coinglassSecret': CONFIG.coinGlassKey
                };
                
                const [openInterest, liquidations, fundingRates, longShort, fearGreed] = await Promise.all([
                    axios.get(CONFIG.apiEndpoints.coinGlass.openInterest, { headers: coinGlassHeaders }),
                    axios.get(CONFIG.apiEndpoints.coinGlass.liquidation, { headers: coinGlassHeaders }),
                    axios.get(CONFIG.apiEndpoints.coinGlass.fundingRates, { headers: coinGlassHeaders }),
                    axios.get(CONFIG.apiEndpoints.coinGlass.longShort, { headers: coinGlassHeaders }),
                    axios.get(CONFIG.apiEndpoints.coinGlass.fearGreed, { headers: coinGlassHeaders })
                ]);

                // Process Binance data
                const btcData = binancePrices.data.find(p => p.symbol === 'BTCUSDT');
                const ethData = binancePrices.data.find(p => p.symbol === 'ETHUSDT');

                // Transform data into our format
                const transformedData = {
                    btc: {
                        price: parseFloat(btcData.lastPrice),
                        change_24h: parseFloat(btcData.priceChangePercent),
                        funding_rate: parseFloat(btcFunding.data.lastFundingRate) * 100,
                        open_interest: openInterest.data.data.btc.sumOpenInterest,
                        liquidations: liquidations.data.data.btc.sumLiquidation
                    },
                    eth: {
                        price: parseFloat(ethData.lastPrice),
                        change_24h: parseFloat(ethData.priceChangePercent),
                        funding_rate: parseFloat(ethFunding.data.lastFundingRate) * 100,
                        open_interest: openInterest.data.data.eth.sumOpenInterest,
                        liquidations: liquidations.data.data.eth.sumLiquidation
                    },
                    phi_score: calculatePHIScore(longShort.data.data), // Calculated score
                    volx: parseFloat(fearGreed.data.data.volatility),
                    momx: parseFloat(fearGreed.data.data.momentum),
                    fbs: parseFloat(fundingRates.data.data.averageRate),
                    lpi: parseFloat(longShort.data.data.longShortRate),
                    long_short_ratio: parseFloat(longShort.data.data.longShortRate),
                    fear_greed: {
                        value: parseFloat(fearGreed.data.data.value),
                        label: fearGreed.data.data.valueClass
                    },
                    funding_rates: fundingRates.data.data.rateList,
                    open_interest_history: openInterest.data.data.historyList,
                    liquidations_history: liquidations.data.data.historyList
                };

                // Helper function to calculate PHI score
                function calculatePHIScore(longShortData) {
                    // Weighted average of multiple factors
                    const volScore = (parseFloat(longShortData.volatility) / 100) * 30;
                    const momScore = (parseFloat(longShortData.momentum) + 1) * 25;
                    const lsScore = (parseFloat(longShortData.longShortRate) - 1) * 15;
                    const fgScore = (parseFloat(fearGreed.data.data.value) / 100) * 30;
                    
                    return Math.min(100, Math.max(0, 
                        volScore + momScore + lsScore + fgScore
                    )).toFixed(1);
                }
updateDashboard(transformedData);
                document.getElementById('status-badge').className = 'px-3 py-1 rounded-full bg-opacity-20 bg-green-500 text-green-300 flex items-center';
                document.querySelector('#status-badge span:last-child').textContent = 'Live';
                document.getElementById('last-updated').innerHTML = `<i data-feather="clock" class="w-4 h-4 inline mr-1"></i> ${new Date().toLocaleTimeString()}`;
            } catch (error) {
                console.error('Error fetching data:', error);
                document.getElementById('status-badge').className = 'px-3 py-1 rounded-full bg-opacity-20 bg-red-500 text-red-300 flex items-center';
                document.querySelector('#status-badge span:last-child').textContent = 'Offline';
                
                // Try again in 30 seconds if failed
                setTimeout(fetchData, 30000);
            }
        }
        // Update dashboard with real data
        function updateDashboard(data) {
            // Update timestamp first
            document.getElementById('last-updated').innerHTML = 
                `<i data-feather="clock" class="w-4 h-4 inline mr-1"></i> ${new Date().toLocaleTimeString()}`;
// PHI Score and Metrics
            const phiScore = data.phi_score || 50;
            document.getElementById('phi-score').textContent = phiScore.toFixed(1);
            
            // Update gauge chart
            phiGauge.data.datasets[0].data = [phiScore, 100 - phiScore];
            phiGauge.update();
            
            // Update metric bars
            document.getElementById('volx-value').textContent = data.volx ? data.volx.toFixed(1) : '--';
            document.getElementById('momx-value').textContent = data.momx ? (data.momx * 100).toFixed(2) + '%' : '--';
            document.getElementById('fbs-value').textContent = data.fbs ? (data.fbs * 100).toFixed(4) + '%' : '--';
            document.getElementById('lpi-value').textContent = data.lpi ? data.lpi.toFixed(1) : '--';
            
            document.getElementById('volx-bar').style.width = `${data.volx || 0}%`;
            document.getElementById('momx-bar').style.width = `${(data.momx || 0) * 100}%`;
            document.getElementById('fbs-bar').style.width = `${(data.fbs || 0) * 100}%`;
            document.getElementById('lpi-bar').style.width = `${data.lpi || 0}%`;
            
            // Update market phase
            let phase = 'Neutral';
            let phaseColor = 'gray';
            
            if (phiScore < 30) {
                phase = 'Compression';
                phaseColor = 'purple';
            } else if (phiScore < 50) {
                phase = 'Recovery';
                phaseColor = 'blue';
            } else if (phiScore < 70) {
                phase = 'Expansion';
                phaseColor = 'green';
            } else {
                phase = 'Exhaustion';
                phaseColor = 'red';
            }
            
            const phaseBadge = document.getElementById('phase-badge');
            phaseBadge.textContent = phase;
            phaseBadge.className = `px-3 py-1 rounded-full bg-opacity-20 bg-${phaseColor}-500 text-${phaseColor}-300 phase-badge`;
            
            // Update phase description
            const descriptions = {
                'Compression': 'Market is in a compression phase with low volatility. Traders are cautious, awaiting a breakout.',
                'Recovery': 'Market is recovering from recent moves. Volatility is increasing as traders reposition.',
                'Expansion': 'Market is in expansion with strong momentum. Trending conditions likely to continue.',
                'Exhaustion': 'Market shows signs of exhaustion after strong moves. Potential reversal or consolidation ahead.',
                'Neutral': 'Market is in neutral territory without clear direction. Watch for breakout signals.'
            };
            
            document.getElementById('phase-description').textContent = descriptions[phase] || descriptions['Neutral'];
            
            // Update risk level
            let riskLevel = 'Medium';
            let riskColor = 'yellow';
            
            if (phiScore < 20 || phiScore > 80) {
                riskLevel = 'Extreme';
                riskColor = 'red';
            } else if (phiScore < 40 || phiScore > 60) {
                riskLevel = 'High';
                riskColor = 'orange';
            } else {
                riskLevel = 'Medium';
                riskColor = 'yellow';
            }
            
            document.getElementById('risk-level').innerHTML = `<span class="px-2 py-1 rounded bg-opacity-20 bg-${riskColor}-500 text-${riskColor}-300">${riskLevel} Risk</span>`;
            
            // Update BTC/ETH data
            if (data.btc) {
                document.getElementById('btc-price').textContent = `$${data.btc.price.toLocaleString()}`;
                const btcChange = data.btc.change_24h;
                const btcChangeEl = document.getElementById('btc-change');
                btcChangeEl.textContent = `${btcChange > 0 ? '+' : ''}${btcChange.toFixed(2)}%`;
                btcChangeEl.className = `ml-2 px-2 py-1 rounded text-xs ${btcChange >= 0 ? 'bg-green-500 bg-opacity-20 text-green-300' : 'bg-red-500 bg-opacity-20 text-red-300'}`;
                
                document.getElementById('btc-dominance').textContent = data.btc.dominance.toFixed(1) + '%';
                document.getElementById('btc-funding').textContent = (data.btc.funding_rate * 100).toFixed(4) + '%';
                document.getElementById('btc-oi').textContent = `$${(data.btc.open_interest / 1000000000).toFixed(2)}B`;
                document.getElementById('btc-liquidations').textContent = `$${(data.btc.liquidations / 1000000).toFixed(2)}M`;
                
                // Update BTC chart
                btcChart.data.datasets[0].data = data.btc.price_history || Array(24).fill(0);
                btcChart.update();
            }
            
            if (data.eth) {
                document.getElementById('eth-price').textContent = `$${data.eth.price.toLocaleString()}`;
                const ethChange = data.eth.change_24h;
                const ethChangeEl = document.getElementById('eth-change');
                ethChangeEl.textContent = `${ethChange > 0 ? '+' : ''}${ethChange.toFixed(2)}%`;
                ethChangeEl.className = `ml-2 px-2 py-1 rounded text-xs ${ethChange >= 0 ? 'bg-green-500 bg-opacity-20 text-green-300' : 'bg-red-500 bg-opacity-20 text-red-300'}`;
                
                document.getElementById('eth-dominance').textContent = data.eth.dominance.toFixed(1) + '%';
                document.getElementById('eth-funding').textContent = (data.eth.funding_rate * 100).toFixed(4) + '%';
                document.getElementById('eth-oi').textContent = `$${(data.eth.open_interest / 1000000000).toFixed(2)}B`;
                document.getElementById('eth-liquidations').textContent = `$${(data.eth.liquidations / 1000000).toFixed(2)}M`;
                
                // Update ETH chart
                ethChart.data.datasets[0].data = data.eth.price_history || Array(24).fill(0);
                ethChart.update();
            }
            
            // Update long/short ratio
            if (data.long_short_ratio) {
                const ratio = data.long_short_ratio;
                document.getElementById('ls-ratio-value').textContent = ratio.toFixed(2);
                document.getElementById('long-bar').style.width = `${(ratio / (ratio + 1)) * 100}%`;
                document.getElementById('short-bar').style.width = `${(1 / (ratio + 1)) * 100}%`;
            }
            
            // Update fear & greed index
            if (data.fear_greed) {
                const fg = data.fear_greed;
                document.getElementById('fear-greed-value').textContent = `${fg.value} (${fg.label})`;
                document.getElementById('fear-greed-bar').style.width = `${fg.value}%`;
            }
            
            // Update top gainers/losers
            if (data.top_gainers) {
                const gainersList = document.getElementById('gainers-list');
                gainersList.innerHTML = '';
                
                data.top_gainers.slice(0, 5).forEach(gainer => {
                    const gainerEl = document.createElement('div');
                    gainerEl.className = 'flex items-center justify-between p-3 rounded-lg hover:bg-gray-800 transition';
                    
                    gainerEl.innerHTML = `
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3 flex items-center justify-center text-xs font-bold">
                                ${gainer.symbol.substring(0, 3)}
                            </div>
                            <div>
                                <div class="font-medium">${gainer.symbol}</div>
                                <div class="text-xs text-gray-400">$${(gainer.price / 1000).toFixed(3)}K</div>
                            </div>
                        </div>
                        <div class="px-3 py-1 rounded-full bg-opacity-20 bg-green-500 text-green-300 text-sm">
                            +${gainer.change.toFixed(2)}%
                        </div>
                    `;
                    
                    gainersList.appendChild(gainerEl);
                });
            }
            
            if (data.top_losers) {
                const losersList = document.getElementById('losers-list');
                losersList.innerHTML = '';
                
                data.top_losers.slice(0, 5).forEach(loser => {
                    const loserEl = document.createElement('div');
                    loserEl.className = 'flex items-center justify-between p-3 rounded-lg hover:bg-gray-800 transition';
                    
                    loserEl.innerHTML = `
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gray-700 mr-3 flex items-center justify-center text-xs font-bold">
                                ${loser.symbol.substring(0, 3)}
                            </div>
                            <div>
                                <div class="font-medium">${loser.symbol}</div>
                                <div class="text-xs text-gray-400">$${(loser.price / 1000).toFixed(3)}K</div>
                            </div>
                        </div>
                        <div class="px-3 py-1 rounded-full bg-opacity-20 bg-red-500 text-red-300 text-sm">
                            ${loser.change.toFixed(2)}%
                        </div>
                    `;
                    
                    losersList.appendChild(loserEl);
                });
            }
            
            // Update funding rates chart
            if (data.funding_rates) {
                fundingChart.data.datasets[0].data = Object.values(data.funding_rates);
                fundingChart.update();
            }
            
            // Update open interest chart
            if (data.open_interest) {
                oiChart.data.datasets[0].data = data.open_interest.btc_history;
                oiChart.data.datasets[1].data = data.open_interest.eth_history;
                oiChart.update();
            }
            
            // Update liquidation chart
            if (data.liquidations) {
                liquidationChart.data.datasets[0].data = data.liquidations.longs;
                liquidationChart.data.datasets[1].data = data.liquidations.shorts;
                liquidationChart.update();
            }
        }

        // Refresh button
        document.getElementById('refresh-btn').addEventListener('click', fetchData);
        // Initial load with error handling
        document.addEventListener('DOMContentLoaded', () => {
            feather.replace();
            
            // Add CORS proxy header if needed
            axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
            
            // First try with proxy
            fetchData();
            
            // Auto-refresh every minute
            setInterval(fetchData, CONFIG.refreshInterval);
            
            // Fallback: if CORS proxy fails, try direct with JSONP
            window.jsonpCallback = function(data) {
                console.log('JSONP fallback data:', data);
                // Transform and use data as needed
            };
        });

        // Fallback JSONP function
        function loadJSONP(url) {
            const script = document.createElement('script');
            script.src = url;
            document.head.appendChild(script);
        }
</script>
</body>
</html>