qm fully refactored and ready for more

This commit is contained in:
Boki 2025-06-21 10:49:38 -04:00
parent ab0b7a5385
commit 24fda247aa
5 changed files with 36 additions and 48 deletions

View file

@ -4,7 +4,6 @@
import { OperationContext } from '@stock-bot/utils';
import { getRandomProxy } from '@stock-bot/utils';
import type { Logger } from '@stock-bot/logger';
import { QMSessionManager } from '../shared/session-manager';
import { QM_SESSION_IDS, QM_CONFIG, SESSION_CONFIG } from '../shared/config';
@ -12,13 +11,13 @@ import type { SymbolSpiderJob, Exchange } from '../shared/types';
import { initializeQMResources } from './session.operations';
import { spiderSymbolSearch } from './spider.operations';
export async function fetchSymbols(parentLogger?: Logger): Promise<unknown[] | null> {
const ctx = OperationContext.create('qm', 'symbols', parentLogger);
export async function fetchSymbols(): Promise<unknown[] | null> {
const ctx = OperationContext.create('qm', 'symbols');
try {
const sessionManager = QMSessionManager.getInstance();
if (!sessionManager.getInitialized()) {
await initializeQMResources(parentLogger);
await initializeQMResources();
}
ctx.logger.info('Starting QM spider-based symbol search...');
@ -37,7 +36,7 @@ export async function fetchSymbols(parentLogger?: Logger): Promise<unknown[] | n
maxDepth: 4,
};
const result = await spiderSymbolSearch(rootJob, parentLogger);
const result = await spiderSymbolSearch(rootJob);
if (result.success) {
// Cache successful fetch info
@ -61,8 +60,8 @@ export async function fetchSymbols(parentLogger?: Logger): Promise<unknown[] | n
}
}
export async function searchQMSymbolsAPI(query: string, parentLogger?: Logger): Promise<any[]> {
const ctx = OperationContext.create('qm', 'api-search', parentLogger);
export async function searchQMSymbolsAPI(query: string): Promise<any[]> {
const ctx = OperationContext.create('qm', 'api-search');
const proxyInfo = await getRandomProxy();
if (!proxyInfo) {