MCPcopy Create free account
hub / github.com/cryptocj520/meteora2 / initializeStrategyManager

Method initializeStrategyManager

src/server/api-server.ts:211–261  ·  view source on GitHub ↗

* 初始化策略管理器

()

Source from the content-addressed store, hash-verified

209 * 初始化策略管理器
210 */
211 private async initializeStrategyManager(): Promise<void> {
212 try {
213 await this.logger.logSystem('INFO', '🎯 初始化策略管理器...');
214
215 // 注册SimpleYExecutor到策略注册表
216 const strategyRegistry = this.services.strategyRegistry;
217 const simpleYExecutor = this.services.simpleYExecutor;
218
219 if (strategyRegistry && simpleYExecutor) {
220 await strategyRegistry.register('simple-y', simpleYExecutor);
221 await this.logger.logSystem('INFO', '✅ SimpleYExecutor注册成功 (类型: simple-y)');
222 }
223
224 // 🔗 注册ChainPositionExecutor到策略注册表
225 const chainPositionExecutor = getService(TYPES.ChainPositionExecutor);
226 if (strategyRegistry && chainPositionExecutor) {
227 await strategyRegistry.register('chain_position', chainPositionExecutor);
228 await this.logger.logSystem('INFO', '✅ ChainPositionExecutor注册成功 (类型: chain_position)');
229 }
230
231 // 🚀 启动策略调度器 - 必须在StrategyManager初始化之前启动
232 const strategyScheduler = this.services.strategyScheduler;
233 if (strategyScheduler) {
234 await strategyScheduler.start();
235 await this.logger.logSystem('INFO', '✅ StrategyScheduler启动成功');
236 }
237
238 // 初始化策略管理器
239 const strategyManager = this.services.strategyManager;
240 if (strategyManager) {
241 await strategyManager.initialize();
242 await this.logger.logSystem('INFO', '✅ StrategyManager初始化成功');
243 }
244
245 // 启动健康检查服务
246 const healthChecker = this.services.healthChecker;
247 if (healthChecker) {
248 await healthChecker.start();
249 await this.logger.logSystem('INFO', '✅ StrategyHealthChecker启动成功');
250 }
251
252 await this.logger.logSystem('INFO', '🎯 策略管理器初始化完成');
253 } catch (error) {
254 if (this.logger && typeof this.logger.logError === 'function') {
255 await this.logger.logError('Server', '❌ 策略管理器初始化失败', error as Error);
256 } else {
257 console.error('❌ 策略管理器初始化失败(logger未初始化):', error);
258 }
259 throw error;
260 }
261 }
262
263 /**
264 * 设置Express中间件

Callers 1

initializeServicesMethod · 0.95

Calls 7

getServiceFunction · 0.90
logSystemMethod · 0.65
startMethod · 0.65
initializeMethod · 0.65
logErrorMethod · 0.65
registerMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected