- Added /close Telegram command for full position closure - Updated /reduce to accept 10-100% (was 10-90%) - Implemented auto-flip logic: automatically closes opposite position when signal reverses - Fixed risk check to allow opposite direction trades (signal flips) - Enhanced Position Manager to cancel orders when removing trades - Added startup initialization for Position Manager (restores trades on restart) - Fixed analytics to show stopped-out trades (manual DB update for orphaned trade) - Updated reduce endpoint to route 100% closes through closePosition for proper cleanup - All position closures now guarantee TP/SL order cancellation on Drift
19 lines
610 B
TypeScript
19 lines
610 B
TypeScript
/**
|
|
* Next.js Instrumentation Hook
|
|
*
|
|
* This file is automatically called when the Next.js server starts
|
|
* Use it to initialize services that need to run on startup
|
|
*/
|
|
|
|
export async function register() {
|
|
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
console.log('🎯 Server starting - initializing services...')
|
|
|
|
// Initialize Position Manager to restore trades from database
|
|
const { initializePositionManagerOnStartup } = await import('./lib/startup/init-position-manager')
|
|
await initializePositionManagerOnStartup()
|
|
|
|
console.log('✅ Server initialization complete')
|
|
}
|
|
}
|