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 (
Crypto Engine
Real-time reinforcement learning for cryptocurrency trading strategies
Market Data Feeds
Exchange API connections status
{loading ? (
{Array(3).fill(0).map((_, idx) => (
))}
) : (
<>
Trade Data
Executed transactions
86 tps
Sentiment Data
Social feeds
>
)}
RL Training Status
Reinforcement learning pipeline
{loading ? (
{Array(3).fill(0).map((_, idx) => (
))}
) : (
<>
Last Training
35 minutes ago
crypto_trader v3.7.2
Trades since last run
651 / 1,000
Training Schedule
Hourly
Every hour or after 1,000 new market trades
>
)}
Risk Controls
Trading limits and performance metrics
{loading ? (
{Array(3).fill(0).map((_, idx) => (
))}
) : (
<>
Max Drawdown
2.1% / 5.0%
Current / Limit
Position Sizing
1.8% / 2.0%
Current / Limit
Sharpe Ratio
1.42
Above 1.0 threshold (good)
>
)}
RL Algorithm
Performance
Recent Trades
TD3 Reinforcement Learning
Twin Delayed Deep Deterministic Policy Gradient implementation
Algorithm Configuration
Actor Network
3 layers, 256 units
Critic Networks
Twin Q-networks
Update Frequency
Every 2 steps
Target Update
Soft, τ=0.005
Exploration
Gaussian noise
State Vector
Price Features
Moving averages (7 timeframes), Bollinger bands, RSI
Volume Features
VWAP, OBV, volume profile by price level
Sentiment Features
Social sentiment score, news sentiment, fear & greed
Hierarchical RL Structure
{/* Meta-controller */}
Meta-Controller
Market regime classifier
{/* Connector lines */}
{/* Sub-agents container */}
{/* Sub-agent 1 */}
Trend Agent
Long timeframes
{/* Sub-agent 2 */}
Range Agent
Consolidation
{/* Sub-agent 3 */}
Volatility Agent
News events
{/* Action space */}
Continuous Action Space:
Position Size
0-2% of capital
Direction
-1 (short) to +1 (long)
Trading Performance
Key metrics from the reinforcement learning model
Returns
+8.3%
Last 30 days
Sharpe Ratio
1.42
Risk-adjusted return
Max Drawdown
-2.1%
Within target range
Performance Breakdown
| Metric |
Value |
Target |
Status |
| Sharpe Ratio |
1.42 |
≥ 1.0 |
✓ Pass |
| Max Drawdown |
-2.1% |
≤ 5.0% |
✓ Pass |
| Win Rate |
58.3% |
≥ 55.0% |
✓ Pass |
| Profit Factor |
1.83 |
≥ 1.5 |
✓ Pass |
| Avg Win / Avg Loss |
1.31 |
≥ 1.0 |
✓ Pass |
Recent Trading Activity
Trades executed by the reinforcement learning agent
| Time |
Symbol |
Action |
Price |
Size |
P/L |
Strategy |
{loading ? (
<>
{Array(5).fill(0).map((_, idx) => (
|
|
|
|
|
|
|
))}
>
) : (
<>
| 14:32:15 |
BTC/USD |
Buy
|
$61,245.30 |
0.082 BTC |
+$137.62 |
Trend Agent |
| 14:05:52 |
ETH/USD |
Sell
|
$3,128.75 |
1.5 ETH |
+$78.45 |
Range Agent |
| 13:48:07 |
SOL/USD |
Buy
|
$146.82 |
10.5 SOL |
-$42.20 |
Volatility Agent |
| 13:22:34 |
XRP/USD |
Sell
|
$0.5231 |
1,500 XRP |
+$28.35 |
Range Agent |
| 13:01:15 |
BNB/USD |
Buy
|
$572.45 |
2.1 BNB |
+$64.80 |
Trend Agent |
>
)}
Training History
Past reinforcement learning model versions
| Version |
Date |
Sharpe |
Win Rate |
Status |
{loading ? (
<>
{Array(5).fill(0).map((_, idx) => (
|
|
|
|
|
))}
>
) : (
<>
| v3.7.2 |
2025-05-09 13:00 |
1.42 |
58.3% |
Active
|
| v3.7.1 |
2025-05-09 12:00 |
1.39 |
57.9% |
Archived
|
| v3.7.0 |
2025-05-09 11:00 |
1.36 |
57.2% |
Archived
|
| v3.6.9 |
2025-05-09 10:00 |
1.34 |
56.8% |
Archived
|
| v3.6.8 |
2025-05-09 09:00 |
0.98 |
54.3% |
Failed
|
>
)}
);
};
export default CryptoEngine;