import { ProStrategyEngine } from '../src/strategies/ProStrategyEngine.js'; import { AutoTrader } from '../src/services/AutoTrader.js'; import { TradeExecutor } from '../src/services/TradeExecutor.js'; import { RuleResult, SignalDirection } from '../src/strategies/rules/types.js'; import logger from '../src/utils/logger.js'; // Mock objects const mockExchange: any = { fetchOHLCV: async () => [], getPosition: async () => null, placeOrder: async () => ({ id: 'mock-order', status: 'filled' }) }; async function testBroadcast() { console.log("๐Ÿงช Testing Signal Broadcast to Multiple Profiles..."); // Create 3 Simulated Profiles const profiles = [ { id: 'profile-alpha', name: 'Alpha Scalper', capital: 1000 }, { id: 'profile-beta', name: 'Beta Trend', capital: 5000 }, { id: 'profile-gamma', name: 'Gamma Swing', capital: 2500 } ]; const traders: AutoTrader[] = []; for (const p of profiles) { const executor = new TradeExecutor(mockExchange, undefined, 'test-user', p.id); const trader = new AutoTrader(executor, mockExchange, p.capital, 1, ['BTC/USDT']); traders.push(trader); } // Simulate a PASSING signal const mockResult: RuleResult = { passed: true, signal: SignalDirection.BUY, reason: "Test Signal Pass", rules: {} }; const mockContext: any = { symbol: 'BTC/USDT', currentPrice: 50000, indicators: {} }; console.log("\n๐Ÿš€ Broadcasting Signal..."); // This replicates the logic in index.ts: // await Promise.allSettled(userContexts.map(ctx => ctx.autoTrader.handleSignal(symbol, result!, context!))); await Promise.allSettled(traders.map(t => t.handleSignal('BTC/USDT', mockResult, mockContext))); console.log("\nโœ… Broadcast Phase Complete. Check logs above for profile identifiers."); } testBroadcast();