re-organized code; implemented getAggregate() where it was missing

This commit is contained in:
2024-08-11 18:08:54 -04:00
parent 15a5d7c67b
commit d6762fdae5
14 changed files with 193 additions and 86 deletions
+8 -5
View File
@@ -1,4 +1,4 @@
import type { AggregateDatabase } from "../interfaces.js";
import type { AggregateDatabase } from "../AggregateDatabase/interfaces.js";
import { stockDatabase as stockDatabaseClickhouse } from "../stockdb/clickhouse.js";
import { stockDatabase as stockDatabaseLmdbx } from "../stockdb/lmdbx.js";
// import { optionContractDatabase as optionContractDatabaseClickhouse } from "../optiondb.clickhouse.js";
@@ -20,7 +20,7 @@ async function syncAggregates<T>({
date: string;
}) {
const aggregatesFrom = (await fromDatabase.getAggregates({ key, date })).map(
(aggregateWithoutKey) => ({ ...aggregateWithoutKey, key }),
(aggregateWithoutKey) => ({ ...aggregateWithoutKey, key })
);
await toDatabase.insertAggregates(aggregatesFrom);
}
@@ -29,7 +29,10 @@ const symbols = ["AMD", "AAPL", "MSFT", "GOOGL", "NFLX", "NVDA"];
async function run<T extends StockKey | OptionContractKey>({
fromDatabase,
toDatabase,
}: { fromDatabase: AggregateDatabase<T>; toDatabase: AggregateDatabase<T> }) {
}: {
fromDatabase: AggregateDatabase<T>;
toDatabase: AggregateDatabase<T>;
}) {
const startDate = process.argv[2];
const endDate = process.argv[3];
@@ -48,7 +51,7 @@ async function run<T extends StockKey | OptionContractKey>({
key: { symbol } as T,
date,
}),
{ shouldRetry: retryOnTimeout },
{ shouldRetry: retryOnTimeout }
);
for (const key of keys) {
@@ -61,7 +64,7 @@ async function run<T extends StockKey | OptionContractKey>({
key,
date,
}),
{ shouldRetry: retryOnTimeout },
{ shouldRetry: retryOnTimeout }
);
}
}