From 133f37e755958e216512239f5f7f883327190a8c Mon Sep 17 00:00:00 2001 From: Boki Date: Sun, 29 Jun 2025 14:22:38 -0400 Subject: [PATCH] about to start --- apps/stock/config/config/default.json | 4 ++-- .../src/handlers/qm/actions/prices.action.ts | 22 +++++++++---------- .../src/handlers/qm/shared/config.ts | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/apps/stock/config/config/default.json b/apps/stock/config/config/default.json index dde869a..255bbcc 100644 --- a/apps/stock/config/config/default.json +++ b/apps/stock/config/config/default.json @@ -77,8 +77,8 @@ "port": 6379, "db": 1 }, - "workers": 1, - "concurrency": 1, + "workers": 10, + "concurrency": 4, "enableScheduledJobs": true, "defaultJobOptions": { "attempts": 3, diff --git a/apps/stock/data-ingestion/src/handlers/qm/actions/prices.action.ts b/apps/stock/data-ingestion/src/handlers/qm/actions/prices.action.ts index 7ec3ad5..8c6dd72 100644 --- a/apps/stock/data-ingestion/src/handlers/qm/actions/prices.action.ts +++ b/apps/stock/data-ingestion/src/handlers/qm/actions/prices.action.ts @@ -30,6 +30,8 @@ export async function updatePrices( input: { qmSearchCode: string; lastRecordDate?: Date; + symbol: string; + exchange: string; }, _context?: ExecutionContext ): Promise<{ @@ -38,7 +40,7 @@ export async function updatePrices( message: string; data?: any; }> { - const { qmSearchCode, lastRecordDate } = input; + const { qmSearchCode, lastRecordDate, symbol, exchange } = input; this.logger.info(`Fetching daily prices ${qmSearchCode}`, { qmSearchCode }); @@ -70,8 +72,6 @@ export async function updatePrices( // https://app.quotemedia.com/datatool/getEnhancedChartData.json?zeroTradeDays=false&start=2025-06-22&interval=1&marketSession=mkt&freq=day&adjusted=true&adjustmentType=none&unadjusted=false&datatype=int&symbol=AAPL // TODO: Update with correct prices endpoint const apiUrl = `${QM_CONFIG.PRICES_URL}?${searchParams.toString()}`; - - console.log('QM Symbol Info API URL:', apiUrl); const response = await fetch(apiUrl, { method: 'GET', headers: session.headers, @@ -103,6 +103,8 @@ export async function updatePrices( // Store prices in a separate collection const processedPrices = priceData.map((price: any) => ({ ...price, + symbol, + exchange, qmSearchCode, dateTime: new Date(price.date), })); @@ -191,7 +193,7 @@ export async function schedulePriceUpdates( symbolsQueued: number; errors: number; }> { - const { limit = 10000, forceUpdate = false } = input; + const { limit = 100, forceUpdate = false } = input; const tracker = await getOperationTracker(this); this.logger.info('Scheduling price updates', { limit, forceUpdate }); @@ -218,7 +220,7 @@ export async function schedulePriceUpdates( const symbolDocs = await this.mongodb.find('qmSymbols', { qmSearchCode: { $in: staleSymbols } }, { - projection: { qmSearchCode: 1, operations: 1 } + projection: { qmSearchCode: 1, operations: 1, symbol: 1, exchange: 1 }, }); let queued = 0; @@ -227,15 +229,11 @@ export async function schedulePriceUpdates( // Schedule individual update jobs for each symbol for (const doc of symbolDocs) { try { - - if(doc.qmSearchCode !== 'A') { - // this.logger.warn(`Skipping symbol with missing qmSearchCode ${doc.qmSearchCode}`, { doc }); - continue; - } - await this.scheduleOperation('update-prices', { qmSearchCode: doc.qmSearchCode, - lastRecordDate: doc.operations?.price_update?.lastRecordDate + lastRecordDate: doc.operations?.price_update?.lastRecordDate, + symbol: doc.symbol, + exchange: doc.exchange }, { priority: 7, // High priority for price data delay: queued * 500 // 0.5 seconds between jobs diff --git a/apps/stock/data-ingestion/src/handlers/qm/shared/config.ts b/apps/stock/data-ingestion/src/handlers/qm/shared/config.ts index 00c9864..80faa35 100644 --- a/apps/stock/data-ingestion/src/handlers/qm/shared/config.ts +++ b/apps/stock/data-ingestion/src/handlers/qm/shared/config.ts @@ -42,8 +42,8 @@ export const QM_CONFIG = { // Session management settings export const SESSION_CONFIG = { - MIN_SESSIONS: 2, - MAX_SESSIONS: 2, + MIN_SESSIONS: 100, + MAX_SESSIONS: 100, MAX_FAILED_CALLS: 3, SESSION_TIMEOUT: 5000, // 10 seconds API_TIMEOUT: 30000, // 15 seconds