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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
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>QuantumFX AI - Advanced Forex Trading Bot</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
        }
        .card-glow:hover {
            box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
        }
        .signal-buy {
            border-left: 4px solid #10b981;
        }
        .signal-sell {
            border-left: 4px solid #ef4444;
        }
        .signal-neutral {
            border-left: 4px solid #f59e0b;
        }
        .blink {
            animation: blink 1s infinite;
        }
        @keyframes blink {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }
        .news-ticker {
            white-space: nowrap;
            animation: ticker 30s linear infinite;
        }
        @keyframes ticker {
            0% { transform: translateX(100%); }
            100% { transform: translateX(-100%); }
        }
        .loading-spinner {
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top: 3px solid #3b82f6;
            width: 20px;
            height: 20px;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body class="bg-gray-900 text-gray-100 font-sans">
    <div class="min-h-screen flex flex-col">
        <!-- Header -->
        <header class="gradient-bg py-4 px-6 shadow-lg">
            <div class="flex justify-between items-center">
                <div class="flex items-center space-x-3">
                    <i class="fas fa-robot text-blue-400 text-2xl"></i>
                    <h1 class="text-xl font-bold">Quantum<span class="text-blue-400">FX</span> AI</h1>
                </div>
                <div class="flex items-center space-x-4">
                    <div class="flex items-center space-x-2">
                        <span class="h-3 w-3 rounded-full bg-green-500 animate-pulse"></span>
                        <span id="connection-status">Connecting...</span>
                    </div>
                    <div id="live-status" class="bg-gray-600 px-3 py-1 rounded-full text-sm">
                        <span>OFFLINE</span>
                    </div>
                    <button class="bg-blue-600 hover:bg-blue-700 px-4 py-1 rounded-md text-sm">
                        <i class="fas fa-cog mr-1"></i> Settings
                    </button>
                </div>
            </div>
        </header>

        <!-- News Ticker -->
        <div class="bg-gray-800 py-2 px-4 overflow-hidden">
            <div class="flex items-center">
                <span class="bg-red-600 px-2 py-1 rounded text-xs mr-3">LIVE NEWS</span>
                <div class="overflow-hidden w-full">
                    <div id="news-ticker" class="news-ticker">
                        <span>Loading market news...</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Main Content -->
        <main class="flex-1 p-6 grid grid-cols-1 lg:grid-cols-4 gap-6">
            <!-- Market Overview -->
            <div class="lg:col-span-4 bg-gray-800 rounded-xl p-4 shadow-lg">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-lg font-semibold">Market Overview</h2>
                    <div class="flex space-x-2">
                        <button class="bg-blue-600 hover:bg-blue-700 px-3 py-1 rounded text-sm">Forex</button>
                        <button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-sm">Indices</button>
                        <button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-sm">Commodities</button>
                    </div>
                </div>
                <div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-3" id="market-overview">
                    <!-- Market data will be loaded here -->
                    <div class="flex items-center justify-center h-32">
                        <div class="loading-spinner"></div>
                    </div>
                </div>
            </div>

            <!-- Main Chart -->
            <div class="lg:col-span-3 bg-gray-800 rounded-xl p-4 shadow-lg">
                <div class="flex justify-between items-center mb-4">
                    <div class="flex items-center space-x-4">
                        <h2 id="main-chart-title" class="text-lg font-semibold">EUR/USD</h2>
                        <div class="flex space-x-2">
                            <button class="bg-blue-600 hover:bg-blue-700 px-3 py-1 rounded text-sm" onclick="changeTimeframe('1h')">1H</button>
                            <button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-sm" onclick="changeTimeframe('4h')">4H</button>
                            <button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-sm" onclick="changeTimeframe('1d')">D</button>
                            <button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-sm" onclick="changeTimeframe('1w')">W</button>
                        </div>
                    </div>
                    <div class="flex items-center space-x-3">
                        <div class="flex items-center space-x-1">
                            <i class="fas fa-bolt text-yellow-400"></i>
                            <span class="text-sm">AI Confidence: <span id="ai-confidence">87%</span></span>
                        </div>
                        <div id="signal-strength" class="bg-green-600 px-2 py-1 rounded-full text-xs">
                            <span>STRONG BUY</span>
                        </div>
                    </div>
                </div>
                <div class="h-96">
                    <canvas id="mainChart"></canvas>
                </div>
                <div class="mt-4 grid grid-cols-4 gap-3">
                    <div class="bg-gray-700 rounded-lg p-3">
                        <p class="text-sm text-gray-400">Current Price</p>
                        <p id="current-price" class="text-lg font-bold">1.0985</p>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-3">
                        <p class="text-sm text-gray-400">Daily High</p>
                        <p id="daily-high" class="text-lg font-bold">1.1023</p>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-3">
                        <p class="text-sm text-gray-400">Daily Low</p>
                        <p id="daily-low" class="text-lg font-bold">1.0957</p>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-3">
                        <p class="text-sm text-gray-400">24h Change</p>
                        <p id="daily-change" class="text-lg font-bold text-green-500">+0.42%</p>
                    </div>
                </div>
            </div>

            <!-- Trading Signals -->
            <div class="lg:col-span-1 bg-gray-800 rounded-xl p-4 shadow-lg">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-lg font-semibold">Trading Signals</h2>
                    <div class="text-xs text-gray-400">Updated: <span id="signals-updated">Just now</span></div>
                </div>
                <div id="trading-signals" class="space-y-3 max-h-[500px] overflow-y-auto pr-2">
                    <!-- Signals will be loaded here -->
                    <div class="flex items-center justify-center h-32">
                        <div class="loading-spinner"></div>
                    </div>
                </div>
            </div>

            <!-- Technical Analysis -->
            <div class="lg:col-span-2 bg-gray-800 rounded-xl p-4 shadow-lg">
                <h2 class="text-lg font-semibold mb-4">Technical Analysis</h2>
                <div class="grid grid-cols-2 gap-4" id="technical-analysis">
                    <!-- Analysis will be loaded here -->
                    <div class="flex items-center justify-center h-32">
                        <div class="loading-spinner"></div>
                    </div>
                </div>
            </div>

            <!-- Fundamental Analysis -->
            <div class="lg:col-span-1 bg-gray-800 rounded-xl p-4 shadow-lg">
                <h2 class="text-lg font-semibold mb-4">Fundamental Analysis</h2>
                <div class="space-y-4" id="fundamental-analysis">
                    <!-- Analysis will be loaded here -->
                    <div class="flex items-center justify-center h-32">
                        <div class="loading-spinner"></div>
                    </div>
                </div>
            </div>

            <!-- Risk Management -->
            <div class="lg:col-span-1 bg-gray-800 rounded-xl p-4 shadow-lg">
                <h2 class="text-lg font-semibold mb-4">Risk Management</h2>
                <div class="space-y-4" id="risk-management">
                    <!-- Risk data will be loaded here -->
                    <div class="flex items-center justify-center h-32">
                        <div class="loading-spinner"></div>
                    </div>
                </div>
            </div>

            <!-- Trade Execution -->
            <div class="lg:col-span-1 bg-gray-800 rounded-xl p-4 shadow-lg">
                <h2 class="text-lg font-semibold mb-4">Trade Execution</h2>
                <div class="space-y-4" id="trade-execution">
                    <!-- Execution will be loaded here -->
                    <div class="flex items-center justify-center h-32">
                        <div class="loading-spinner"></div>
                    </div>
                </div>
            </div>

            <!-- AI Insights -->
            <div class="lg:col-span-2 bg-gray-800 rounded-xl p-4 shadow-lg">
                <h2 class="text-lg font-semibold mb-4">AI Insights</h2>
                <div id="ai-insights">
                    <!-- Insights will be loaded here -->
                    <div class="flex items-center justify-center h-32">
                        <div class="loading-spinner"></div>
                    </div>
                </div>
            </div>
        </main>

        <!-- Footer -->
        <footer class="bg-gray-800 py-3 px-6 border-t border-gray-700">
            <div class="flex justify-between items-center text-sm text-gray-400">
                <div>
                    <span>QuantumFX AI v2.4.1 | </span>
                    <span>Last Update: <span id="last-update" class="text-blue-400">Just now</span></span>
                </div>
                <div class="flex space-x-4">
                    <span>Server: NY4 <i id="server-status" class="fas fa-circle text-gray-500 ml-1"></i></span>
                    <span>Ping: <span id="ping">--</span>ms</span>
                    <span>CPU: <span id="cpu">--</span>%</span>
                    <span>RAM: <span id="ram">--</span>%</span>
                </div>
            </div>
        </footer>
    </div>

    <script>
        // API Configuration
        const API_KEY = 'YOUR_FOREX_API_KEY'; // Replace with your actual API key
        const BASE_URL = 'https://api.forexapi.com/v1';
        
        // Current selected pair and timeframe
        let currentPair = 'EURUSD';
        let currentTimeframe = '1h';
        
        // Chart instances
        let mainChart;
        let allocationChart;
        let miniCharts = {};
        
        // Initialize the dashboard
        document.addEventListener('DOMContentLoaded', function() {
            // Update connection status
            updateConnectionStatus();
            
            // Load initial data
            loadMarketData();
            loadMainChartData();
            loadTradingSignals();
            loadTechnicalAnalysis();
            loadFundamentalAnalysis();
            loadRiskManagement();
            loadTradeExecution();
            loadAIInsights();
            
            // Set up periodic updates
            setInterval(updateDashboard, 30000); // Update every 30 seconds
            setInterval(updatePerformanceMetrics, 5000); // Update performance metrics every 5 seconds
        });
        
        // Update connection status
        async function updateConnectionStatus() {
            try {
                document.getElementById('connection-status').textContent = 'Connecting...';
                
                // Simulate API connection check
                setTimeout(() => {
                    document.getElementById('connection-status').textContent = 'Connected';
                    document.getElementById('live-status').className = 'bg-green-600 px-3 py-1 rounded-full text-sm';
                    document.getElementById('live-status').innerHTML = '<span>LIVE</span>';
                    document.getElementById('server-status').className = 'fas fa-circle text-green-500 ml-1';
                }, 1500);
            } catch (error) {
                console.error('Connection error:', error);
                document.getElementById('connection-status').textContent = 'Disconnected';
                document.getElementById('live-status').className = 'bg-red-600 px-3 py-1 rounded-full text-sm';
                document.getElementById('live-status').innerHTML = '<span>OFFLINE</span>';
                document.getElementById('server-status').className = 'fas fa-circle text-red-500 ml-1';
            }
        }
        
        // Update performance metrics
        function updatePerformanceMetrics() {
            document.getElementById('ping').textContent = Math.floor(Math.random() * 20) + 10;
            document.getElementById('cpu').textContent = Math.floor(Math.random() * 10) + 5;
            document.getElementById('ram').textContent = Math.floor(Math.random() * 20) + 20;
        }
        
        // Change timeframe for main chart
        function changeTimeframe(timeframe) {
            currentTimeframe = timeframe;
            loadMainChartData();
            
            // Update button styles
            document.querySelectorAll('#main-chart-title ~ div button').forEach(btn => {
                btn.className = 'bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-sm';
            });
            document.querySelector(`button[onclick="changeTimeframe('${timeframe}')"]`).className = 
                'bg-blue-600 hover:bg-blue-700 px-3 py-1 rounded text-sm';
        }
        
        // Load market data for overview
        async function loadMarketData() {
            try {
                // In a real app, you would fetch from ForexAPI
                // const response = await axios.get(`${BASE_URL}/market?api_key=${API_KEY}`);
                
                // Simulated response with realistic data
                const simulatedResponse = {
                    data: {
                        EURUSD: { price: 1.0985, change: 0.42, high: 1.1023, low: 1.0957 },
                        GBPUSD: { price: 1.2642, change: -0.18, high: 1.2678, low: 1.2610 },
                        USDJPY: { price: 138.72, change: 0.65, high: 138.95, low: 138.10 },
                        AUDUSD: { price: 0.6714, change: -0.31, high: 0.6732, low: 0.6705 },
                        USDCAD: { price: 1.3428, change: 0.27, high: 1.3440, low: 1.3405 },
                        XAUUSD: { price: 1978.42, change: 1.12, high: 1982.50, low: 1970.30 },
                        OILUSD: { price: 72.56, change: -2.35, high: 73.80, low: 72.20 },
                        BTCUSD: { price: 27345, change: 3.78, high: 27500, low: 27020 }
                    }
                };
                
                const marketData = simulatedResponse.data;
                let marketOverviewHTML = '';
                
                // Generate market cards
                for (const [pair, data] of Object.entries(marketData)) {
                    const isPositive = data.change >= 0;
                    const changeColor = isPositive ? 'text-green-500' : 'text-red-500';
                    const changeIcon = isPositive ? 'fa-caret-up' : 'fa-caret-down';
                    
                    marketOverviewHTML += `
                        <div class="bg-gray-700 rounded-lg p-3 card-glow">
                            <div class="flex justify-between items-start">
                                <div>
                                    <p class="text-sm text-gray-400">${pair}</p>
                                    <p class="text-lg font-bold">${data.price.toLocaleString(undefined, { minimumFractionDigits: pair === 'BTCUSD' ? 0 : 4 })}</p>
                                </div>
                                <div class="${changeColor} text-sm">
                                    <i class="fas ${changeIcon} mr-1"></i> ${Math.abs(data.change)}%
                                </div>
                            </div>
                            <div class="mt-2 h-12">
                                <canvas id="${pair.toLowerCase()}-minichart"></canvas>
                            </div>
                        </div>
                    `;
                }
                
                document.getElementById('market-overview').innerHTML = marketOverviewHTML;
                
                // Initialize mini charts
                initializeMiniCharts();
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading market data:', error);
                document.getElementById('market-overview').innerHTML = `
                    <div class="col-span-8 bg-gray-700 rounded-lg p-4 text-center text-red-400">
                        <i class="fas fa-exclamation-triangle mr-2"></i> Failed to load market data
                    </div>
                `;
            }
        }
        
        // Initialize mini charts
        function initializeMiniCharts() {
            // Simulated price history for mini charts
            const pairs = ['eurusd', 'gbpusd', 'usdjpy', 'audusd', 'usdcad', 'xauusd', 'oilusd', 'btcusd'];
            
            pairs.forEach(pair => {
                const ctx = document.getElementById(`${pair}-minichart`).getContext('2d');
                const data = generateRandomChartData(8, pair.includes('usd') ? 0.002 : pair.includes('jpy') ? 0.5 : pair.includes('btc') ? 200 : 2);
                
                miniCharts[pair] = new Chart(ctx, {
                    type: 'line',
                    data: {
                        labels: Array(data.length).fill(''),
                        datasets: [{
                            data: data,
                            borderColor: data[data.length - 1] >= data[0] ? '#10b981' : '#ef4444',
                            borderWidth: 1,
                            tension: 0.4,
                            fill: false,
                            pointRadius: 0
                        }]
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        scales: {
                            x: { display: false },
                            y: { display: false }
                        },
                        plugins: { legend: { display: false } }
                    }
                });
            });
        }
        
        // Load main chart data
        async function loadMainChartData() {
            try {
                // In a real app, you would fetch from ForexAPI
                // const response = await axios.get(`${BASE_URL}/history?symbol=${currentPair}&timeframe=${currentTimeframe}&api_key=${API_KEY}`);
                
                // Simulated response with realistic data
                const simulatedResponse = {
                    data: {
                        symbol: 'EURUSD',
                        timeframe: currentTimeframe,
                        prices: generateRandomChartData(24, 0.005, 1.09),
                        high: 1.1023,
                        low: 1.0957,
                        change: 0.42,
                        indicators: {
                            rsi: 62.4,
                            macd: 0.0012,
                            stochastic: 78.2,
                            adx: 32.6
                        },
                        movingAverages: {
                            ema10: 1.0972,
                            sma20: 1.0958,
                            ema50: 1.0924,
                            sma100: 1.0887
                        },
                        pattern: 'Bullish Flag'
                    }
                };
                
                const chartData = simulatedResponse.data;
                
                // Update chart title
                document.getElementById('main-chart-title').textContent = chartData.symbol;
                
                // Update price info
                document.getElementById('current-price').textContent = chartData.prices[chartData.prices.length - 1].toFixed(4);
                document.getElementById('daily-high').textContent = chartData.high.toFixed(4);
                document.getElementById('daily-low').textContent = chartData.low.toFixed(4);
                
                const changeElement = document.getElementById('daily-change');
                if (chartData.change >= 0) {
                    changeElement.className = 'text-lg font-bold text-green-500';
                    changeElement.textContent = `+${chartData.change.toFixed(2)}%`;
                } else {
                    changeElement.className = 'text-lg font-bold text-red-500';
                    changeElement.textContent = `${chartData.change.toFixed(2)}%`;
                }
                
                // Create or update main chart
                const ctx = document.getElementById('mainChart').getContext('2d');
                const labels = Array(chartData.prices.length).fill('').map((_, i) => `${i}:00`);
                
                if (mainChart) {
                    mainChart.destroy();
                }
                
                mainChart = new Chart(ctx, {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [{
                            label: chartData.symbol,
                            data: chartData.prices,
                            borderColor: '#3b82f6',
                            backgroundColor: 'rgba(59, 130, 246, 0.1)',
                            borderWidth: 2,
                            tension: 0.3,
                            fill: true
                        }]
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        plugins: {
                            legend: { display: false },
                            tooltip: {
                                mode: 'index',
                                intersect: false
                            }
                        },
                        scales: {
                            y: {
                                grid: { color: 'rgba(255, 255, 255, 0.1)' }
                            },
                            x: {
                                grid: { display: false }
                            }
                        },
                        interaction: {
                            mode: 'nearest',
                            axis: 'x',
                            intersect: false
                        }
                    }
                });
                
                // Update AI confidence and signal strength based on indicators
                updateAIConfidence(chartData.indicators, chartData.pattern);
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading chart data:', error);
                document.getElementById('main-chart-title').nextElementSibling.innerHTML = `
                    <div class="text-red-400 text-sm">
                        <i class="fas fa-exclamation-triangle mr-1"></i> Chart data unavailable
                    </div>
                `;
            }
        }
        
        // Update AI confidence based on technical indicators
        function updateAIConfidence(indicators, pattern) {
            // Calculate confidence score (simplified)
            let confidence = 70; // Base confidence
            
            // RSI between 40-60 is ideal
            if (indicators.rsi > 40 && indicators.rsi < 60) confidence += 10;
            
            // Positive MACD is good
            if (indicators.macd > 0) confidence += 5;
            
            // Strong ADX (>25) is good
            if (indicators.adx > 25) confidence += 10;
            
            // Bullish pattern adds confidence
            if (pattern.includes('Bullish')) confidence += 10;
            
            // Cap at 95%
            confidence = Math.min(95, confidence);
            
            // Update UI
            document.getElementById('ai-confidence').textContent = `${confidence}%`;
            
            // Update signal strength
            const signalElement = document.getElementById('signal-strength');
            if (confidence >= 85) {
                signalElement.className = 'bg-green-600 px-2 py-1 rounded-full text-xs';
                signalElement.innerHTML = '<span>STRONG BUY</span>';
            } else if (confidence >= 70) {
                signalElement.className = 'bg-green-500 px-2 py-1 rounded-full text-xs';
                signalElement.innerHTML = '<span>BUY</span>';
            } else if (confidence >= 55) {
                signalElement.className = 'bg-yellow-500 px-2 py-1 rounded-full text-xs';
                signalElement.innerHTML = '<span>NEUTRAL</span>';
            } else if (confidence >= 40) {
                signalElement.className = 'bg-red-500 px-2 py-1 rounded-full text-xs';
                signalElement.innerHTML = '<span>SELL</span>';
            } else {
                signalElement.className = 'bg-red-600 px-2 py-1 rounded-full text-xs';
                signalElement.innerHTML = '<span>STRONG SELL</span>';
            }
        }
        
        // Load trading signals
        async function loadTradingSignals() {
            try {
                // In a real app, you would fetch from your API
                // const response = await axios.get(`${BASE_URL}/signals?api_key=${API_KEY}`);
                
                // Simulated response with realistic signals
                const simulatedResponse = {
                    data: [
                        {
                            pair: 'EURUSD',
                            timeframe: '1H',
                            signal: 'BUY',
                            entry: 1.0975,
                            take_profit: 1.1025,
                            stop_loss: 1.0950,
                            confidence: 87,
                            updated: new Date().toISOString()
                        },
                        {
                            pair: 'USDJPY',
                            timeframe: '4H',
                            signal: 'SELL',
                            entry: 138.85,
                            take_profit: 137.50,
                            stop_loss: 139.50,
                            confidence: 76,
                            updated: new Date().toISOString()
                        },
                        {
                            pair: 'GBPUSD',
                            timeframe: 'D',
                            signal: 'HOLD',
                            entry_range: '1.2600-1.2620',
                            take_profit: 1.2700,
                            stop_loss: 1.2550,
                            confidence: 68,
                            updated: new Date().toISOString()
                        },
                        {
                            pair: 'XAUUSD',
                            timeframe: '1H',
                            signal: 'BUY',
                            entry: 1975.00,
                            take_profit: 1990.00,
                            stop_loss: 1965.00,
                            confidence: 82,
                            updated: new Date().toISOString()
                        }
                    ]
                };
                
                const signals = simulatedResponse.data;
                let signalsHTML = '';
                
                signals.forEach(signal => {
                    const signalClass = signal.signal === 'BUY' ? 'signal-buy' : 
                                      signal.signal === 'SELL' ? 'signal-sell' : 'signal-neutral';
                    const signalColor = signal.signal === 'BUY' ? 'bg-green-600' : 
                                      signal.signal === 'SELL' ? 'bg-red-600' : 'bg-yellow-600';
                    
                    signalsHTML += `
                        <div class="bg-gray-700 rounded-lg p-3 ${signalClass}">
                            <div class="flex justify-between items-start">
                                <div>
                                    <p class="font-medium">${signal.pair}</p>
                                    <p class="text-sm text-gray-400">${signal.timeframe} Timeframe</p>
                                </div>
                                <div class="${signalColor} px-2 py-1 rounded-full text-xs">
                                    <span>${signal.signal}</span>
                                </div>
                            </div>
                            <div class="mt-2 text-sm">
                                <div class="flex justify-between">
                                    <span class="text-gray-400">Entry:</span>
                                    <span>${signal.entry_range || signal.entry}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-400">Take Profit:</span>
                                    <span>${signal.take_profit}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-400">Stop Loss:</span>
                                    <span>${signal.stop_loss}</span>
                                </div>
                            </div>
                            <div class="mt-2 flex justify-between items-center text-xs">
                                <span class="text-gray-400">Confidence: ${signal.confidence}%</span>
                                <button class="bg-blue-600 hover:bg-blue-700 px-2 py-1 rounded text-xs">
                                    ${signal.signal === 'HOLD' ? 'Pending' : 'Execute'}
                                </button>
                            </div>
                        </div>
                    `;
                });
                
                document.getElementById('trading-signals').innerHTML = signalsHTML;
                document.getElementById('signals-updated').textContent = 'Just now';
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading trading signals:', error);
                document.getElementById('trading-signals').innerHTML = `
                    <div class="bg-gray-700 rounded-lg p-4 text-center text-red-400">
                        <i class="fas fa-exclamation-triangle mr-2"></i> Failed to load signals
                    </div>
                `;
            }
        }
        
        // Load technical analysis
        async function loadTechnicalAnalysis() {
            try {
                // In a real app, you would fetch from your API
                // const response = await axios.get(`${BASE_URL}/analysis/technical?symbol=${currentPair}&api_key=${API_KEY}`);
                
                // Simulated response with realistic data
                const simulatedResponse = {
                    data: {
                        indicators: {
                            rsi: 62.4,
                            macd: 0.0012,
                            stochastic: 78.2,
                            adx: 32.6
                        },
                        moving_averages: {
                            ema10: { value: 1.0972, trend: 'up' },
                            sma20: { value: 1.0958, trend: 'up' },
                            ema50: { value: 1.0924, trend: 'up' },
                            sma100: { value: 1.0887, trend: 'up' }
                        },
                        pivot_points: {
                            r3: 1.1089,
                            r2: 1.1057,
                            r1: 1.1021,
                            pp: 1.0989,
                            s1: 1.0953,
                            s2: 1.0921
                        },
                        patterns: [
                            { name: 'Bullish Flag', reliability: 85 },
                            { name: 'Higher Highs', reliability: 80 }
                        ],
                        fibonacci: {
                            level_618: 1.1025
                        }
                    }
                };
                
                const analysis = simulatedResponse.data;
                let analysisHTML = `
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">Indicators</h3>
                        <div class="space-y-3">
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>RSI (14)</span>
                                    <span class="font-mono">${analysis.indicators.rsi}</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-blue-500 h-1.5 rounded-full" style="width: ${analysis.indicators.rsi}%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>MACD (12,26,9)</span>
                                    <span class="font-mono">${analysis.indicators.macd > 0 ? '+' : ''}${analysis.indicators.macd}</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-green-500 h-1.5 rounded-full" style="width: ${70}%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>Stochastic (14,3,3)</span>
                                    <span class="font-mono">${analysis.indicators.stochastic}</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-yellow-500 h-1.5 rounded-full" style="width: ${analysis.indicators.stochastic}%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>ADX (14)</span>
                                    <span class="font-mono">${analysis.indicators.adx}</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-purple-500 h-1.5 rounded-full" style="width: ${analysis.indicators.adx}%"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">Moving Averages</h3>
                        <div class="space-y-3">
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>EMA (10)</span>
                                    <span class="font-mono">${analysis.moving_averages.ema10.value} <span class="text-green-500">↑</span></span>
                                </div>
                                <div class="text-xs text-gray-400">Bullish Crossover</div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>SMA (20)</span>
                                    <span class="font-mono">${analysis.moving_averages.sma20.value} <span class="text-green-500">↑</span></span>
                                </div>
                                <div class="text-xs text-gray-400">Support Level</div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>EMA (50)</span>
                                    <span class="font-mono">${analysis.moving_averages.ema50.value} <span class="text-green-500">↑</span></span>
                                </div>
                                <div class="text-xs text-gray-400">Strong Support</div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>SMA (100)</span>
                                    <span class="font-mono">${analysis.moving_averages.sma100.value} <span class="text-green-500">↑</span></span>
                                </div>
                                <div class="text-xs text-gray-400">Long-term Trend</div>
                            </div>
                        </div>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">Pivot Points</h3>
                        <div class="grid grid-cols-3 gap-2 text-sm">
                            <div class="bg-gray-600 p-2 rounded text-center">
                                <div class="text-gray-400">R3</div>
                                <div>${analysis.pivot_points.r3}</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded text-center">
                                <div class="text-gray-400">R2</div>
                                <div>${analysis.pivot_points.r2}</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded text-center">
                                <div class="text-gray-400">R1</div>
                                <div>${analysis.pivot_points.r1}</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded text-center">
                                <div class="text-gray-400">PP</div>
                                <div>${analysis.pivot_points.pp}</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded text-center">
                                <div class="text-gray-400">S1</div>
                                <div>${analysis.pivot_points.s1}</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded text-center">
                                <div class="text-gray-400">S2</div>
                                <div>${analysis.pivot_points.s2}</div>
                            </div>
                        </div>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">Pattern Recognition</h3>
                        <div class="flex items-center space-x-3">
                            <div class="bg-blue-500 p-2 rounded-full">
                                <i class="fas fa-chart-line text-white"></i>
                            </div>
                            <div>
                                <p class="font-medium">${analysis.patterns[0].name}</p>
                                <p class="text-xs text-gray-400">${analysis.patterns[0].reliability}% reliability</p>
                            </div>
                        </div>
                        <div class="mt-3 flex items-center space-x-3">
                            <div class="bg-green-500 p-2 rounded-full">
                                <i class="fas fa-arrow-up text-white"></i>
                            </div>
                            <div>
                                <p class="font-medium">${analysis.patterns[1].name}</p>
                                <p class="text-xs text-gray-400">3 consecutive</p>
                            </div>
                        </div>
                        <div class="mt-3">
                            <p class="text-sm">Fibonacci Extension: ${analysis.fibonacci.level_618} (61.8%)</p>
                            <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                <div class="bg-yellow-500 h-1.5 rounded-full" style="width: 61.8%"></div>
                            </div>
                        </div>
                    </div>
                `;
                
                document.getElementById('technical-analysis').innerHTML = analysisHTML;
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading technical analysis:', error);
                document.getElementById('technical-analysis').innerHTML = `
                    <div class="col-span-2 bg-gray-700 rounded-lg p-4 text-center text-red-400">
                        <i class="fas fa-exclamation-triangle mr-2"></i> Failed to load technical analysis
                    </div>
                `;
            }
        }
        
        // Load fundamental analysis
        async function loadFundamentalAnalysis() {
            try {
                // In a real app, you would fetch from your API
                // const response = await axios.get(`${BASE_URL}/analysis/fundamental?symbol=${currentPair}&api_key=${API_KEY}`);
                
                // Simulated response with realistic data
                const simulatedResponse = {
                    data: {
                        calendar: [
                            {
                                event: 'USD: Fed Interest Rate',
                                time: 'Today, 18:00 GMT',
                                impact: 'High'
                            },
                            {
                                event: 'EUR: ECB President Speech',
                                time: 'Today, 14:30 GMT',
                                impact: 'Medium'
                            },
                            {
                                event: 'USD: Non-Farm Payrolls',
                                time: 'Tomorrow, 12:30 GMT',
                                impact: 'High'
                            }
                        ],
                        sentiment: {
                            market: 72,
                            retail: 58,
                            institutional: 67
                        },
                        news: [
                            {
                                title: 'Fed Pause Expected',
                                summary: 'Dollar weakness likely to continue'
                            },
                            {
                                title: 'Eurozone Inflation',
                                summary: 'Core CPI remains sticky at 5.3%'
                            },
                            {
                                title: 'Banking Concerns',
                                summary: 'Safe-haven flows supporting EUR'
                            }
                        ]
                    }
                };
                
                const analysis = simulatedResponse.data;
                let analysisHTML = `
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">Economic Calendar</h3>
                        <div class="space-y-3 text-sm">
                            ${analysis.calendar.map(item => `
                                <div class="flex justify-between items-center">
                                    <div>
                                        <p class="font-medium">${item.event}</p>
                                        <p class="text-gray-400">${item.time}</p>
                                    </div>
                                    <span class="${item.impact === 'High' ? 'bg-red-100 text-red-800' : 'bg-yellow-100 text-yellow-800'} px-2 py-1 rounded-full text-xs">
                                        ${item.impact} Impact
                                    </span>
                                </div>
                            `).join('')}
                        </div>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">Sentiment Analysis</h3>
                        <div class="space-y-3">
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>Market Sentiment</span>
                                    <span class="font-mono">${analysis.sentiment.market}% Bullish</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-green-500 h-1.5 rounded-full" style="width: ${analysis.sentiment.market}%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>Retail Traders</span>
                                    <span class="font-mono">${analysis.sentiment.retail}% Short</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-red-500 h-1.5 rounded-full" style="width: ${analysis.sentiment.retail}%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between text-sm">
                                    <span>Institutional Bias</span>
                                    <span class="font-mono">${analysis.sentiment.institutional}% Long</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-green-500 h-1.5 rounded-full" style="width: ${analysis.sentiment.institutional}%"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">News Impact</h3>
                        <div class="space-y-3 text-sm">
                            ${analysis.news.map((item, index) => `
                                <div class="flex items-start">
                                    <div class="${index === 0 ? 'bg-blue-500' : index === 1 ? 'bg-green-500' : 'bg-red-500'} p-1 rounded-full mr-2 mt-1">
                                        <i class="${index === 0 ? 'fas fa-newspaper' : index === 1 ? 'fas fa-chart-line' : 'fas fa-exclamation-triangle'} text-white text-xs"></i>
                                    </div>
                                    <div>
                                        <p class="font-medium">${item.title}</p>
                                        <p class="text-gray-400">${item.summary}</p>
                                    </div>
                                </div>
                            `).join('')}
                        </div>
                    </div>
                `;
                
                document.getElementById('fundamental-analysis').innerHTML = analysisHTML;
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading fundamental analysis:', error);
                document.getElementById('fundamental-analysis').innerHTML = `
                    <div class="bg-gray-700 rounded-lg p-4 text-center text-red-400">
                        <i class="fas fa-exclamation-triangle mr-2"></i> Failed to load fundamental analysis
                    </div>
                `;
            }
        }
        
        // Load risk management
        async function loadRiskManagement() {
            try {
                // In a real app, you would fetch from your API
                // const response = await axios.get(`${BASE_URL}/risk?api_key=${API_KEY}`);
                
                // Simulated response with realistic data
                const simulatedResponse = {
                    data: {
                        allocation: {
                            EURUSD: 35,
                            USDJPY: 25,
                            XAUUSD: 20,
                            Cash: 15,
                            Other: 5
                        },
                        parameters: {
                            max_risk: 2,
                            drawdown: 5,
                            volatility: 'Medium'
                        },
                        performance: {
                            win_rate: 78,
                            profit_factor: 2.4,
                            avg_win_loss: 1.8,
                            sharpe_ratio: 1.6
                        }
                    }
                };
                
                const riskData = simulatedResponse.data;
                let riskHTML = `
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-3">Portfolio Allocation</h3>
                        <div class="h-40">
                            <canvas id="allocationChart"></canvas>
                        </div>
                        <div class="mt-3 grid grid-cols-3 gap-2 text-xs">
                            <div class="flex items-center">
                                <div class="w-3 h-3 bg-blue-500 rounded-full mr-1"></div>
                                <span>EUR/USD</span>
                            </div>
                            <div class="flex items-center">
                                <div class="w-3 h-3 bg-green-500 rounded-full mr-1"></div>
                                <span>USD/JPY</span>
                            </div>
                            <div class="flex items-center">
                                <div class="w-3 h-3 bg-purple-500 rounded-full mr-1"></div>
                                <span>XAU/USD</span>
                            </div>
                            <div class="flex items-center">
                                <div class="w-3 h-3 bg-yellow-500 rounded-full mr-1"></div>
                                <span>Cash</span>
                            </div>
                            <div class="flex items-center">
                                <div class="w-3 h-3 bg-red-500 rounded-full mr-1"></div>
                                <span>Other</span>
                            </div>
                        </div>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-3">Risk Parameters</h3>
                        <div class="space-y-3 text-sm">
                            <div>
                                <div class="flex justify-between">
                                    <span>Max Risk per Trade</span>
                                    <span>${riskData.parameters.max_risk}%</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-blue-500 h-1.5 rounded-full" style="width: ${riskData.parameters.max_risk * 10}%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between">
                                    <span>Daily Drawdown Limit</span>
                                    <span>${riskData.parameters.drawdown}%</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-green-500 h-1.5 rounded-full" style="width: ${riskData.parameters.drawdown * 2}%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between">
                                    <span>Portfolio Volatility</span>
                                    <span>${riskData.parameters.volatility}</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5 mt-1">
                                    <div class="bg-yellow-500 h-1.5 rounded-full" style="width: ${riskData.parameters.volatility === 'Low' ? 30 : riskData.parameters.volatility === 'Medium' ? 60 : 90}%"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-2">Performance Metrics</h3>
                        <div class="grid grid-cols-2 gap-3 text-sm">
                            <div class="bg-gray-600 p-2 rounded">
                                <div class="text-gray-400">Win Rate</div>
                                <div class="font-bold text-green-500">${riskData.performance.win_rate}%</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded">
                                <div class="text-gray-400">Profit Factor</div>
                                <div class="font-bold text-green-500">${riskData.performance.profit_factor}</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded">
                                <div class="text-gray-400">Avg Win/Loss</div>
                                <div class="font-bold text-green-500">${riskData.performance.avg_win_loss}</div>
                            </div>
                            <div class="bg-gray-600 p-2 rounded">
                                <div class="text-gray-400">Sharpe Ratio</div>
                                <div class="font-bold text-green-500">${riskData.performance.sharpe_ratio}</div>
                            </div>
                        </div>
                    </div>
                `;
                
                document.getElementById('risk-management').innerHTML = riskHTML;
                
                // Initialize allocation chart
                if (allocationChart) {
                    allocationChart.destroy();
                }
                
                const ctx = document.getElementById('allocationChart').getContext('2d');
                allocationChart = new Chart(ctx, {
                    type: 'doughnut',
                    data: {
                        labels: ['EUR/USD', 'USD/JPY', 'XAU/USD', 'Cash', 'Other'],
                        datasets: [{
                            data: [
                                riskData.allocation.EURUSD,
                                riskData.allocation.USDJPY,
                                riskData.allocation.XAUUSD,
                                riskData.allocation.Cash,
                                riskData.allocation.Other
                            ],
                            backgroundColor: [
                                '#3b82f6',
                                '#10b981',
                                '#8b5cf6',
                                '#f59e0b',
                                '#ef4444'
                            ],
                            borderWidth: 0
                        }]
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        plugins: {
                            legend: { display: false }
                        },
                        cutout: '70%'
                    }
                });
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading risk management:', error);
                document.getElementById('risk-management').innerHTML = `
                    <div class="bg-gray-700 rounded-lg p-4 text-center text-red-400">
                        <i class="fas fa-exclamation-triangle mr-2"></i> Failed to load risk data
                    </div>
                `;
            }
        }
        
        // Load trade execution
        async function loadTradeExecution() {
            try {
                // In a real app, you would fetch from your API
                // const response = await axios.get(`${BASE_URL}/trades?api_key=${API_KEY}`);
                
                // Simulated response with realistic data
                const simulatedResponse = {
                    data: {
                        active_trades: [
                            {
                                pair: 'EURUSD',
                                direction: 'BUY',
                                entry: 1.0975,
                                current: 1.0985,
                                pnl: 1.2
                            },
                            {
                                pair: 'USDJPY',
                                direction: 'SELL',
                                entry: 138.85,
                                current: 139.50,
                                pnl: -0.5
                            }
                        ],
                        total_pnl: 342.50
                    }
                };
                
                const trades = simulatedResponse.data;
                let executionHTML = `
                    <div class="bg-gray-700 rounded-lg p-4">
                        <div class="flex justify-between items-center mb-3">
                            <h3 class="font-medium">Quick Trade</h3>
                            <div class="relative">
                                <select class="bg-gray-600 text-white text-sm rounded px-2 py-1">
                                    <option>EUR/USD</option>
                                    <option>USD/JPY</option>
                                    <option>GBP/USD</option>
                                    <option>XAU/USD</option>
                                </select>
                            </div>
                        </div>
                        <div class="grid grid-cols-2 gap-2 mb-3">
                            <button class="bg-green-600 hover:bg-green-700 py-2 rounded font-medium">
                                BUY
                            </button>
                            <button class="bg-red-600 hover:bg-red-700 py-2 rounded font-medium">
                                SELL
                            </button>
                        </div>
                        <div class="space-y-2 text-sm">
                            <div>
                                <label class="block text-gray-400 mb-1">Amount</label>
                                <div class="relative">
                                    <input type="number" class="w-full bg-gray-600 border border-gray-500 rounded px-3 py-1" value="1.00">
                                    <span class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400">LOT</span>
                                </div>
                            </div>
                            <div class="grid grid-cols-2 gap-2">
                                <div>
                                    <label class="block text-gray-400 mb-1">Take Profit</label>
                                    <input type="number" class="w-full bg-gray-600 border border-gray-500 rounded px-3 py-1" value="1.1025">
                                </div>
                                <div>
                                    <label class="block text-gray-400 mb-1">Stop Loss</label>
                                    <input type="number" class="w-full bg-gray-600 border border-gray-500 rounded px-3 py-1" value="1.0950">
                                </div>
                            </div>
                        </div>
                        <button class="w-full bg-blue-600 hover:bg-blue-700 py-2 rounded font-medium mt-3">
                            Execute Trade
                        </button>
                    </div>
                    <div class="bg-gray-700 rounded-lg p-4">
                        <h3 class="font-medium mb-3">Active Trades</h3>
                        <div class="space-y-3 text-sm">
                            ${trades.active_trades.map(trade => `
                                <div class="flex justify-between items-center p-2 bg-gray-600 rounded">
                                    <div>
                                        <p class="font-medium">${trade.pair}</p>
                                        <p class="text-gray-400">${trade.direction} @ ${trade.entry}</p>
                                    </div>
                                    <div class="text-right">
                                        <p class="${trade.pnl >= 0 ? 'text-green-500' : 'text-red-500'}">${trade.pnl >= 0 ? '+' : ''}${trade.pnl}%</p>
                                        <p class="text-gray-400">${trade.current}</p>
                                    </div>
                                </div>
                            `).join('')}
                        </div>
                        <div class="mt-3">
                            <div class="flex justify-between text-sm mb-1">
                                <span class="text-gray-400">Total P&L</span>
                                <span class="text-green-500">+$${trades.total_pnl.toFixed(2)}</span>
                            </div>
                            <div class="w-full bg-gray-600 rounded-full h-1.5">
                                <div class="bg-green-500 h-1.5 rounded-full" style="width: 65%"></div>
                            </div>
                        </div>
                    </div>
                `;
                
                document.getElementById('trade-execution').innerHTML = executionHTML;
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading trade execution:', error);
                document.getElementById('trade-execution').innerHTML = `
                    <div class="bg-gray-700 rounded-lg p-4 text-center text-red-400">
                        <i class="fas fa-exclamation-triangle mr-2"></i> Failed to load trade data
                    </div>
                `;
            }
        }
        
        // Load AI insights
        async function loadAIInsights() {
            try {
                // In a real app, you would fetch from your API
                // const response = await axios.get(`${BASE_URL}/insights?symbol=${currentPair}&api_key=${API_KEY}`);
                
                // Simulated response with realistic data
                const simulatedResponse = {
                    data: {
                        outlook: "The EUR/USD pair is showing strong bullish momentum with confirmation from both technical and fundamental factors. Technical indicators show a bullish flag pattern with RSI in healthy territory (62.4). Fundamentally, expectations of a Fed pause and ECB tightening bias support further EUR gains. AI confidence in this setup is 87%.",
                        technical_summary: [
                            "Bullish EMA crossover (10 > 20 > 50)",
                            "Price above key Fibonacci level (1.0950)",
                            "Volume confirms upward momentum",
                            "Watch for resistance at 1.1025 (R1)"
                        ],
                        fundamental_summary: [
                            "Fed expected to pause rate hikes",
                            "Eurozone core inflation remains elevated",
                            "Risk sentiment improving (supporting EUR)",
                            "Monitor US NFP data tomorrow"
                        ],
                        entry_zones: {
                            primary: "1.0970 - 1.0980",
                            secondary: "1.0950 - 1.0960"
                        },
                        risk_assessment: {
                            reward_risk: 3.2,
                            probability: 72,
                            expected_move: "+75 pips / -25 pips",
                            risk_level: 30
                        }
                    }
                };
                
                const insights = simulatedResponse.data;
                let insightsHTML = `
                    <div class="bg-gray-700 rounded-lg p-4 mb-4">
                        <div class="flex items-start">
                            <div class="bg-blue-500 p-2 rounded-full mr-3">
                                <i class="fas fa-brain text-white"></i>
                            </div>
                            <div>
                                <h3 class="font-medium mb-2">Market Outlook</h3>
                                <p class="text-sm text-gray-300">
                                    ${insights.outlook}
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div class="bg-gray-700 rounded-lg p-4">
                            <h3 class="font-medium mb-2">Technical Summary</h3>
                            <ul class="text-sm space-y-2 text-gray-300">
                                ${insights.technical_summary.map(item => `
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle ${item.includes('Watch') ? 'text-yellow-500' : 'text-green-500'} mr-2 mt-1"></i>
                                        <span>${item}</span>
                                    </li>
                                `).join('')}
                            </ul>
                        </div>
                        <div class="bg-gray-700 rounded-lg p-4">
                            <h3 class="font-medium mb-2">Fundamental Summary</h3>
                            <ul class="text-sm space-y-2 text-gray-300">
                                ${insights.fundamental_summary.map(item => `
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle ${item.includes('Monitor') ? 'text-yellow-500' : 'text-green-500'} mr-2 mt-1"></i>
                                        <span>${item}</span>
                                    </li>
                                `).join('')}
                            </ul>
                        </div>
                        <div class="bg-gray-700 rounded-lg p-4">
                            <h3 class="font-medium mb-2">Optimal Entry Zones</h3>
                            <div class="flex items-center justify-between text-sm mb-2">
                                <span class="text-gray-400">Primary</span>
                                <span>${insights.entry_zones.primary}</span>
                                <span class="text-green-500">Current</span>
                            </div>
                            <div class="flex items-center justify-between text-sm mb-2">
                                <span class="text-gray-400">Secondary</span>
                                <span>${insights.entry_zones.secondary}</span>
                                <span class="text-gray-400">Wait</span>
                            </div>
                            <div class="w-full bg-gray-600 rounded-full h-2 mt-2">
                                <div class="bg-gradient-to-r from-green-500 to-blue-500 h-2 rounded-full" style="width: 85%"></div>
                            </div>
                        </div>
                        <div class="bg-gray-700 rounded-lg p-4">
                            <h3 class="font-medium mb-2">Risk Assessment</h3>
                            <div class="flex justify-between text-sm mb-1">
                                <span class="text-gray-400">Reward/Risk Ratio</span>
                                <span>${insights.risk_assessment.reward_risk}:1</span>
                            </div>
                            <div class="flex justify-between text-sm mb-1">
                                <span class="text-gray-400">Probability of Success</span>
                                <span>${insights.risk_assessment.probability}%</span>
                            </div>
                            <div class="flex justify-between text-sm mb-1">
                                <span class="text-gray-400">Expected Move</span>
                                <span>${insights.risk_assessment.expected_move}</span>
                            </div>
                            <div class="mt-2">
                                <div class="flex justify-between text-xs text-gray-400 mb-1">
                                    <span>Low Risk</span>
                                    <span>High Risk</span>
                                </div>
                                <div class="w-full bg-gray-600 rounded-full h-1.5">
                                    <div class="bg-green-500 h-1.5 rounded-full" style="width: ${insights.risk_assessment.risk_level}%"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                `;
                
                document.getElementById('ai-insights').innerHTML = insightsHTML;
                
                // Update timestamp
                updateTimestamp();
            } catch (error) {
                console.error('Error loading AI insights:', error);
                document.getElementById('ai-insights').innerHTML = `
                    <div class="bg-gray-700 rounded-lg p-4 text-center text-red-400">
                        <i class="fas fa-exclamation-triangle mr-2"></i> Failed to load AI insights
                    </div>
                `;
            }
        }
        
        // Update news ticker
        async function updateNewsTicker() {
            try {
                // In a real app, you would fetch from a news API
                // const response = await axios.get(`${BASE_URL}/news?api_key=${API_KEY}`);
                
                // Simulated news items
                const newsItems = [
                    "USD: Fed signals potential rate pause in June",
                    "EUR: ECB President Lagarde hints at further tightening",
                    "GBP: UK inflation falls more than expected to 6.8%",
                    "JPY: BOJ maintains ultra-loose policy, yen weakens",
                    "Gold prices rise amid banking sector concerns"
                ];
                
                const tickerContent = newsItems.map(item => `<span class="mr-8">${item} | </span>`).join('');
                document.getElementById('news-ticker').innerHTML = tickerContent;
            } catch (error) {
                console.error('Error updating news ticker:', error);
                document.getElementById('news-ticker').innerHTML = 'Market news currently unavailable';
            }
        }
        
        // Update dashboard timestamp
        function updateTimestamp() {
            const now = new Date();
            document.getElementById('last-update').textContent = now.toLocaleTimeString();
        }
        
        // Update all dashboard components
        function updateDashboard() {
            loadMarketData();
            loadMainChartData();
            loadTradingSignals();
            loadTechnicalAnalysis();
            loadFundamentalAnalysis();
            loadRiskManagement();
            loadTradeExecution();
            loadAIInsights();
            updateNewsTicker();
        }
        
        // Helper function to generate random chart data
        function generateRandomChartData(count, volatility, base = 1.0) {
            const data = [];
            let current = base;
            
            for (let i = 0; i < count; i++) {
                // Add some randomness with slight upward bias
                const change = (Math.random() - 0.3) * volatility;
                current += change;
                data.push(current);
            }
            
            return data;
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=Raven710/basic-frame-trade-bot" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
</html>