re-organized code; implemented getAggregate() where it was missing
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user