42 lines
1 KiB
TypeScript
42 lines
1 KiB
TypeScript
import {
|
|
BaseHandler,
|
|
Handler,
|
|
Operation,
|
|
ScheduledOperation,
|
|
type IServiceContainer,
|
|
} from '@stock-bot/handlers';
|
|
import { fetchExchanges, fetchExchangesAndSymbols, fetchSession, fetchSymbols } from './actions';
|
|
|
|
@Handler('ib')
|
|
export class IbHandler extends BaseHandler {
|
|
constructor(services: IServiceContainer) {
|
|
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);
|
|
}
|
|
|
|
@Operation('ib-exchanges-and-symbols')
|
|
@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);
|
|
}
|
|
}
|
|
|
|
|