feat(research): prepare stored data by declared sessions (RP03)
This commit is contained in:
parent
302ba60e53
commit
d2b78eacdf
10 changed files with 805 additions and 72 deletions
|
|
@ -7,6 +7,7 @@ import type {
|
|||
FinancialDecimal,
|
||||
HistoricalDatasetInputV2,
|
||||
HistoricalDatasetManifestV2,
|
||||
HistoricalDatasetMetadataV2,
|
||||
} from '@stock-bot/types';
|
||||
import { parseFinancialDecimal } from '@stock-bot/types';
|
||||
import { builtinStrategySelectionSchema } from './builtin-strategy';
|
||||
|
|
@ -214,8 +215,23 @@ export interface CanonicalDatasetPreparation {
|
|||
reason: string | null;
|
||||
}
|
||||
|
||||
/** One materialized storage read; retention must use this input without requerying. */
|
||||
/** Intersections only: declarations are supplied by the caller, never inferred from source bars. */
|
||||
export function declaredStoredSourceWindows(metadata: HistoricalDatasetMetadataV2) {
|
||||
const series = metadata.series[0];
|
||||
const calendar = metadata.calendars.find(item => item.id === series?.calendarId);
|
||||
return (calendar?.sessions ?? [])
|
||||
.map(session => ({
|
||||
date: session.date,
|
||||
start: Math.max(session.open, metadata.bounds.warmupStart),
|
||||
end: Math.min(session.close, metadata.bounds.tradeEnd),
|
||||
}))
|
||||
.filter(window => window.start < window.end)
|
||||
.sort((left, right) => left.start - right.start);
|
||||
}
|
||||
|
||||
/** Materialized source capture; retention must use this input without requerying. */
|
||||
export interface CanonicalStoredSourcePreparation {
|
||||
selection?: 'declared-sessions';
|
||||
input: HistoricalDatasetInputV2;
|
||||
preparation: CanonicalDatasetPreparation;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue