File size: 35,185 Bytes
60b2d8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import React, { useState, useEffect } from 'react';
import Sidebar from '../components/dashboard/Sidebar';
import Header from '../components/dashboard/Header';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Progress } from "@/components/ui/progress";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { CheckCircle, AlertTriangle, Database, Shield, RefreshCw, TrendingUp } from 'lucide-react';
import { useToast } from "@/components/ui/use-toast";

const CryptoEngine = () => {
  const [loading, setLoading] = useState(true);
  const { toast } = useToast();
  
  useEffect(() => {
    // Simulate loading time
    const timer = setTimeout(() => {
      setLoading(false);
    }, 800);
    
    return () => clearTimeout(timer);
  }, []);

  const handleTrainModel = () => {
    toast({
      title: "Training Initiated",
      description: "Crypto trader model training has started. Estimated completion time: 15 minutes.",
    });
  };

  return (
    <div className="flex h-screen bg-gray-100 dark:bg-factory-blue-dark text-gray-900 dark:text-gray-100">
      <Sidebar />
      
      <div className="flex-1 flex flex-col overflow-hidden">
        <Header />
        
        <main className="flex-1 overflow-x-hidden overflow-y-auto p-4">
          <div className="mb-6">
            <h1 className="text-2xl font-bold mb-2">Crypto Engine</h1>
            <p className="text-gray-500 dark:text-gray-400">
              Real-time reinforcement learning for cryptocurrency trading strategies
            </p>
          </div>
          
          <div className="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
            <Card>
              <CardHeader>
                <CardTitle className="flex items-center">
                  <Database className="h-5 w-5 mr-2" />
                  Market Data Feeds
                </CardTitle>
                <CardDescription>Exchange API connections status</CardDescription>
              </CardHeader>
              <CardContent className="space-y-4">
                {loading ? (
                  <div className="space-y-4">
                    {Array(3).fill(0).map((_, idx) => (
                      <div key={idx} className="animate-pulse space-y-2">
                        <div className="h-5 bg-gray-200 dark:bg-factory-blue-light rounded w-1/2"></div>
                        <div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-3/4"></div>
                      </div>
                    ))}
                  </div>
                ) : (
                  <>
                    <div className="flex items-center justify-between pb-3 border-b dark:border-factory-blue-light">
                      <div>
                        <div className="font-medium">Order Books</div>
                        <div className="text-sm text-gray-500 dark:text-gray-400">Level 2 data</div>
                      </div>
                      <div className="flex items-center text-green-600 dark:text-green-400">
                        <span className="mr-1">Online</span>
                        <CheckCircle className="h-4 w-4" />
                      </div>
                    </div>
                    <div className="flex items-center justify-between pb-3 border-b dark:border-factory-blue-light">
                      <div>
                        <div className="font-medium">Trade Data</div>
                        <div className="text-sm text-gray-500 dark:text-gray-400">Executed transactions</div>
                      </div>
                      <div className="flex items-center text-green-600 dark:text-green-400">
                        <span className="mr-1">86 tps</span>
                        <CheckCircle className="h-4 w-4" />
                      </div>
                    </div>
                    <div className="flex items-center justify-between">
                      <div>
                        <div className="font-medium">Sentiment Data</div>
                        <div className="text-sm text-gray-500 dark:text-gray-400">Social feeds</div>
                      </div>
                      <div className="flex items-center text-yellow-600 dark:text-yellow-400">
                        <span className="mr-1">Delayed</span>
                        <AlertTriangle className="h-4 w-4" />
                      </div>
                    </div>
                  </>
                )}
              </CardContent>
            </Card>
            
            <Card>
              <CardHeader>
                <CardTitle className="flex items-center">
                  <RefreshCw className="h-5 w-5 mr-2" />
                  RL Training Status
                </CardTitle>
                <CardDescription>Reinforcement learning pipeline</CardDescription>
              </CardHeader>
              <CardContent className="space-y-4">
                {loading ? (
                  <div className="space-y-4">
                    {Array(3).fill(0).map((_, idx) => (
                      <div key={idx} className="animate-pulse space-y-2">
                        <div className="h-5 bg-gray-200 dark:bg-factory-blue-light rounded w-1/2"></div>
                        <div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-3/4"></div>
                      </div>
                    ))}
                  </div>
                ) : (
                  <>
                    <div className="pb-3 border-b dark:border-factory-blue-light">
                      <div className="flex justify-between mb-1">
                        <span className="font-medium">Last Training</span>
                        <Badge variant="outline">35 minutes ago</Badge>
                      </div>
                      <div className="text-sm text-gray-500 dark:text-gray-400 mb-2">crypto_trader v3.7.2</div>
                      <div className="w-full">
                        <div className="text-xs mb-1 flex justify-between">
                          <span>Trades since last run</span>
                          <span>651 / 1,000</span>
                        </div>
                        <Progress value={65.1} className="h-2" />
                      </div>
                    </div>
                    <div className="pb-3 border-b dark:border-factory-blue-light">
                      <div className="flex justify-between mb-1">
                        <span className="font-medium">Training Schedule</span>
                        <Badge variant="outline" className="bg-purple-100 dark:bg-purple-900/20">Hourly</Badge>
                      </div>
                      <div className="text-sm text-gray-500 dark:text-gray-400">
                        Every hour or after 1,000 new market trades
                      </div>
                    </div>
                    <div className="flex flex-col space-y-2">
                      <button 
                        className="bg-factory-teal hover:bg-factory-teal/90 text-white px-4 py-2 rounded"
                        onClick={handleTrainModel}
                      >
                        Trigger Manual Training
                      </button>
                    </div>
                  </>
                )}
              </CardContent>
            </Card>
            
            <Card>
              <CardHeader>
                <CardTitle className="flex items-center">
                  <Shield className="h-5 w-5 mr-2" />
                  Risk Controls
                </CardTitle>
                <CardDescription>Trading limits and performance metrics</CardDescription>
              </CardHeader>
              <CardContent className="space-y-4">
                {loading ? (
                  <div className="space-y-4">
                    {Array(3).fill(0).map((_, idx) => (
                      <div key={idx} className="animate-pulse space-y-2">
                        <div className="h-5 bg-gray-200 dark:bg-factory-blue-light rounded w-1/2"></div>
                        <div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-3/4"></div>
                      </div>
                    ))}
                  </div>
                ) : (
                  <>
                    <div className="pb-3 border-b dark:border-factory-blue-light">
                      <div className="flex justify-between mb-1">
                        <span className="font-medium">Max Drawdown</span>
                        <span>2.1% / 5.0%</span>
                      </div>
                      <div className="text-sm text-gray-500 dark:text-gray-400 mb-2">Current / Limit</div>
                      <div className="w-full">
                        <Progress value={42} className="h-2" />
                      </div>
                    </div>
                    <div className="pb-3 border-b dark:border-factory-blue-light">
                      <div className="flex justify-between mb-1">
                        <span className="font-medium">Position Sizing</span>
                        <span>1.8% / 2.0%</span>
                      </div>
                      <div className="text-sm text-gray-500 dark:text-gray-400 mb-2">Current / Limit</div>
                      <div className="w-full">
                        <Progress value={90} className="h-2" />
                      </div>
                    </div>
                    <div>
                      <div className="flex justify-between mb-1">
                        <span className="font-medium">Sharpe Ratio</span>
                        <span className="text-green-600 dark:text-green-400">1.42</span>
                      </div>
                      <div className="text-sm text-gray-500 dark:text-gray-400">
                        Above 1.0 threshold (good)
                      </div>
                    </div>
                  </>
                )}
              </CardContent>
            </Card>
          </div>
          
          <Tabs defaultValue="algorithm" className="mb-6">
            <TabsList className="mb-4">
              <TabsTrigger value="algorithm"><RefreshCw className="h-4 w-4 mr-2" /> RL Algorithm</TabsTrigger>
              <TabsTrigger value="performance"><TrendingUp className="h-4 w-4 mr-2" /> Performance</TabsTrigger>
              <TabsTrigger value="trades"><Database className="h-4 w-4 mr-2" /> Recent Trades</TabsTrigger>
            </TabsList>
            
            <TabsContent value="algorithm">
              <Card>
                <CardHeader>
                  <CardTitle>TD3 Reinforcement Learning</CardTitle>
                  <CardDescription>Twin Delayed Deep Deterministic Policy Gradient implementation</CardDescription>
                </CardHeader>
                <CardContent>
                  <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div className="space-y-4">
                      <div className="bg-gray-50 dark:bg-factory-blue-light rounded-md p-4">
                        <h3 className="text-sm font-semibold mb-3">Algorithm Configuration</h3>
                        <div className="grid grid-cols-2 gap-3 text-sm">
                          <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                            <p className="font-medium">Actor Network</p>
                            <p className="text-xs">3 layers, 256 units</p>
                          </div>
                          <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                            <p className="font-medium">Critic Networks</p>
                            <p className="text-xs">Twin Q-networks</p>
                          </div>
                          <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                            <p className="font-medium">Update Frequency</p>
                            <p className="text-xs">Every 2 steps</p>
                          </div>
                          <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                            <p className="font-medium">Target Update</p>
                            <p className="text-xs">Soft, τ=0.005</p>
                          </div>
                          <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                            <p className="font-medium">Exploration</p>
                            <p className="text-xs">Gaussian noise</p>
                          </div>
                          <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                            <p className="font-medium">Batch Size</p>
                            <p className="text-xs">256 trades</p>
                          </div>
                        </div>
                      </div>
                      
                      <div className="bg-gray-50 dark:bg-factory-blue-light rounded-md p-4">
                        <h3 className="text-sm font-semibold mb-3">State Vector</h3>
                        <div className="space-y-2">
                          <div className="bg-factory-teal/10 dark:bg-factory-teal/20 p-2 rounded">
                            <p className="font-medium">Price Features</p>
                            <p className="text-xs">Moving averages (7 timeframes), Bollinger bands, RSI</p>
                          </div>
                          <div className="bg-factory-teal/10 dark:bg-factory-teal/20 p-2 rounded">
                            <p className="font-medium">Volume Features</p>
                            <p className="text-xs">VWAP, OBV, volume profile by price level</p>
                          </div>
                          <div className="bg-factory-teal/10 dark:bg-factory-teal/20 p-2 rounded">
                            <p className="font-medium">Sentiment Features</p>
                            <p className="text-xs">Social sentiment score, news sentiment, fear & greed</p>
                          </div>
                        </div>
                      </div>
                    </div>
                    
                    <div className="bg-gray-50 dark:bg-factory-blue-light rounded-md p-4">
                      <h3 className="text-sm font-semibold mb-3">Hierarchical RL Structure</h3>
                      <div className="relative">
                        {/* Meta-controller */}
                        <div className="bg-factory-blue/30 dark:bg-factory-blue-light/90 p-3 rounded-md mb-6 text-center">
                          <p className="font-medium">Meta-Controller</p>
                          <p className="text-xs">Market regime classifier</p>
                        </div>
                        
                        {/* Connector lines */}
                        <div className="absolute left-1/2 top-12 w-0.5 h-6 bg-gray-400 dark:bg-gray-500 transform -translate-x-1/2"></div>
                        
                        {/* Sub-agents container */}
                        <div className="grid grid-cols-3 gap-3 mt-2">
                          {/* Sub-agent 1 */}
                          <div className="bg-factory-teal/20 dark:bg-factory-teal/30 p-2 rounded-md text-center relative">
                            <div className="absolute -top-6 left-1/2 w-0.5 h-6 bg-gray-400 dark:bg-gray-500 transform -translate-x-1/2"></div>
                            <p className="font-medium">Trend Agent</p>
                            <p className="text-xs">Long timeframes</p>
                          </div>
                          
                          {/* Sub-agent 2 */}
                          <div className="bg-factory-teal/20 dark:bg-factory-teal/30 p-2 rounded-md text-center relative">
                            <div className="absolute -top-6 left-1/2 w-0.5 h-6 bg-gray-400 dark:bg-gray-500 transform -translate-x-1/2"></div>
                            <p className="font-medium">Range Agent</p>
                            <p className="text-xs">Consolidation</p>
                          </div>
                          
                          {/* Sub-agent 3 */}
                          <div className="bg-factory-teal/20 dark:bg-factory-teal/30 p-2 rounded-md text-center relative">
                            <div className="absolute -top-6 left-1/2 w-0.5 h-6 bg-gray-400 dark:bg-gray-500 transform -translate-x-1/2"></div>
                            <p className="font-medium">Volatility Agent</p>
                            <p className="text-xs">News events</p>
                          </div>
                        </div>
                        
                        {/* Action space */}
                        <div className="mt-6">
                          <p className="text-sm font-semibold mb-2">Continuous Action Space:</p>
                          <div className="grid grid-cols-2 gap-3">
                            <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                              <p className="font-medium">Position Size</p>
                              <p className="text-xs">0-2% of capital</p>
                            </div>
                            <div className="bg-factory-blue/10 dark:bg-factory-blue-light/70 p-2 rounded">
                              <p className="font-medium">Direction</p>
                              <p className="text-xs">-1 (short) to +1 (long)</p>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </CardContent>
              </Card>
            </TabsContent>
            
            <TabsContent value="performance">
              <Card>
                <CardHeader>
                  <CardTitle>Trading Performance</CardTitle>
                  <CardDescription>Key metrics from the reinforcement learning model</CardDescription>
                </CardHeader>
                <CardContent>
                  <div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
                    <div className="bg-gray-50 dark:bg-factory-blue-light rounded-md p-4">
                      <h3 className="text-sm font-semibold mb-2">Returns</h3>
                      <div className="text-3xl font-bold text-factory-teal">+8.3%</div>
                      <p className="text-xs text-gray-500 dark:text-gray-400">Last 30 days</p>
                    </div>
                    <div className="bg-gray-50 dark:bg-factory-blue-light rounded-md p-4">
                      <h3 className="text-sm font-semibold mb-2">Sharpe Ratio</h3>
                      <div className="text-3xl font-bold text-factory-teal">1.42</div>
                      <p className="text-xs text-gray-500 dark:text-gray-400">Risk-adjusted return</p>
                    </div>
                    <div className="bg-gray-50 dark:bg-factory-blue-light rounded-md p-4">
                      <h3 className="text-sm font-semibold mb-2">Max Drawdown</h3>
                      <div className="text-3xl font-bold text-yellow-500">-2.1%</div>
                      <p className="text-xs text-gray-500 dark:text-gray-400">Within target range</p>
                    </div>
                  </div>
                  
                  <div className="space-y-4">
                    <h3 className="text-sm font-semibold">Performance Breakdown</h3>
                    <div className="overflow-x-auto">
                      <table className="w-full text-sm">
                        <thead>
                          <tr className="border-b dark:border-factory-blue-light">
                            <th className="text-left py-2 px-4">Metric</th>
                            <th className="text-left py-2 px-4">Value</th>
                            <th className="text-left py-2 px-4">Target</th>
                            <th className="text-left py-2 px-4">Status</th>
                          </tr>
                        </thead>
                        <tbody>
                          <tr className="border-b dark:border-factory-blue-light">
                            <td className="py-2 px-4">Sharpe Ratio</td>
                            <td className="py-2 px-4">1.42</td>
                            <td className="py-2 px-4">≥ 1.0</td>
                            <td className="py-2 px-4 text-green-600 dark:text-green-400">✓ Pass</td>
                          </tr>
                          <tr className="border-b dark:border-factory-blue-light">
                            <td className="py-2 px-4">Max Drawdown</td>
                            <td className="py-2 px-4">-2.1%</td>
                            <td className="py-2 px-4">≤ 5.0%</td>
                            <td className="py-2 px-4 text-green-600 dark:text-green-400">✓ Pass</td>
                          </tr>
                          <tr className="border-b dark:border-factory-blue-light">
                            <td className="py-2 px-4">Win Rate</td>
                            <td className="py-2 px-4">58.3%</td>
                            <td className="py-2 px-4">≥ 55.0%</td>
                            <td className="py-2 px-4 text-green-600 dark:text-green-400">✓ Pass</td>
                          </tr>
                          <tr className="border-b dark:border-factory-blue-light">
                            <td className="py-2 px-4">Profit Factor</td>
                            <td className="py-2 px-4">1.83</td>
                            <td className="py-2 px-4">≥ 1.5</td>
                            <td className="py-2 px-4 text-green-600 dark:text-green-400">✓ Pass</td>
                          </tr>
                          <tr className="border-b dark:border-factory-blue-light">
                            <td className="py-2 px-4">Avg Win / Avg Loss</td>
                            <td className="py-2 px-4">1.31</td>
                            <td className="py-2 px-4">≥ 1.0</td>
                            <td className="py-2 px-4 text-green-600 dark:text-green-400">✓ Pass</td>
                          </tr>
                        </tbody>
                      </table>
                    </div>
                  </div>
                </CardContent>
              </Card>
            </TabsContent>
            
            <TabsContent value="trades">
              <Card>
                <CardHeader>
                  <CardTitle>Recent Trading Activity</CardTitle>
                  <CardDescription>Trades executed by the reinforcement learning agent</CardDescription>
                </CardHeader>
                <CardContent>
                  <div className="overflow-x-auto">
                    <table className="w-full text-sm">
                      <thead>
                        <tr className="border-b dark:border-factory-blue-light">
                          <th className="text-left py-2 px-4">Time</th>
                          <th className="text-left py-2 px-4">Symbol</th>
                          <th className="text-left py-2 px-4">Action</th>
                          <th className="text-left py-2 px-4">Price</th>
                          <th className="text-left py-2 px-4">Size</th>
                          <th className="text-left py-2 px-4">P/L</th>
                          <th className="text-left py-2 px-4">Strategy</th>
                        </tr>
                      </thead>
                      <tbody>
                        {loading ? (
                          <>
                            {Array(5).fill(0).map((_, idx) => (
                              <tr key={idx} className="border-b dark:border-factory-blue-light animate-pulse">
                                <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-20"></div></td>
                                <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-16"></div></td>
                                <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-12"></div></td>
                                <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-20"></div></td>
                                <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-16"></div></td>
                                <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-12"></div></td>
                                <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-20"></div></td>
                              </tr>
                            ))}
                          </>
                        ) : (
                          <>
                            <tr className="border-b dark:border-factory-blue-light">
                              <td className="py-2 px-4">14:32:15</td>
                              <td className="py-2 px-4">BTC/USD</td>
                              <td className="py-2 px-4">
                                <span className="bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400 px-2 py-1 rounded-full text-xs">Buy</span>
                              </td>
                              <td className="py-2 px-4">$61,245.30</td>
                              <td className="py-2 px-4">0.082 BTC</td>
                              <td className="py-2 px-4 text-green-600 dark:text-green-400">+$137.62</td>
                              <td className="py-2 px-4">Trend Agent</td>
                            </tr>
                            <tr className="border-b dark:border-factory-blue-light">
                              <td className="py-2 px-4">14:05:52</td>
                              <td className="py-2 px-4">ETH/USD</td>
                              <td className="py-2 px-4">
                                <span className="bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400 px-2 py-1 rounded-full text-xs">Sell</span>
                              </td>
                              <td className="py-2 px-4">$3,128.75</td>
                              <td className="py-2 px-4">1.5 ETH</td>
                              <td className="py-2 px-4 text-green-600 dark:text-green-400">+$78.45</td>
                              <td className="py-2 px-4">Range Agent</td>
                            </tr>
                            <tr className="border-b dark:border-factory-blue-light">
                              <td className="py-2 px-4">13:48:07</td>
                              <td className="py-2 px-4">SOL/USD</td>
                              <td className="py-2 px-4">
                                <span className="bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400 px-2 py-1 rounded-full text-xs">Buy</span>
                              </td>
                              <td className="py-2 px-4">$146.82</td>
                              <td className="py-2 px-4">10.5 SOL</td>
                              <td className="py-2 px-4 text-red-600 dark:text-red-400">-$42.20</td>
                              <td className="py-2 px-4">Volatility Agent</td>
                            </tr>
                            <tr className="border-b dark:border-factory-blue-light">
                              <td className="py-2 px-4">13:22:34</td>
                              <td className="py-2 px-4">XRP/USD</td>
                              <td className="py-2 px-4">
                                <span className="bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400 px-2 py-1 rounded-full text-xs">Sell</span>
                              </td>
                              <td className="py-2 px-4">$0.5231</td>
                              <td className="py-2 px-4">1,500 XRP</td>
                              <td className="py-2 px-4 text-green-600 dark:text-green-400">+$28.35</td>
                              <td className="py-2 px-4">Range Agent</td>
                            </tr>
                            <tr className="border-b dark:border-factory-blue-light">
                              <td className="py-2 px-4">13:01:15</td>
                              <td className="py-2 px-4">BNB/USD</td>
                              <td className="py-2 px-4">
                                <span className="bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400 px-2 py-1 rounded-full text-xs">Buy</span>
                              </td>
                              <td className="py-2 px-4">$572.45</td>
                              <td className="py-2 px-4">2.1 BNB</td>
                              <td className="py-2 px-4 text-green-600 dark:text-green-400">+$64.80</td>
                              <td className="py-2 px-4">Trend Agent</td>
                            </tr>
                          </>
                        )}
                      </tbody>
                    </table>
                  </div>
                </CardContent>
              </Card>
            </TabsContent>
          </Tabs>
          
          <Card>
            <CardHeader>
              <CardTitle>Training History</CardTitle>
              <CardDescription>Past reinforcement learning model versions</CardDescription>
            </CardHeader>
            <CardContent>
              <div className="overflow-x-auto">
                <table className="w-full text-sm">
                  <thead>
                    <tr className="border-b dark:border-factory-blue-light">
                      <th className="text-left py-2 px-4">Version</th>
                      <th className="text-left py-2 px-4">Date</th>
                      <th className="text-left py-2 px-4">Sharpe</th>
                      <th className="text-left py-2 px-4">Win Rate</th>
                      <th className="text-left py-2 px-4">Status</th>
                    </tr>
                  </thead>
                  <tbody>
                    {loading ? (
                      <>
                        {Array(5).fill(0).map((_, idx) => (
                          <tr key={idx} className="border-b dark:border-factory-blue-light animate-pulse">
                            <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-16"></div></td>
                            <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-28"></div></td>
                            <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-12"></div></td>
                            <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-12"></div></td>
                            <td className="py-2 px-4"><div className="h-4 bg-gray-200 dark:bg-factory-blue-light rounded w-16"></div></td>
                          </tr>
                        ))}
                      </>
                    ) : (
                      <>
                        <tr className="border-b dark:border-factory-blue-light">
                          <td className="py-2 px-4 font-medium">v3.7.2</td>
                          <td className="py-2 px-4">2025-05-09 13:00</td>
                          <td className="py-2 px-4 text-green-600 dark:text-green-400">1.42</td>
                          <td className="py-2 px-4">58.3%</td>
                          <td className="py-2 px-4">
                            <span className="bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400 px-2 py-1 rounded-full text-xs">
                              Active
                            </span>
                          </td>
                        </tr>
                        <tr className="border-b dark:border-factory-blue-light">
                          <td className="py-2 px-4 font-medium">v3.7.1</td>
                          <td className="py-2 px-4">2025-05-09 12:00</td>
                          <td className="py-2 px-4">1.39</td>
                          <td className="py-2 px-4">57.9%</td>
                          <td className="py-2 px-4">
                            <span className="bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 px-2 py-1 rounded-full text-xs">
                              Archived
                            </span>
                          </td>
                        </tr>
                        <tr className="border-b dark:border-factory-blue-light">
                          <td className="py-2 px-4 font-medium">v3.7.0</td>
                          <td className="py-2 px-4">2025-05-09 11:00</td>
                          <td className="py-2 px-4">1.36</td>
                          <td className="py-2 px-4">57.2%</td>
                          <td className="py-2 px-4">
                            <span className="bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 px-2 py-1 rounded-full text-xs">
                              Archived
                            </span>
                          </td>
                        </tr>
                        <tr className="border-b dark:border-factory-blue-light">
                          <td className="py-2 px-4 font-medium">v3.6.9</td>
                          <td className="py-2 px-4">2025-05-09 10:00</td>
                          <td className="py-2 px-4">1.34</td>
                          <td className="py-2 px-4">56.8%</td>
                          <td className="py-2 px-4">
                            <span className="bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 px-2 py-1 rounded-full text-xs">
                              Archived
                            </span>
                          </td>
                        </tr>
                        <tr className="border-b dark:border-factory-blue-light">
                          <td className="py-2 px-4 font-medium">v3.6.8</td>
                          <td className="py-2 px-4">2025-05-09 09:00</td>
                          <td className="py-2 px-4 text-yellow-600 dark:text-yellow-400">0.98</td>
                          <td className="py-2 px-4">54.3%</td>
                          <td className="py-2 px-4">
                            <span className="bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400 px-2 py-1 rounded-full text-xs">
                              Failed
                            </span>
                          </td>
                        </tr>
                      </>
                    )}
                  </tbody>
                </table>
              </div>
            </CardContent>
          </Card>
        </main>
      </div>
    </div>
  );
};

export default CryptoEngine;