stock-bot/apps/stock/data-ingestion/src/handlers/ib/ib.handler.ts

38 lines
976 B
TypeScript

import {
BaseHandler,
Handler,
Operation,
ScheduledOperation,
} from '@stock-bot/handlers';
import { fetchExchanges, fetchExchangesAndSymbols, fetchSession, fetchSymbols } from './actions';
@Handler('ib')
export class IbHandler extends BaseHandler {
constructor(services: any) {
super(services);
}
@Operation('fetch-session')
async fetchSession(): Promise<Record<string, string> | undefined> {
return fetchSession(this);
}
@Operation('fetch-exchanges')
async fetchExchanges(): Promise<unknown[] | null> {
return fetchExchanges(this);
}
@Operation('fetch-symbols')
async fetchSymbols(): Promise<unknown[] | null> {
return fetchSymbols(this);
}
@ScheduledOperation('ib-exchanges-and-symbols', '0 0 * * 0', {
priority: 5,
description: 'Fetch and update IB exchanges and symbols data',
immediately: false,
})
async fetchExchangesAndSymbols(): Promise<unknown> {
return fetchExchangesAndSymbols(this);
}
}