#!/usr/bin/env node /** * Emergency script to manually place TP/SL orders for unprotected position */ const API_URL = 'http://localhost:3001' // Trade details from database const tradeId = 'cmhyw5pn7000imo07n65ihi8y' const symbol = 'SOL-PERP' const direction = 'long' const entryPrice = 137.069998 const positionSizeUSD = 42.92421 const stopLossPrice = 135.69929802 const tp1Price = 137.618277992 const tp2Price = 138.029487986 console.log('🚨 EMERGENCY: Placing TP/SL orders manually') console.log(`Trade ID: ${tradeId}`) console.log(`Symbol: ${symbol}`) console.log(`Direction: ${direction}`) console.log(`Entry: $${entryPrice}`) console.log(`Size: $${positionSizeUSD}`) console.log(`SL: $${stopLossPrice}`) console.log(`TP1: $${tp1Price}`) console.log(`TP2: $${tp2Price}`) // Call internal API const response = await fetch(`${API_URL}/api/trading/execute`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ action: 'place_exit_orders_only', symbol, direction, entryPrice, positionSizeUSD, stopLossPrice, tp1Price, tp2Price, }) }) const result = await response.json() console.log('\nšŸ“Š Result:', JSON.stringify(result, null, 2)) if (result.success) { console.log('āœ… Orders placed successfully!') } else { console.error('āŒ Failed to place orders:', result.error) }