43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { createDatasetV2 } from '../../apps/stock/orchestrator/src/data/historical-dataset-v2';
|
|
import { nativeReplayFixture } from './native-replay';
|
|
|
|
/** Three explicit windows; a later suffix can change without changing earlier observations. */
|
|
export function chronologicalDataset(testSuffixPrice?: number) {
|
|
const fixture = nativeReplayFixture(36);
|
|
const { calendars, series, executionSeries, bounds, universe, corporateActions } =
|
|
fixture.dataset.manifest;
|
|
const closes = [3, 2, 1, 4, 5, 1, 1, 3, 6, 2, 1, 4];
|
|
const dataset = createDatasetV2({
|
|
metadata: { calendars, series, executionSeries, bounds, universe, corporateActions },
|
|
bars: fixture.dataset.bars.map((bar, index) => {
|
|
const close =
|
|
index >= 28 && testSuffixPrice !== undefined
|
|
? testSuffixPrice + index
|
|
: closes[index % closes.length]!;
|
|
const open = index === 0 ? 3 : closes[(index - 1) % closes.length]!;
|
|
return {
|
|
seriesId: bar.seriesId,
|
|
timestamp: bar.intervalStart,
|
|
availableAt: bar.availableAt,
|
|
sourceSequence: bar.sourceSequence,
|
|
open,
|
|
close,
|
|
high: Math.max(open, close),
|
|
low: Math.min(open, close),
|
|
volume: 1000,
|
|
};
|
|
}),
|
|
});
|
|
const at = (step: number) => fixture.start + step * fixture.minute;
|
|
return {
|
|
...fixture,
|
|
dataset,
|
|
recipe: {
|
|
version: 1 as const,
|
|
labelHorizonMs: 0 as const,
|
|
train: { warmupStart: at(0), tradeStart: at(6), tradeEnd: at(12) },
|
|
validation: { warmupStart: at(10), tradeStart: at(16), tradeEnd: at(24) },
|
|
test: { warmupStart: at(22), tradeStart: at(28), tradeEnd: at(36) },
|
|
},
|
|
};
|
|
}
|