fixed up qm and added types to BaseHandler for typesafety
This commit is contained in:
parent
87b1cad4f5
commit
2e86598262
20 changed files with 164 additions and 109 deletions
|
|
@ -2,10 +2,11 @@
|
|||
* QM Intraday Actions - Fetch and update intraday price bars
|
||||
*/
|
||||
|
||||
import type { BaseHandler, ExecutionContext } from '@stock-bot/handlers';
|
||||
import type { ExecutionContext } from '@stock-bot/handlers';
|
||||
import type { QMHandler } from '../qm.handler';
|
||||
import { QM_CONFIG, QM_SESSION_IDS } from '../shared/config';
|
||||
import { QMSessionManager } from '../shared/session-manager';
|
||||
import { QMOperationTracker } from '../shared/operation-tracker';
|
||||
import { QMSessionManager } from '../shared/session-manager';
|
||||
|
||||
// Cache tracker instance
|
||||
let operationTracker: QMOperationTracker | null = null;
|
||||
|
|
@ -13,7 +14,7 @@ let operationTracker: QMOperationTracker | null = null;
|
|||
/**
|
||||
* Get or initialize the operation tracker
|
||||
*/
|
||||
async function getOperationTracker(handler: BaseHandler): Promise<QMOperationTracker> {
|
||||
async function getOperationTracker(handler: QMHandler): Promise<QMOperationTracker> {
|
||||
if (!operationTracker) {
|
||||
const { initializeQMOperations } = await import('../shared/operation-registry');
|
||||
operationTracker = await initializeQMOperations(handler.mongodb, handler.logger);
|
||||
|
|
@ -26,7 +27,7 @@ async function getOperationTracker(handler: BaseHandler): Promise<QMOperationTra
|
|||
* This handles both initial crawl and incremental updates
|
||||
*/
|
||||
export async function updateIntradayBars(
|
||||
this: BaseHandler,
|
||||
this: QMHandler,
|
||||
input: {
|
||||
symbol: string;
|
||||
symbolId: number;
|
||||
|
|
@ -66,7 +67,7 @@ export async function updateIntradayBars(
|
|||
webmasterId: '500',
|
||||
date: targetDate.toISOString().split('T')[0],
|
||||
interval: '1' // 1-minute bars
|
||||
});
|
||||
} as Record<string, string>);
|
||||
|
||||
// TODO: Update with correct intraday endpoint
|
||||
const apiUrl = `${QM_CONFIG.BASE_URL}/datatool/intraday.json?${searchParams.toString()}`;
|
||||
|
|
@ -157,7 +158,7 @@ export async function updateIntradayBars(
|
|||
* This handles both initial crawls and regular updates
|
||||
*/
|
||||
export async function scheduleIntradayUpdates(
|
||||
this: BaseHandler,
|
||||
this: QMHandler,
|
||||
input: {
|
||||
limit?: number;
|
||||
mode?: 'crawl' | 'update'; // crawl for historical, update for recent
|
||||
|
|
@ -259,7 +260,6 @@ export async function scheduleIntradayUpdates(
|
|||
crawlState: {
|
||||
finished: false,
|
||||
oldestDateReached: new Date(startDate.getTime() - daysToFetch * 24 * 60 * 60 * 1000),
|
||||
lastCrawlDirection: 'backward'
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue