feat(research): preview chronological validation inputs and windows
This commit is contained in:
parent
b373410320
commit
67ab30cb7a
25 changed files with 2917 additions and 54 deletions
|
|
@ -554,6 +554,46 @@ export function validateDatasetV2(input: unknown): HistoricalDatasetV2 {
|
|||
return dataset;
|
||||
}
|
||||
|
||||
/** Exact retained v2 interval slice. V2 lineage belongs to the caller's manifest;
|
||||
* parentDatasetHash continues to describe only the original legacy-v1 conversion. */
|
||||
export function sliceDatasetV2(
|
||||
input: unknown,
|
||||
boundsInput: HistoricalDatasetMetadataV2['bounds']
|
||||
): HistoricalDatasetV2 {
|
||||
const source = validateDatasetV2(input);
|
||||
const bounds = metadataSchema.shape.bounds.parse(boundsInput);
|
||||
if (
|
||||
bounds.warmupStart < source.manifest.bounds.warmupStart ||
|
||||
bounds.tradeStart < source.manifest.bounds.tradeStart ||
|
||||
bounds.tradeEnd > source.manifest.bounds.tradeEnd
|
||||
) {
|
||||
throw new Error('Slice bounds must remain within the source warmup and evaluation bounds');
|
||||
}
|
||||
for (const boundary of [bounds.warmupStart, bounds.tradeStart, bounds.tradeEnd]) {
|
||||
if (source.bars.some(bar => bar.intervalStart < boundary && boundary < bar.intervalEnd)) {
|
||||
throw new Error('Slice boundaries cannot cut through a retained bar interval');
|
||||
}
|
||||
}
|
||||
const {
|
||||
version: _version,
|
||||
hash: _hash,
|
||||
normalizationRevision: _revision,
|
||||
parentDatasetHash,
|
||||
volumePolicy: _volume,
|
||||
qualityPolicy: _quality,
|
||||
intradayPolicy: _intraday,
|
||||
eligibility: _eligibility,
|
||||
limitations: _limitations,
|
||||
barCount: _count,
|
||||
...rawMetadata
|
||||
} = source.manifest;
|
||||
const metadata = parseMetadata({ ...rawMetadata, bounds });
|
||||
const bars = source.bars.filter(
|
||||
bar => bar.intervalStart >= bounds.warmupStart && bar.intervalEnd <= bounds.tradeEnd
|
||||
);
|
||||
return finish(metadata, validateBars(metadata, bars), parentDatasetHash);
|
||||
}
|
||||
|
||||
/** Unknown coverage remains exploratory; this assertion does not certify economic correctness. */
|
||||
export function assertDatasetV2Executable(input: unknown): HistoricalDatasetV2 {
|
||||
const dataset = validateDatasetV2(input);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue