initial setup with operation tracker
This commit is contained in:
parent
d52cfe7de2
commit
736b86e66a
5 changed files with 92 additions and 89 deletions
|
|
@ -118,11 +118,7 @@ export async function createSession(
|
||||||
const sessionResponse = await fetch(sessionUrl, sessionRequest);
|
const sessionResponse = await fetch(sessionUrl, sessionRequest);
|
||||||
|
|
||||||
// Check if authentication was successful
|
// Check if authentication was successful
|
||||||
if (sessionResponse.status === 200 || sessionResponse.status === 302) {
|
if (!(sessionResponse.status === 200 || sessionResponse.status === 302)) {
|
||||||
this.logger.info('QM authentication successful', {
|
|
||||||
status: sessionResponse.status,
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
this.logger.warn('QM authentication failed', {
|
this.logger.warn('QM authentication failed', {
|
||||||
status: sessionResponse.status,
|
status: sessionResponse.status,
|
||||||
statusText: sessionResponse.statusText,
|
statusText: sessionResponse.statusText,
|
||||||
|
|
@ -130,7 +126,6 @@ export async function createSession(
|
||||||
throw new Error(`QM authentication failed with status ${sessionResponse.status}`);
|
throw new Error(`QM authentication failed with status ${sessionResponse.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const sessionData = await sessionResponse.json();
|
const sessionData = await sessionResponse.json();
|
||||||
|
|
||||||
// Add token to headers
|
// Add token to headers
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
import type { BaseHandler, ExecutionContext } from '@stock-bot/handlers';
|
import type { BaseHandler, ExecutionContext } from '@stock-bot/handlers';
|
||||||
import { QM_CONFIG, QM_SESSION_IDS } from '../shared/config';
|
import { QM_CONFIG, QM_SESSION_IDS } from '../shared/config';
|
||||||
import { QMSessionManager } from '../shared/session-manager';
|
import { QMSessionManager } from '../shared/session-manager';
|
||||||
import { QMOperationTracker } from '../shared/operation-tracker';
|
// import { QMOperationTracker } from '../shared/operation-tracker';
|
||||||
import { initializeQMOperations } from '../shared/operation-registry';
|
// import { initializeQMOperations } from '../shared/operation-registry';
|
||||||
import type { Exchange, SymbolSpiderJob } from '../shared/types';
|
import type { Exchange, SymbolSpiderJob } from '../shared/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,13 @@ import {
|
||||||
ScheduledOperation,
|
ScheduledOperation,
|
||||||
} from '@stock-bot/handlers';
|
} from '@stock-bot/handlers';
|
||||||
import { checkSessions, createSession, searchSymbols, spiderSymbol } from './actions';
|
import { checkSessions, createSession, searchSymbols, spiderSymbol } from './actions';
|
||||||
import { updatePrices, updateIntradayBars, getOperationStats } from './actions/price.action';
|
import { getOperationStats } from './actions/price.action';
|
||||||
|
import { initializeQMOperations } from './shared/operation-registry';
|
||||||
|
|
||||||
@Handler('qm')
|
@Handler('qm')
|
||||||
export class QMHandler extends BaseHandler {
|
export class QMHandler extends BaseHandler {
|
||||||
constructor(services: any) {
|
constructor(services: any) {
|
||||||
|
initializeQMOperations(services.mongodb, services.logger);
|
||||||
super(services); // Handler name read from @Handler decorator
|
super(services); // Handler name read from @Handler decorator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,22 +41,22 @@ export class QMHandler extends BaseHandler {
|
||||||
@Operation('search-symbols')
|
@Operation('search-symbols')
|
||||||
searchSymbols = searchSymbols;
|
searchSymbols = searchSymbols;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* PRICE DATA
|
// * PRICE DATA
|
||||||
*/
|
// */
|
||||||
@ScheduledOperation('update-prices', '0 */6 * * *', {
|
// @ScheduledOperation('update-prices', '0 */6 * * *', {
|
||||||
priority: 5,
|
// priority: 5,
|
||||||
immediately: false,
|
// immediately: false,
|
||||||
description: 'Update daily prices every 6 hours'
|
// description: 'Update daily prices every 6 hours'
|
||||||
})
|
// })
|
||||||
updatePrices = updatePrices;
|
// updatePrices = updatePrices;
|
||||||
|
|
||||||
@ScheduledOperation('update-intraday-bars', '*/30 * * * *', {
|
// @ScheduledOperation('update-intraday-bars', '*/30 * * * *', {
|
||||||
priority: 6,
|
// priority: 6,
|
||||||
immediately: false,
|
// immediately: false,
|
||||||
description: 'Update intraday bars every 30 minutes during market hours'
|
// description: 'Update intraday bars every 30 minutes during market hours'
|
||||||
})
|
// })
|
||||||
updateIntradayBars = updateIntradayBars;
|
// updateIntradayBars = updateIntradayBars;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MONITORING
|
* MONITORING
|
||||||
|
|
|
||||||
|
|
@ -11,74 +11,80 @@ import type { QMOperationConfig } from './types';
|
||||||
export const QM_OPERATIONS: QMOperationConfig[] = [
|
export const QM_OPERATIONS: QMOperationConfig[] = [
|
||||||
// Price data operations
|
// Price data operations
|
||||||
{
|
{
|
||||||
name: 'price_update',
|
name: 'symbol_info',
|
||||||
type: 'standard',
|
type: 'standard',
|
||||||
description: 'Update daily price data',
|
description: 'Update symbol metadata',
|
||||||
defaultStaleHours: 24
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'intraday_bars',
|
|
||||||
type: 'intraday_crawl',
|
|
||||||
description: 'Crawl intraday price bars from today backwards',
|
|
||||||
requiresFinishedFlag: true,
|
|
||||||
defaultStaleHours: 1 // Check every hour for new data
|
|
||||||
},
|
|
||||||
|
|
||||||
// Fundamental data operations
|
|
||||||
{
|
|
||||||
name: 'financials_update',
|
|
||||||
type: 'standard',
|
|
||||||
description: 'Update financial statements',
|
|
||||||
defaultStaleHours: 24 * 7 // Weekly
|
defaultStaleHours: 24 * 7 // Weekly
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
name: 'earnings_update',
|
// name: 'price_update',
|
||||||
type: 'standard',
|
// type: 'standard',
|
||||||
description: 'Update earnings data',
|
// description: 'Update daily price data',
|
||||||
defaultStaleHours: 24 * 7 // Weekly
|
// defaultStaleHours: 24
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'dividends_update',
|
// name: 'intraday_bars',
|
||||||
type: 'standard',
|
// type: 'intraday_crawl',
|
||||||
description: 'Update dividend history',
|
// description: 'Crawl intraday price bars from today backwards',
|
||||||
defaultStaleHours: 24 * 7 // Weekly
|
// requiresFinishedFlag: true,
|
||||||
},
|
// defaultStaleHours: 1 // Check every hour for new data
|
||||||
{
|
// },
|
||||||
name: 'splits_update',
|
|
||||||
type: 'standard',
|
|
||||||
description: 'Update stock split history',
|
|
||||||
defaultStaleHours: 24 * 30 // Monthly
|
|
||||||
},
|
|
||||||
|
|
||||||
// News and filings
|
// // Fundamental data operations
|
||||||
{
|
// {
|
||||||
name: 'filings_update',
|
// name: 'financials_update',
|
||||||
type: 'standard',
|
// type: 'standard',
|
||||||
description: 'Update SEC filings',
|
// description: 'Update financial statements',
|
||||||
defaultStaleHours: 24 // Daily
|
// defaultStaleHours: 24 * 7 // Weekly
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'news_update',
|
// name: 'earnings_update',-
|
||||||
type: 'standard',
|
// type: 'standard',
|
||||||
description: 'Update news articles',
|
// description: 'Update earnings data',
|
||||||
defaultStaleHours: 6 // Every 6 hours
|
// defaultStaleHours: 24 * 7 // Weekly
|
||||||
},
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'dividends_update',
|
||||||
|
// type: 'standard',
|
||||||
|
// description: 'Update dividend history',
|
||||||
|
// defaultStaleHours: 24 * 7 // Weekly
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'splits_update',
|
||||||
|
// type: 'standard',
|
||||||
|
// description: 'Update stock split history',
|
||||||
|
// defaultStaleHours: 24 * 30 // Monthly
|
||||||
|
// },
|
||||||
|
|
||||||
// Technical indicators
|
// // News and filings
|
||||||
{
|
// {
|
||||||
name: 'indicators_update',
|
// name: 'filings_update',
|
||||||
type: 'standard',
|
// type: 'standard',
|
||||||
description: 'Calculate technical indicators',
|
// description: 'Update SEC filings',
|
||||||
defaultStaleHours: 24 // Daily
|
// defaultStaleHours: 24 // Daily
|
||||||
},
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'news_update',
|
||||||
|
// type: 'standard',
|
||||||
|
// description: 'Update news articles',
|
||||||
|
// defaultStaleHours: 6 // Every 6 hours
|
||||||
|
// },
|
||||||
|
|
||||||
// Options data
|
// // Technical indicators
|
||||||
{
|
// {
|
||||||
name: 'options_chain',
|
// name: 'indicators_update',
|
||||||
type: 'standard',
|
// type: 'standard',
|
||||||
description: 'Update options chain data',
|
// description: 'Calculate technical indicators',
|
||||||
defaultStaleHours: 1 // Hourly during market hours
|
// defaultStaleHours: 24 // Daily
|
||||||
}
|
// },
|
||||||
|
|
||||||
|
// // Options data
|
||||||
|
// {
|
||||||
|
// name: 'options_chain',
|
||||||
|
// type: 'standard',
|
||||||
|
// description: 'Update options chain data',
|
||||||
|
// defaultStaleHours: 1 // Hourly during market hours
|
||||||
|
// }
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* Supports dynamic operation registration with auto-indexing
|
* Supports dynamic operation registration with auto-indexing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Logger } from '@stock-bot/types';
|
|
||||||
import type { MongoDBClient } from '@stock-bot/mongodb';
|
import type { MongoDBClient } from '@stock-bot/mongodb';
|
||||||
|
import type { Logger } from '@stock-bot/types';
|
||||||
import type { IntradayCrawlSymbol, QMOperationConfig } from './types';
|
import type { IntradayCrawlSymbol, QMOperationConfig } from './types';
|
||||||
|
|
||||||
export class QMOperationTracker {
|
export class QMOperationTracker {
|
||||||
|
|
@ -140,7 +140,7 @@ export class QMOperationTracker {
|
||||||
};
|
};
|
||||||
}>
|
}>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (updates.length === 0) return;
|
if (updates.length === 0) {return;}
|
||||||
|
|
||||||
const bulkOps = updates.map(({ symbol, operation, data }) => {
|
const bulkOps = updates.map(({ symbol, operation, data }) => {
|
||||||
const update: any = {
|
const update: any = {
|
||||||
|
|
@ -180,7 +180,7 @@ export class QMOperationTracker {
|
||||||
this.logger.debug('Bulk updated symbol operations', {
|
this.logger.debug('Bulk updated symbol operations', {
|
||||||
totalUpdates: updates.length,
|
totalUpdates: updates.length,
|
||||||
modified: result.modifiedCount,
|
modified: result.modifiedCount,
|
||||||
operations: [...new Set(updates.map(u => u.operation))]
|
operations: Array.from(new Set(updates.map(u => u.operation)))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue