feat: add long/short test trade buttons to settings page
- Split test trade button into separate LONG and SHORT buttons - Update testTrade function to accept direction parameter - Add confirmation dialog showing the specific direction - Green button for LONG, red button for SHORT - Success message includes executed direction
This commit is contained in:
@@ -91,8 +91,8 @@ export default function SettingsPage() {
|
||||
setRestarting(false)
|
||||
}
|
||||
|
||||
const testTrade = async () => {
|
||||
if (!confirm('⚠️ This will execute a REAL trade with current settings. Continue?')) {
|
||||
const testTrade = async (direction: 'long' | 'short') => {
|
||||
if (!confirm(`⚠️ This will execute a REAL ${direction.toUpperCase()} trade with current settings. Continue?`)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ export default function SettingsPage() {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
symbol: 'SOLUSDT',
|
||||
direction: 'long',
|
||||
direction: direction,
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -118,7 +118,7 @@ export default function SettingsPage() {
|
||||
: `SL: $${data.stopLoss?.toFixed(4)}`
|
||||
setMessage({
|
||||
type: 'success',
|
||||
text: `✅ Test trade executed! Size: $${data.positionSize?.toFixed(2)} | Entry: $${data.entryPrice?.toFixed(4)} | ${dualStopsMsg} | TX: ${data.positionId?.substring(0, 8)}...`
|
||||
text: `✅ ${direction.toUpperCase()} test trade executed! Size: $${data.positionSize?.toFixed(2)} | Entry: $${data.entryPrice?.toFixed(4)} | ${dualStopsMsg} | TX: ${data.positionId?.substring(0, 8)}...`
|
||||
})
|
||||
} else {
|
||||
setMessage({ type: 'error', text: `Failed: ${data.error || data.message}` })
|
||||
@@ -406,14 +406,23 @@ export default function SettingsPage() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Test Trade Button */}
|
||||
<button
|
||||
onClick={testTrade}
|
||||
disabled={testing}
|
||||
className="w-full bg-gradient-to-r from-orange-500 to-red-500 text-white font-bold py-4 px-6 rounded-lg hover:from-orange-600 hover:to-red-600 transition-all disabled:opacity-50 disabled:cursor-not-allowed border-2 border-orange-400"
|
||||
>
|
||||
{testing ? '🧪 Executing Test Trade...' : '🧪 Test Trade (REAL - SOL Long)'}
|
||||
</button>
|
||||
{/* Test Trade Buttons */}
|
||||
<div className="flex gap-4">
|
||||
<button
|
||||
onClick={() => testTrade('long')}
|
||||
disabled={testing}
|
||||
className="flex-1 bg-gradient-to-r from-green-500 to-emerald-500 text-white font-bold py-4 px-6 rounded-lg hover:from-green-600 hover:to-emerald-600 transition-all disabled:opacity-50 disabled:cursor-not-allowed border-2 border-green-400"
|
||||
>
|
||||
{testing ? '🧪 Executing...' : '🧪 Test LONG (REAL)'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => testTrade('short')}
|
||||
disabled={testing}
|
||||
className="flex-1 bg-gradient-to-r from-red-500 to-orange-500 text-white font-bold py-4 px-6 rounded-lg hover:from-red-600 hover:to-orange-600 transition-all disabled:opacity-50 disabled:cursor-not-allowed border-2 border-red-400"
|
||||
>
|
||||
{testing ? '🧪 Executing...' : '🧪 Test SHORT (REAL)'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 text-center text-slate-400 text-sm">
|
||||
|
||||
Reference in New Issue
Block a user