fix: Remove fallback that breaks TP2-as-runner system

- Change tp2SizePercent fallback from || 100 to ?? 0
- Allows 0 value to pass through (means 'activate trailing stop, don't close')
- Fixes bug where TP2 was closing 100% of remaining position
- Now correctly leaves 25% runner after TP1 closes 75%
- Applied to both execute and test endpoints
This commit is contained in:
mindesbunister
2025-11-08 10:59:58 +01:00
parent 9b767342dc
commit 2f80c2133c
3 changed files with 244 additions and 4 deletions

View File

@@ -258,8 +258,8 @@ export async function POST(request: NextRequest): Promise<NextResponse<TestTrade
tp1Price,
tp2Price,
stopLossPrice,
tp1SizePercent: config.takeProfit1SizePercent || 50,
tp2SizePercent: config.takeProfit2SizePercent || 100,
tp1SizePercent: config.takeProfit1SizePercent ?? 75,
tp2SizePercent: config.takeProfit2SizePercent ?? 0, // 0 = activate trailing stop, don't close
direction: direction,
// Dual stop parameters
useDualStops: config.useDualStops,