This commit is contained in:
Boki 2026-04-04 12:40:49 -04:00
parent 167a586257
commit 1f5dac28c7
4 changed files with 198 additions and 1 deletions

View file

@ -0,0 +1,48 @@
import {
BaseHandler,
Handler,
ScheduledOperation,
} from '@stock-bot/handlers';
import type { DataIngestionServices } from '../../types';
import { importData } from './actions';
@Handler('tt')
export class TtHandler extends BaseHandler<DataIngestionServices> {
constructor(services: any) {
super(services);
}
async onInit(): Promise<void> {
if (!this.mongodb) return;
const indexes = [
{
indexSpec: { contract: 1, date: 1 },
options: { name: 'contract_date_unique_idx', unique: true, background: true },
},
{
indexSpec: { symbol: 1, date: 1 },
options: { name: 'symbol_date_idx', background: true },
},
{
indexSpec: { date: 1 },
options: { name: 'date_idx', background: true },
},
];
for (const index of indexes) {
try {
await this.mongodb.createIndex('ttFutures', index.indexSpec, index.options);
} catch (error) {
this.logger.debug(`ttFutures index ${index.options.name} may already exist:`, error);
}
}
}
@ScheduledOperation('tt-import', '0 0 * * 0', {
priority: 5,
description: 'Import TurtleTrader futures data',
immediately: true,
})
importData = importData;
}