Fix complete trading system: SL/TP working, live trading operational
- Fixed network connectivity and live trading mode - Updated Drift SDK integration with proper API methods - Fixed BN type conversions and minimum order size - Fixed stop loss & take profit conditional orders - Complete risk management system now functional
This commit is contained in:
@@ -156,67 +156,66 @@ export default function AutomationPageV2() {
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Header with Start/Stop */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-white">Automated Trading</h1>
|
||||
<p className="text-gray-400 mt-1">Multi-Timeframe Analysis</p>
|
||||
</div>
|
||||
<div className="flex space-x-3">
|
||||
{status?.isActive ? (
|
||||
<button
|
||||
onClick={handleStop}
|
||||
disabled={loading}
|
||||
className="px-6 py-3 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50 font-semibold"
|
||||
>
|
||||
{loading ? 'Stopping...' : 'STOP'}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={handleStart}
|
||||
disabled={loading}
|
||||
className="px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors disabled:opacity-50 font-semibold"
|
||||
>
|
||||
{loading ? 'Starting...' : 'START'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 xl:grid-cols-3 gap-6">
|
||||
{/* Configuration Panel */}
|
||||
<div className="xl:col-span-2 space-y-6">
|
||||
<div className="bg-gray-800 p-6 rounded-lg border border-gray-700">
|
||||
<h3 className="text-xl font-bold text-white mb-6">Configuration</h3>
|
||||
{/* Header with Start/Stop Button */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h3 className="text-xl font-bold text-white">Configuration</h3>
|
||||
<div className="flex space-x-3">
|
||||
{status?.isActive ? (
|
||||
<button
|
||||
onClick={handleStop}
|
||||
disabled={loading}
|
||||
className="px-6 py-3 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50 font-semibold"
|
||||
>
|
||||
{loading ? 'Stopping...' : 'STOP'}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={handleStart}
|
||||
disabled={loading}
|
||||
className="px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors disabled:opacity-50 font-semibold"
|
||||
>
|
||||
{loading ? 'Starting...' : status?.rateLimitHit ? 'RESTART' : 'START'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Trading Mode */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
||||
<div className="space-y-3">
|
||||
<label className="block text-sm font-bold text-blue-400">Trading Mode</label>
|
||||
<div className="space-y-2">
|
||||
<label className="flex items-center space-x-3 cursor-pointer p-3 rounded-lg border border-gray-600 hover:border-blue-500 transition-colors">
|
||||
<input
|
||||
type="radio"
|
||||
className="w-4 h-4 text-blue-600"
|
||||
name="mode"
|
||||
checked={config.mode === 'SIMULATION'}
|
||||
onChange={() => setConfig({...config, mode: 'SIMULATION'})}
|
||||
disabled={status?.isActive}
|
||||
/>
|
||||
<span className="text-white">Paper Trading</span>
|
||||
</label>
|
||||
<label className="flex items-center space-x-3 cursor-pointer p-3 rounded-lg border border-gray-600 hover:border-green-500 transition-colors">
|
||||
<input
|
||||
type="radio"
|
||||
className="w-4 h-4 text-green-600"
|
||||
name="mode"
|
||||
checked={config.mode === 'LIVE'}
|
||||
onChange={() => setConfig({...config, mode: 'LIVE'})}
|
||||
disabled={status?.isActive}
|
||||
/>
|
||||
{/* Trading Mode - Side by Side Radio Buttons with Logos */}
|
||||
<div className="mb-6">
|
||||
<label className="block text-sm font-bold text-blue-400 mb-3">Trading Mode</label>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<label className="flex items-center space-x-3 cursor-pointer p-4 rounded-lg border border-gray-600 hover:border-blue-500 transition-colors">
|
||||
<input
|
||||
type="radio"
|
||||
className="w-5 h-5 text-blue-600"
|
||||
name="mode"
|
||||
checked={config.mode === 'SIMULATION'}
|
||||
onChange={() => setConfig({...config, mode: 'SIMULATION'})}
|
||||
disabled={status?.isActive}
|
||||
/>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-2xl">📊</span>
|
||||
<span className="text-white font-medium">Paper Trading</span>
|
||||
</div>
|
||||
</label>
|
||||
<label className="flex items-center space-x-3 cursor-pointer p-4 rounded-lg border border-gray-600 hover:border-green-500 transition-colors">
|
||||
<input
|
||||
type="radio"
|
||||
className="w-5 h-5 text-green-600"
|
||||
name="mode"
|
||||
checked={config.mode === 'LIVE'}
|
||||
onChange={() => setConfig({...config, mode: 'LIVE'})}
|
||||
disabled={status?.isActive}
|
||||
/>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-2xl">💰</span>
|
||||
<span className="text-white font-semibold">Live Trading</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -324,31 +323,37 @@ export default function AutomationPageV2() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Quick Selection Buttons */}
|
||||
<div className="flex gap-2">
|
||||
{/* Quick Selection Buttons - Made Bigger */}
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setConfig({...config, selectedTimeframes: ['5', '15', '30']})}
|
||||
disabled={status?.isActive}
|
||||
className="py-1 px-2 rounded text-xs font-medium bg-green-600/20 text-green-300 hover:bg-green-600/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
className="py-3 px-4 rounded-lg text-sm font-medium bg-green-600/20 text-green-300 hover:bg-green-600/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed border border-green-600/30 hover:border-green-600/50"
|
||||
>
|
||||
📈 Scalping
|
||||
<div className="text-lg mb-1">📈</div>
|
||||
<div>Scalping</div>
|
||||
<div className="text-xs opacity-75">5m, 15m, 30m</div>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setConfig({...config, selectedTimeframes: ['60', '120']})}
|
||||
disabled={status?.isActive}
|
||||
className="py-1 px-2 rounded text-xs font-medium bg-blue-600/20 text-blue-300 hover:bg-blue-600/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
className="py-3 px-4 rounded-lg text-sm font-medium bg-blue-600/20 text-blue-300 hover:bg-blue-600/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed border border-blue-600/30 hover:border-blue-600/50"
|
||||
>
|
||||
⚡ Day Trading
|
||||
<div className="text-lg mb-1">⚡</div>
|
||||
<div>Day Trading</div>
|
||||
<div className="text-xs opacity-75">1h, 2h</div>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setConfig({...config, selectedTimeframes: ['240', 'D']})}
|
||||
disabled={status?.isActive}
|
||||
className="py-1 px-2 rounded text-xs font-medium bg-purple-600/20 text-purple-300 hover:bg-purple-600/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
className="py-3 px-4 rounded-lg text-sm font-medium bg-purple-600/20 text-purple-300 hover:bg-purple-600/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed border border-purple-600/30 hover:border-purple-600/50"
|
||||
>
|
||||
🎯 Swing Trading
|
||||
<div className="text-lg mb-1">🎯</div>
|
||||
<div>Swing Trading</div>
|
||||
<div className="text-xs opacity-75">4h, 1d</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -395,6 +400,21 @@ export default function AutomationPageV2() {
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Rate Limit Notification */}
|
||||
{status?.rateLimitHit && (
|
||||
<div className="mt-4 p-3 bg-red-900 border border-red-600 rounded-lg">
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-red-400 font-semibold">⚠️ Rate Limit Reached</span>
|
||||
</div>
|
||||
{status.rateLimitMessage && (
|
||||
<p className="text-red-300 text-sm mt-1">{status.rateLimitMessage}</p>
|
||||
)}
|
||||
<p className="text-red-200 text-xs mt-2">
|
||||
Automation stopped automatically. Please recharge your OpenAI account to continue.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user