feat(research): prepare stored EOD datasets before canonical admission
This commit is contained in:
parent
366bee810b
commit
0c6aec4dc6
16 changed files with 1897 additions and 61 deletions
|
|
@ -39,6 +39,17 @@ import { seedBuiltinCatalog } from '../../scripts/seed-builtin-strategies';
|
|||
|
||||
setLoggerConfig({ logLevel: 'fatal', logConsole: false });
|
||||
const logger = getLogger('browser-fixture');
|
||||
interface StoredEodBar {
|
||||
eodSearchCode: string;
|
||||
symbol: string;
|
||||
exchange: string;
|
||||
timestamp: number;
|
||||
open: number;
|
||||
high: number;
|
||||
low: number;
|
||||
close: number;
|
||||
volume: number;
|
||||
}
|
||||
export function gate() {
|
||||
let resolve!: () => void;
|
||||
const promise = new Promise<void>(done => {
|
||||
|
|
@ -395,7 +406,35 @@ export async function fixture(browser: Browser, native = false) {
|
|||
}
|
||||
});
|
||||
cleanup.push(() => dispatcher.shutdown());
|
||||
const container = { postgres, logger } as IServiceContainer;
|
||||
// Replace only Mongo transport; HTTP preparation exercises the real EOD
|
||||
// StorageService adapter, while retained execution must never read it.
|
||||
const storedEodBars = new Map<string, StoredEodBar[]>();
|
||||
const storedSourceReads: {
|
||||
collection: string;
|
||||
filter: { eodSearchCode: string; timestamp: { $gte: number; $lt: number } };
|
||||
}[] = [];
|
||||
const mongodb = {
|
||||
async find(
|
||||
collection: string,
|
||||
filter: { eodSearchCode: string; timestamp: { $gte: number; $lt: number } }
|
||||
) {
|
||||
if (!['eodIntraday1M', 'eodIntraday5M', 'eodIntraday1H'].includes(collection)) {
|
||||
throw new Error('Unexpected stored-source collection');
|
||||
}
|
||||
storedSourceReads.push({ collection, filter: structuredClone(filter) });
|
||||
return structuredClone(
|
||||
(storedEodBars.get(collection) ?? [])
|
||||
.filter(
|
||||
bar =>
|
||||
bar.eodSearchCode === filter.eodSearchCode &&
|
||||
bar.timestamp >= filter.timestamp.$gte &&
|
||||
bar.timestamp < filter.timestamp.$lt
|
||||
)
|
||||
.sort((a, b) => a.timestamp - b.timestamp)
|
||||
);
|
||||
},
|
||||
} as unknown as NonNullable<IServiceContainer['mongodb']>;
|
||||
const container = { postgres, mongodb, logger } as IServiceContainer;
|
||||
const token = randomUUID() + randomUUID();
|
||||
const security = createHttpSecurity({
|
||||
adminToken: token,
|
||||
|
|
@ -602,6 +641,10 @@ export async function fixture(browser: Browser, native = false) {
|
|||
close,
|
||||
unexpectedNetwork,
|
||||
historicalDataReads,
|
||||
storedSourceReads,
|
||||
setStoredEodBars: (collection: string, bars: StoredEodBar[]) => {
|
||||
storedEodBars.set(collection, structuredClone(bars));
|
||||
},
|
||||
seedCatalog: () => seedBuiltinCatalog(new StrategyCatalogService(container)),
|
||||
};
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue