Spaces:
Running

File size: 5,126 Bytes
13b8627
8adc04f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13b8627
 
 
 
8adc04f
 
 
 
 
 
432676f
 
8adc04f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432676f
 
 
8adc04f
 
 
 
 
 
432676f
8adc04f
 
 
432676f
 
 
 
8adc04f
 
 
 
 
 
 
 
 
 
13b8627
 
 
 
8adc04f
 
 
 
 
 
 
 
 
432676f
8adc04f
 
 
 
 
 
 
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
import { ArrowUpRight, ArrowDownRight, AlertTriangle, Zap, FileJson } from 'lucide-react'

export default function SignalPanel({ signals, marketData }) {
  const latestSignal = signals[0]

  return (
    <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
      {/* Main Signal Card */}
      <div className="card p-6 flex flex-col justify-between relative overflow-hidden">
        <div className="absolute top-0 right-0 p-4 opacity-10">
          <Zap className="w-24 h-24 text-white" />
        </div>
        
        <div>
          <h3 className="text-dark-400 text-sm font-medium mb-1">AI Recommendation</h3>
          {latestSignal ? (
            <div className="flex items-center space-x-3">
              <div className={`p-3 rounded-lg ${
                latestSignal.action === 'LONG' ? 'bg-success/20 text-success' : 'bg-danger/20 text-danger'
              }`}>
                {latestSignal.action === 'LONG' ? <ArrowUpRight className="w-8 h-8" /> : <ArrowDownRight className="w-8 h-8" />}
              </div>
              <div>
                <div className={`text-2xl font-bold ${
                  latestSignal.action === 'LONG' ? 'text-success' : 'text-danger'
                }`}>
                  {latestSignal.action}
                </div>
                <div className="flex items-center space-x-2">
                  <span className="text-xs text-dark-400">{latestSignal.rule}</span>
                  {latestSignal.isCustom && <FileJson className="w-3 h-3 text-primary-400" />}
                </div>
              </div>
            </div>
          ) : (
            <div className="flex items-center space-x-3 text-dark-500">
              <AlertTriangle className="w-8 h-8 opacity-50" />
              <div>
                <div className="text-lg font-medium">Neutral / Hold</div>
                <div className="text-xs">No strong signals detected</div>
              </div>
            </div>
          )}
        </div>

        {latestSignal && (
          <div className="mt-4 pt-4 border-t border-dark-700">
            <div className="text-xs text-dark-400 mb-1">Reasoning:</div>
            <div className="text-sm text-white font-medium">{latestSignal.reason}</div>
            <div className="mt-2 flex items-center space-x-2">
              <span className="text-xs text-dark-500">Confidence:</span>
              <div className="flex-1 h-1.5 bg-dark-700 rounded-full overflow-hidden">
                <div 
                  className={`h-full rounded-full ${
                    latestSignal.confidence === 'High' ? 'bg-success w-full' : 
                    latestSignal.confidence === 'Medium' ? 'bg-primary-500 w-2/3' : 'bg-yellow-500 w-1/3'
                  }`}
                ></div>
              </div>
              <span className="text-xs text-white">{latestSignal.confidence}</span>
            </div>
          </div>
        )}
      </div>

      {/* Market Stats */}
      <div className="card p-6 flex flex-col justify-center space-y-4">
        <div>
          <div className="text-xs text-dark-400 mb-1">Current Price</div>
          <div className="text-2xl font-bold text-white">
            ${marketData.price ? marketData.price.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) : '---'}
          </div>
        </div>
        <div>
          <div className="text-xs text-dark-400 mb-1">RSI (14)</div>
          <div className={`text-lg font-medium ${
            marketData.rsi > 70 ? 'text-danger' : marketData.rsi < 30 ? 'text-success' : 'text-white'
          }`}>
            {marketData.rsi ? marketData.rsi.toFixed(2) : '---'}
          </div>
        </div>
        <div>
          <div className="text-xs text-dark-400 mb-1">24h Volume</div>
          <div className="text-lg font-medium text-white">
            {marketData.volume ? (marketData.volume / 1000000).toFixed(2) + 'M' : '---'}
          </div>
        </div>
      </div>

      {/* Active Rules Log */}
      <div className="card p-6 flex flex-col">
        <h3 className="text-dark-400 text-sm font-medium mb-3">Active Triggers</h3>
        <div className="flex-1 overflow-y-auto space-y-2 max-h-[160px]">
          {signals.length > 0 ? (
            signals.map((signal, idx) => (
              <div key={idx} className="flex items-center justify-between text-sm p-2 bg-dark-900 rounded border border-dark-700">
                <div className="flex items-center space-x-2">
                  <span className="text-white">{signal.rule}</span>
                  {signal.isCustom && <FileJson className="w-3 h-3 text-primary-400" />}
                </div>
                <span className={`text-xs px-2 py-0.5 rounded ${
                  signal.action === 'LONG' ? 'bg-success/20 text-success' : 'bg-danger/20 text-danger'
                }`}>
                  {signal.action}
                </span>
              </div>
            ))
          ) : (
            <div className="text-center text-dark-500 text-sm py-4">
              Scanning market conditions...
            </div>
          )}
        </div>
      </div>
    </div>
  )
}