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);
|
||||
|
||||
// Check if authentication was successful
|
||||
if (sessionResponse.status === 200 || sessionResponse.status === 302) {
|
||||
this.logger.info('QM authentication successful', {
|
||||
status: sessionResponse.status,
|
||||
});
|
||||
}else{
|
||||
if (!(sessionResponse.status === 200 || sessionResponse.status === 302)) {
|
||||
this.logger.warn('QM authentication failed', {
|
||||
status: sessionResponse.status,
|
||||
statusText: sessionResponse.statusText,
|
||||
|
|
@ -130,7 +126,6 @@ export async function createSession(
|
|||
throw new Error(`QM authentication failed with status ${sessionResponse.status}`);
|
||||
}
|
||||
|
||||
|
||||
const sessionData = await sessionResponse.json();
|
||||
|
||||
// Add token to headers
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
import type { BaseHandler, ExecutionContext } from '@stock-bot/handlers';
|
||||
import { QM_CONFIG, QM_SESSION_IDS } from '../shared/config';
|
||||
import { QMSessionManager } from '../shared/session-manager';
|
||||
import { QMOperationTracker } from '../shared/operation-tracker';
|
||||
import { initializeQMOperations } from '../shared/operation-registry';
|
||||
// import { QMOperationTracker } from '../shared/operation-tracker';
|
||||
// import { initializeQMOperations } from '../shared/operation-registry';
|
||||
import type { Exchange, SymbolSpiderJob } from '../shared/types';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ import {
|
|||
ScheduledOperation,
|
||||
} from '@stock-bot/handlers';
|
||||
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')
|
||||
export class QMHandler extends BaseHandler {
|
||||
constructor(services: any) {
|
||||
initializeQMOperations(services.mongodb, services.logger);
|
||||
super(services); // Handler name read from @Handler decorator
|
||||
}
|
||||
|
||||
|
|
@ -39,22 +41,22 @@ export class QMHandler extends BaseHandler {
|
|||
@Operation('search-symbols')
|
||||
searchSymbols = searchSymbols;
|
||||
|
||||
/**
|
||||
* PRICE DATA
|
||||
*/
|
||||
@ScheduledOperation('update-prices', '0 */6 * * *', {
|
||||
priority: 5,
|
||||
immediately: false,
|
||||
description: 'Update daily prices every 6 hours'
|
||||
})
|
||||
updatePrices = updatePrices;
|
||||
// /**
|
||||
// * PRICE DATA
|
||||
// */
|
||||
// @ScheduledOperation('update-prices', '0 */6 * * *', {
|
||||
// priority: 5,
|
||||
// immediately: false,
|
||||
// description: 'Update daily prices every 6 hours'
|
||||
// })
|
||||
// updatePrices = updatePrices;
|
||||
|
||||
@ScheduledOperation('update-intraday-bars', '*/30 * * * *', {
|
||||
priority: 6,
|
||||
immediately: false,
|
||||
description: 'Update intraday bars every 30 minutes during market hours'
|
||||
})
|
||||
updateIntradayBars = updateIntradayBars;
|
||||
// @ScheduledOperation('update-intraday-bars', '*/30 * * * *', {
|
||||
// priority: 6,
|
||||
// immediately: false,
|
||||
// description: 'Update intraday bars every 30 minutes during market hours'
|
||||
// })
|
||||
// updateIntradayBars = updateIntradayBars;
|
||||
|
||||
/**
|
||||
* MONITORING
|
||||
|
|
|
|||
|
|
@ -11,74 +11,80 @@ import type { QMOperationConfig } from './types';
|
|||
export const QM_OPERATIONS: QMOperationConfig[] = [
|
||||
// Price data operations
|
||||
{
|
||||
name: 'price_update',
|
||||
name: 'symbol_info',
|
||||
type: 'standard',
|
||||
description: 'Update daily price data',
|
||||
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',
|
||||
description: 'Update symbol metadata',
|
||||
defaultStaleHours: 24 * 7 // Weekly
|
||||
},
|
||||
{
|
||||
name: 'earnings_update',
|
||||
type: 'standard',
|
||||
description: 'Update earnings data',
|
||||
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
|
||||
},
|
||||
// {
|
||||
// name: 'price_update',
|
||||
// type: 'standard',
|
||||
// description: 'Update daily price data',
|
||||
// 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
|
||||
// },
|
||||
|
||||
// News and filings
|
||||
{
|
||||
name: 'filings_update',
|
||||
type: 'standard',
|
||||
description: 'Update SEC filings',
|
||||
defaultStaleHours: 24 // Daily
|
||||
},
|
||||
{
|
||||
name: 'news_update',
|
||||
type: 'standard',
|
||||
description: 'Update news articles',
|
||||
defaultStaleHours: 6 // Every 6 hours
|
||||
},
|
||||
// // Fundamental data operations
|
||||
// {
|
||||
// name: 'financials_update',
|
||||
// type: 'standard',
|
||||
// description: 'Update financial statements',
|
||||
// defaultStaleHours: 24 * 7 // Weekly
|
||||
// },
|
||||
// {
|
||||
// name: 'earnings_update',-
|
||||
// type: 'standard',
|
||||
// description: 'Update earnings data',
|
||||
// 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
|
||||
{
|
||||
name: 'indicators_update',
|
||||
type: 'standard',
|
||||
description: 'Calculate technical indicators',
|
||||
defaultStaleHours: 24 // Daily
|
||||
},
|
||||
// // News and filings
|
||||
// {
|
||||
// name: 'filings_update',
|
||||
// type: 'standard',
|
||||
// description: 'Update SEC filings',
|
||||
// defaultStaleHours: 24 // Daily
|
||||
// },
|
||||
// {
|
||||
// name: 'news_update',
|
||||
// type: 'standard',
|
||||
// description: 'Update news articles',
|
||||
// defaultStaleHours: 6 // Every 6 hours
|
||||
// },
|
||||
|
||||
// Options data
|
||||
{
|
||||
name: 'options_chain',
|
||||
type: 'standard',
|
||||
description: 'Update options chain data',
|
||||
defaultStaleHours: 1 // Hourly during market hours
|
||||
}
|
||||
// // Technical indicators
|
||||
// {
|
||||
// name: 'indicators_update',
|
||||
// type: 'standard',
|
||||
// description: 'Calculate technical indicators',
|
||||
// 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
|
||||
*/
|
||||
|
||||
import type { Logger } from '@stock-bot/types';
|
||||
import type { MongoDBClient } from '@stock-bot/mongodb';
|
||||
import type { Logger } from '@stock-bot/types';
|
||||
import type { IntradayCrawlSymbol, QMOperationConfig } from './types';
|
||||
|
||||
export class QMOperationTracker {
|
||||
|
|
@ -140,7 +140,7 @@ export class QMOperationTracker {
|
|||
};
|
||||
}>
|
||||
): Promise<void> {
|
||||
if (updates.length === 0) return;
|
||||
if (updates.length === 0) {return;}
|
||||
|
||||
const bulkOps = updates.map(({ symbol, operation, data }) => {
|
||||
const update: any = {
|
||||
|
|
@ -180,7 +180,7 @@ export class QMOperationTracker {
|
|||
this.logger.debug('Bulk updated symbol operations', {
|
||||
totalUpdates: updates.length,
|
||||
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