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:
mindesbunister
2025-10-26 21:53:44 +01:00
parent d64f6d84c4
commit c2842f88c0
2 changed files with 27 additions and 18 deletions

12
.env
View File

@@ -70,7 +70,7 @@ LEVERAGE=5
# Risk parameters (as percentages)
# Stop Loss: Close 100% of position when price drops this much
# Example: -1.5% on 10x = -15% account loss
STOP_LOSS_PERCENT=-2.0
STOP_LOSS_PERCENT=-1.5
# ================================
# DUAL STOP SYSTEM (Advanced)
@@ -93,19 +93,19 @@ HARD_STOP_PERCENT=-2.5
# Take Profit 1: Close 50% of position at this profit level
# Example: +0.7% on 10x = +7% account gain
TAKE_PROFIT_1_PERCENT=0.5
TAKE_PROFIT_1_PERCENT=0.7
# Take Profit 1 Size: What % of position to close at TP1
# Example: 50 = close 50% of position
TAKE_PROFIT_1_SIZE_PERCENT=75
TAKE_PROFIT_1_SIZE_PERCENT=50
# Take Profit 2: Close remaining 50% at this profit level
# Example: +1.5% on 10x = +15% account gain
TAKE_PROFIT_2_PERCENT=2.5
TAKE_PROFIT_2_PERCENT=1.5
# Take Profit 2 Size: What % of remaining position to close at TP2
# Example: 100 = close all remaining position
TAKE_PROFIT_2_SIZE_PERCENT=100
TAKE_PROFIT_2_SIZE_PERCENT=50
# Emergency Stop: Hard stop if this level is breached
# Example: -2.0% on 10x = -20% account loss (rare but protects from flash crashes)
@@ -119,7 +119,7 @@ BREAKEVEN_TRIGGER_PERCENT=0.5
PROFIT_LOCK_TRIGGER_PERCENT=1.2
# How much profit to lock (move SL to this profit level)
PROFIT_LOCK_PERCENT=0.5
PROFIT_LOCK_PERCENT=0.2
# Risk limits
# Stop trading if daily loss exceeds this amount (USD)

View File

@@ -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">