✅ Restore working dashboard and TradingView analysis
- Fixed layout conflicts by removing minimal layout.tsx in favor of complete layout.js - Restored original AI Analysis page with full TradingView integration - Connected enhanced screenshot API to real TradingView automation service - Fixed screenshot gallery to handle both string and object formats - Added image serving API route for screenshot display - Resolved hydration mismatch issues with suppressHydrationWarning - All navigation pages working (Analysis, Trading, Automation, Settings) - TradingView automation successfully capturing screenshots from AI and DIY layouts - Docker Compose v2 compatibility ensured Working features: - Homepage with hero section and status cards - Navigation menu with Trading Bot branding - Real TradingView screenshot capture - AI-powered chart analysis - Multi-layout support (AI + DIY module) - Screenshot gallery with image serving - API endpoints for balance, status, screenshots, trading
This commit is contained in:
@@ -3,26 +3,34 @@ import React, { useState } from 'react'
|
||||
|
||||
interface TradeParams {
|
||||
symbol: string
|
||||
side: 'BUY' | 'SELL'
|
||||
side: 'LONG' | 'SHORT'
|
||||
amount: number
|
||||
leverage: number
|
||||
orderType?: 'MARKET' | 'LIMIT'
|
||||
price?: number
|
||||
stopLoss?: number
|
||||
takeProfit?: number
|
||||
stopLossType?: string
|
||||
takeProfitType?: string
|
||||
}
|
||||
|
||||
export default function DriftTradingPanel() {
|
||||
const [symbol, setSymbol] = useState('SOLUSD')
|
||||
const [side, setSide] = useState<'BUY' | 'SELL'>('BUY')
|
||||
const [symbol, setSymbol] = useState('SOL-PERP')
|
||||
const [side, setSide] = useState<'LONG' | 'SHORT'>('LONG')
|
||||
const [amount, setAmount] = useState('')
|
||||
const [leverage, setLeverage] = useState(1)
|
||||
const [orderType, setOrderType] = useState<'MARKET' | 'LIMIT'>('MARKET')
|
||||
const [price, setPrice] = useState('')
|
||||
const [stopLoss, setStopLoss] = useState('')
|
||||
const [takeProfit, setTakeProfit] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [result, setResult] = useState<any>(null)
|
||||
|
||||
const availableSymbols = [
|
||||
'SOLUSD', 'BTCUSD', 'ETHUSD', 'DOTUSD', 'AVAXUSD', 'ADAUSD',
|
||||
'MATICUSD', 'LINKUSD', 'ATOMUSD', 'NEARUSD', 'APTUSD', 'ORBSUSD',
|
||||
'RNDUSD', 'WIFUSD', 'JUPUSD', 'TNSUSD', 'DOGEUSD', 'PEPE1KUSD',
|
||||
'POPCATUSD', 'BOMERUSD'
|
||||
'SOL-PERP', 'BTC-PERP', 'ETH-PERP', 'DOT-PERP', 'AVAX-PERP', 'ADA-PERP',
|
||||
'MATIC-PERP', 'LINK-PERP', 'ATOM-PERP', 'NEAR-PERP', 'APT-PERP', 'ORBS-PERP',
|
||||
'RND-PERP', 'WIF-PERP', 'JUP-PERP', 'TNS-PERP', 'DOGE-PERP', 'PEPE-PERP',
|
||||
'POPCAT-PERP', 'BOME-PERP'
|
||||
]
|
||||
|
||||
const handleTrade = async () => {
|
||||
@@ -44,11 +52,16 @@ export default function DriftTradingPanel() {
|
||||
symbol,
|
||||
side,
|
||||
amount: parseFloat(amount),
|
||||
leverage,
|
||||
orderType,
|
||||
price: orderType === 'LIMIT' ? parseFloat(price) : undefined
|
||||
price: orderType === 'LIMIT' ? parseFloat(price) : undefined,
|
||||
stopLoss: stopLoss ? parseFloat(stopLoss) : undefined,
|
||||
takeProfit: takeProfit ? parseFloat(takeProfit) : undefined,
|
||||
stopLossType: 'MARKET',
|
||||
takeProfitType: 'MARKET'
|
||||
}
|
||||
|
||||
const response = await fetch('/api/trading', {
|
||||
const response = await fetch('/api/drift/trade', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(tradeParams)
|
||||
@@ -102,16 +115,16 @@ export default function DriftTradingPanel() {
|
||||
<label className="block text-sm font-medium text-gray-400 mb-2">Side</label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<button
|
||||
onClick={() => setSide('BUY')}
|
||||
className={`btn ${side === 'BUY' ? 'btn-primary' : 'btn-secondary'}`}
|
||||
onClick={() => setSide('LONG')}
|
||||
className={`btn ${side === 'LONG' ? 'btn-primary' : 'btn-secondary'}`}
|
||||
>
|
||||
🟢 Buy
|
||||
🟢 Long
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setSide('SELL')}
|
||||
className={`btn ${side === 'SELL' ? 'btn-primary' : 'btn-secondary'}`}
|
||||
onClick={() => setSide('SHORT')}
|
||||
className={`btn ${side === 'SHORT' ? 'btn-primary' : 'btn-secondary'}`}
|
||||
>
|
||||
🔴 Sell
|
||||
🔴 Short
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -149,6 +162,25 @@ export default function DriftTradingPanel() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Leverage */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-400 mb-2">Leverage: {leverage}x</label>
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max="20"
|
||||
value={leverage}
|
||||
onChange={(e) => setLeverage(parseInt(e.target.value))}
|
||||
className="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"
|
||||
/>
|
||||
<div className="flex justify-between text-xs text-gray-500 mt-1">
|
||||
<span>1x</span>
|
||||
<span>5x</span>
|
||||
<span>10x</span>
|
||||
<span>20x</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Price (only for limit orders) */}
|
||||
{orderType === 'LIMIT' && (
|
||||
<div>
|
||||
@@ -165,6 +197,34 @@ export default function DriftTradingPanel() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Risk Management */}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-400 mb-2">Stop Loss (USD)</label>
|
||||
<input
|
||||
type="number"
|
||||
value={stopLoss}
|
||||
onChange={(e) => setStopLoss(e.target.value)}
|
||||
placeholder="Optional"
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="input w-full"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-400 mb-2">Take Profit (USD)</label>
|
||||
<input
|
||||
type="number"
|
||||
value={takeProfit}
|
||||
onChange={(e) => setTakeProfit(e.target.value)}
|
||||
placeholder="Optional"
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="input w-full"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Trade Button */}
|
||||
<button
|
||||
onClick={handleTrade}
|
||||
@@ -177,7 +237,7 @@ export default function DriftTradingPanel() {
|
||||
Executing...
|
||||
</span>
|
||||
) : (
|
||||
`${side} ${symbol}`
|
||||
`${side} ${symbol} ${leverage}x`
|
||||
)}
|
||||
</button>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user