test
This commit is contained in:
parent
167a586257
commit
1f5dac28c7
4 changed files with 198 additions and 1 deletions
48
apps/stock/data-ingestion/src/handlers/tt/tt.handler.ts
Normal file
48
apps/stock/data-ingestion/src/handlers/tt/tt.handler.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue