Add trailing stop feature for runner position + fix settings persistence

- Implemented trailing stop logic in Position Manager for remaining position after TP2
- Added new ActiveTrade fields: tp2Hit, trailingStopActive, peakPrice
- New config settings: useTrailingStop, trailingStopPercent, trailingStopActivation
- Added trailing stop UI section in settings page with explanations
- Fixed env file parsing regex to support numbers in variable names (A-Z0-9_)
- Settings now persist correctly across container restarts
- Added back arrow navigation on settings page
- Updated all API endpoints and test files with new fields
- Trailing stop activates when runner reaches configured profit level
- SL trails below peak price by configurable percentage
This commit is contained in:
mindesbunister
2025-10-27 12:11:10 +01:00
parent d3c04ea9c9
commit 4ae9c38ad8
8 changed files with 193 additions and 22 deletions

View File

@@ -198,11 +198,14 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
emergencyStopPrice,
currentSize: positionSizeUSD,
tp1Hit: false,
tp2Hit: false,
slMovedToBreakeven: false,
slMovedToProfit: false,
trailingStopActive: false,
realizedPnL: 0,
unrealizedPnL: 0,
peakPnL: 0,
peakPrice: entryPrice,
priceCheckCount: 0,
lastPrice: entryPrice,
lastUpdateTime: Date.now(),