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
|
|
@ -5,6 +5,7 @@ import type {
|
|||
CanonicalBacktestAnalytics,
|
||||
financialDecimal,
|
||||
FinancialDecimal,
|
||||
HistoricalDatasetInputV2,
|
||||
HistoricalDatasetManifestV2,
|
||||
} from '@stock-bot/types';
|
||||
import { parseFinancialDecimal } from '@stock-bot/types';
|
||||
|
|
@ -184,6 +185,12 @@ export interface CanonicalDatasetPreparation {
|
|||
reason: string | null;
|
||||
}
|
||||
|
||||
/** One materialized storage read; retention must use this input without requerying. */
|
||||
export interface CanonicalStoredSourcePreparation {
|
||||
input: HistoricalDatasetInputV2;
|
||||
preparation: CanonicalDatasetPreparation;
|
||||
}
|
||||
|
||||
/** Validate the authoritative financial envelope without legacy metric conversion. */
|
||||
export function parseCanonicalFinancialResult(input: unknown, request: CanonicalRunRequest) {
|
||||
return parseReplayReportValue(
|
||||
|
|
|
|||
|
|
@ -278,6 +278,11 @@ function parseMetadata(input: unknown) {
|
|||
return metadata;
|
||||
}
|
||||
|
||||
/** Validate and detach complete operator declarations before a stored-source read. */
|
||||
export function parseHistoricalDatasetMetadataV2(input: unknown): HistoricalDatasetMetadataV2 {
|
||||
return parseMetadata(input);
|
||||
}
|
||||
|
||||
function assess(metadata: HistoricalDatasetMetadataV2, parentDatasetHash: string | null) {
|
||||
const limitations = [
|
||||
'Open liquidity must use previously available volume; intraday partial bars are unsupported',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { Hono } from 'hono';
|
|||
import { getLogger } from '@stock-bot/logger';
|
||||
import { requireServices, type IServiceContainer } from '@stock-bot/services';
|
||||
import { HistoricalDataRequestError } from '@stock-bot/types';
|
||||
import { StorageService } from '../../../orchestrator/src/services/StorageService';
|
||||
import { canonicalDatasetEntry } from '../services/canonical-research.service';
|
||||
import { DatasetCatalogService } from '../services/dataset-catalog.service';
|
||||
import {
|
||||
|
|
@ -9,6 +10,10 @@ import {
|
|||
previewDatasetPreparation,
|
||||
retainDatasetPreparation,
|
||||
} from '../services/dataset-preparation.service';
|
||||
import {
|
||||
prepareStoredDataset,
|
||||
StoredDatasetPreparationError,
|
||||
} from '../services/stored-dataset-preparation';
|
||||
|
||||
const logger = getLogger('dataset-catalog-routes');
|
||||
|
||||
|
|
@ -23,6 +28,32 @@ export function createDatasetRoutes(container: IServiceContainer) {
|
|||
throw new DatasetPreparationError(400, 'Invalid JSON request');
|
||||
}
|
||||
};
|
||||
app.post('/api/v2/datasets/canonical/stored-source', async c => {
|
||||
c.header('Cache-Control', 'no-store');
|
||||
try {
|
||||
const body = await readBody(c.req.raw);
|
||||
// Request-local read adapter: no initialization, mode changes or shared trading runtime.
|
||||
const storage = new StorageService(container, container.mongodb, null, null);
|
||||
const prepared = await prepareStoredDataset(body, storage, c.req.raw.signal);
|
||||
c.req.raw.signal.throwIfAborted();
|
||||
return c.json(prepared);
|
||||
} catch (error) {
|
||||
if (c.req.raw.signal.aborted) {
|
||||
return Response.json(
|
||||
{ error: 'Stored source preparation cancelled' },
|
||||
{ status: 499, headers: { 'Cache-Control': 'no-store' } }
|
||||
);
|
||||
}
|
||||
if (
|
||||
error instanceof StoredDatasetPreparationError ||
|
||||
error instanceof DatasetPreparationError
|
||||
) {
|
||||
return c.json({ error: error.message }, error.status);
|
||||
}
|
||||
logger.error('Failed to prepare stored source dataset', error);
|
||||
return c.json({ error: 'Stored source preparation unavailable' }, 500);
|
||||
}
|
||||
});
|
||||
app.post('/api/v2/datasets/canonical/preview', async c => {
|
||||
c.header('Cache-Control', 'no-store');
|
||||
try {
|
||||
|
|
|
|||
136
apps/stock/web-api/src/services/stored-dataset-preparation.ts
Normal file
136
apps/stock/web-api/src/services/stored-dataset-preparation.ts
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
import { z } from 'zod';
|
||||
import type { CanonicalStoredSourcePreparation } from '@stock-bot/stock-config/canonical-research';
|
||||
import type { HistoricalDatasetInputV2, HistoricalDatasetMetadataV2 } from '@stock-bot/types';
|
||||
import { parseHistoricalDatasetMetadataV2 } from '../../../orchestrator/src/data/historical-dataset-v2';
|
||||
import {
|
||||
HistoricalStorageError,
|
||||
type StorageService,
|
||||
} from '../../../orchestrator/src/services/StorageService';
|
||||
import { DatasetPreparationError, previewDatasetPreparation } from './dataset-preparation.service';
|
||||
|
||||
export class StoredDatasetPreparationError extends Error {
|
||||
constructor(
|
||||
readonly status: 400 | 404 | 422 | 503,
|
||||
message: string
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
const bodySchema = z.object({ metadata: z.unknown() }).strict();
|
||||
function freeze<T>(value: T): T {
|
||||
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
||||
Object.values(value).forEach(freeze);
|
||||
Object.freeze(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function metadataFromBody(body: unknown): HistoricalDatasetMetadataV2 {
|
||||
try {
|
||||
const parsed = bodySchema.parse(body);
|
||||
return freeze(parseHistoricalDatasetMetadataV2(parsed.metadata));
|
||||
} catch (error) {
|
||||
const path = error instanceof z.ZodError ? error.issues[0]?.path.join('.') : undefined;
|
||||
throw new StoredDatasetPreparationError(
|
||||
400,
|
||||
path
|
||||
? `Invalid complete source metadata at ${path}`
|
||||
: 'Stored source requires valid complete v2 metadata'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Materialize one explicit stored EOD query. Captured bytes, not this mutable query, are retained. */
|
||||
export async function prepareStoredDataset(
|
||||
body: unknown,
|
||||
storage: Pick<StorageService, 'getHistoricalBars'>,
|
||||
signal: AbortSignal
|
||||
): Promise<CanonicalStoredSourcePreparation> {
|
||||
signal.throwIfAborted();
|
||||
const metadata = metadataFromBody(body);
|
||||
const series = metadata.series[0];
|
||||
if (
|
||||
!series ||
|
||||
metadata.series.length !== 1 ||
|
||||
metadata.executionSeries.length !== 1 ||
|
||||
metadata.universe.instrumentIds.length !== 1 ||
|
||||
series.source.provider !== 'eod' ||
|
||||
!['1m', '5m', '1h'].includes(series.interval) ||
|
||||
series.adjustment !== 'raw' ||
|
||||
series.timestamp !== 'interval-start' ||
|
||||
series.availability !== 'interval-end-assumption'
|
||||
) {
|
||||
throw new StoredDatasetPreparationError(
|
||||
400,
|
||||
'Stored source supports one EOD raw 1m/5m/1h series with interval-start timestamps and declared interval-end-assumption availability'
|
||||
);
|
||||
}
|
||||
let rows;
|
||||
try {
|
||||
rows = await storage.getHistoricalBars(
|
||||
series.instrumentId,
|
||||
new Date(metadata.bounds.warmupStart),
|
||||
new Date(metadata.bounds.tradeEnd),
|
||||
series.interval,
|
||||
{ adjustment: 'raw', timestamp: 'utc-instant' },
|
||||
signal,
|
||||
'eod'
|
||||
);
|
||||
} catch (error) {
|
||||
signal.throwIfAborted();
|
||||
if (error instanceof HistoricalStorageError && error.code === 'missing-range') {
|
||||
throw new StoredDatasetPreparationError(404, 'No stored EOD bars in the requested range');
|
||||
}
|
||||
if (error instanceof HistoricalStorageError && error.code === 'provider-unavailable') {
|
||||
throw new StoredDatasetPreparationError(503, 'EOD historical storage is unavailable');
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
signal.throwIfAborted();
|
||||
if (!rows.length) {
|
||||
throw new StoredDatasetPreparationError(404, 'No stored EOD bars in the requested range');
|
||||
}
|
||||
for (const row of rows) {
|
||||
if (
|
||||
row.symbol !== series.instrumentId ||
|
||||
row.source !== 'eod' ||
|
||||
row.interpolated === true ||
|
||||
!(row.timestamp instanceof Date) ||
|
||||
!Number.isSafeInteger(row.timestamp.getTime()) ||
|
||||
row.timestamp.getTime() < metadata.bounds.warmupStart ||
|
||||
row.timestamp.getTime() >= metadata.bounds.tradeEnd
|
||||
) {
|
||||
throw new Error('Stored source returned inconsistent bar identity or range');
|
||||
}
|
||||
}
|
||||
const input: HistoricalDatasetInputV2 = freeze({
|
||||
metadata,
|
||||
// Ordinal is deterministic adapter ordering, not a vendor publication sequence.
|
||||
bars: [...rows]
|
||||
.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime())
|
||||
.map((row, sourceSequence) => ({
|
||||
seriesId: series.id,
|
||||
timestamp: row.timestamp.getTime(),
|
||||
sourceSequence,
|
||||
open: row.open,
|
||||
high: row.high,
|
||||
low: row.low,
|
||||
close: row.close,
|
||||
volume: row.volume,
|
||||
...(row.vwap === undefined ? {} : { vwap: row.vwap }),
|
||||
})),
|
||||
});
|
||||
let preparation;
|
||||
try {
|
||||
preparation = previewDatasetPreparation({ input });
|
||||
} catch (error) {
|
||||
if (error instanceof DatasetPreparationError) {
|
||||
throw new StoredDatasetPreparationError(
|
||||
422,
|
||||
'Stored bars do not match the declared complete dataset metadata and interval policy'
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
signal.throwIfAborted();
|
||||
return freeze({ input, preparation });
|
||||
}
|
||||
|
|
@ -18,8 +18,11 @@ interface Retention {
|
|||
input: unknown;
|
||||
preview: CanonicalDatasetPreparation;
|
||||
}
|
||||
type InputMode = 'export' | 'stored-eod';
|
||||
const instant = (value: number) => new Date(value).toISOString();
|
||||
export function DatasetPreparation({ disabled, begin, onStateChange, onRetained }: Props) {
|
||||
const [mode, setMode] = useState<InputMode>('export');
|
||||
const modeRef = useRef<InputMode>('export');
|
||||
const [input, setInput] = useState<{ value: unknown; filename: string } | null>(null);
|
||||
const [preview, setPreview] = useState<CanonicalDatasetPreparation | null>(null);
|
||||
const [retained, setRetained] = useState(false),
|
||||
|
|
@ -65,6 +68,20 @@ export function DatasetPreparation({ disabled, begin, onStateChange, onRetained
|
|||
}
|
||||
state(false, false);
|
||||
};
|
||||
const changeMode = (next: string) => {
|
||||
if (
|
||||
(next !== 'export' && next !== 'stored-eod') ||
|
||||
next === modeRef.current ||
|
||||
disabled ||
|
||||
captured.current ||
|
||||
!callbacks.current.begin()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
reset();
|
||||
modeRef.current = next;
|
||||
setMode(next);
|
||||
};
|
||||
const loadFile = async (file: File | undefined) => {
|
||||
if (disabled || captured.current || !callbacks.current.begin()) {
|
||||
return;
|
||||
|
|
@ -107,6 +124,7 @@ export function DatasetPreparation({ disabled, begin, onStateChange, onRetained
|
|||
};
|
||||
const inspect = async () => {
|
||||
const selectedSource = source.current;
|
||||
const selectedMode = modeRef.current;
|
||||
if (
|
||||
disabled ||
|
||||
pending.current ||
|
||||
|
|
@ -127,10 +145,16 @@ export function DatasetPreparation({ disabled, begin, onStateChange, onRetained
|
|||
setRetained(false);
|
||||
state(true, true);
|
||||
try {
|
||||
const result = await backtestApiV2.previewDataset(selectedSource.value, abort.signal);
|
||||
const result =
|
||||
selectedMode === 'stored-eod'
|
||||
? await backtestApiV2.previewStoredDataset(selectedSource.value, abort.signal)
|
||||
: {
|
||||
input: selectedSource.value,
|
||||
preparation: await backtestApiV2.previewDataset(selectedSource.value, abort.signal),
|
||||
};
|
||||
if (active.current && revision === generation.current) {
|
||||
prepared.current = { input: selectedSource.value, preview: result };
|
||||
setPreview(result);
|
||||
prepared.current = { input: result.input, preview: result.preparation };
|
||||
setPreview(result.preparation);
|
||||
}
|
||||
} catch (cause) {
|
||||
if (active.current && revision === generation.current) {
|
||||
|
|
@ -197,7 +221,9 @@ export function DatasetPreparation({ disabled, begin, onStateChange, onRetained
|
|||
prepared.current = null;
|
||||
setIntent(null);
|
||||
setPreview(null);
|
||||
setError(`${cause.message} Preview again or choose a corrected source export.`);
|
||||
setError(
|
||||
`${cause.message} Preview again or choose a corrected ${modeRef.current === 'export' ? 'source export' : 'metadata file'}.`
|
||||
);
|
||||
} else {
|
||||
setError(
|
||||
`${cause instanceof Error ? cause.message : 'Dataset retention response was lost'} Retry the exact same input and hash; retention may already have succeeded.`
|
||||
|
|
@ -215,25 +241,53 @@ export function DatasetPreparation({ disabled, begin, onStateChange, onRetained
|
|||
return (
|
||||
<section aria-label="Source dataset preparation" className="space-y-3 text-sm">
|
||||
<p>
|
||||
Supply a complete source export with metadata and bars. Sessions, source revisions,
|
||||
universe, corporate actions and publication availability must be explicit. Declared
|
||||
provenance is not independent provider certification. Preview writes nothing; retention does
|
||||
not save settings or start a run.
|
||||
Supply complete metadata with exported bars or explicitly selected stored EOD intraday bars.
|
||||
Sessions, source revisions, universe, corporate actions and publication availability must be
|
||||
explicit. Declared provenance is not independent provider certification. Preview writes
|
||||
nothing; retention does not save settings or start a run.
|
||||
</p>
|
||||
<label className="block">
|
||||
Source dataset JSON
|
||||
Dataset input
|
||||
<select
|
||||
aria-label="Dataset input"
|
||||
className={fieldClass}
|
||||
value={mode}
|
||||
disabled={disabled || Boolean(intent)}
|
||||
onChange={event => changeMode(event.target.value)}
|
||||
>
|
||||
<option value="export">Source export</option>
|
||||
<option value="stored-eod">Stored EOD intraday bars</option>
|
||||
</select>
|
||||
</label>
|
||||
{mode === 'stored-eod' && (
|
||||
<p>
|
||||
Load one EOD instrument from existing storage using raw 1m, 5m or 1h interval-start bars.
|
||||
Supply complete metadata with interval-end-assumption availability. Source sequence is a
|
||||
deterministic sorted row ordinal, not a vendor sequence. The current store, history and
|
||||
declared revision are not independently certified. Preview reads a new snapshot; retention
|
||||
uses that captured snapshot without querying storage again.
|
||||
</p>
|
||||
)}
|
||||
<label className="block">
|
||||
{mode === 'export' ? 'Source dataset JSON' : 'Source metadata JSON'}
|
||||
<input
|
||||
ref={fileInput}
|
||||
className={fieldClass}
|
||||
type="file"
|
||||
accept="application/json,.json"
|
||||
aria-label="Source dataset JSON"
|
||||
aria-label={mode === 'export' ? 'Source dataset JSON' : 'Source metadata JSON'}
|
||||
disabled={disabled || Boolean(intent)}
|
||||
onChange={event => void loadFile(event.target.files?.[0])}
|
||||
/>
|
||||
</label>
|
||||
{!input && !phase && !error && <p>No source export selected.</p>}
|
||||
{input && <p>Selected export: {input.filename}</p>}
|
||||
{!input && !phase && !error && (
|
||||
<p>{mode === 'export' ? 'No source export selected.' : 'No source metadata selected.'}</p>
|
||||
)}
|
||||
{input && (
|
||||
<p>
|
||||
Selected {mode === 'export' ? 'export' : 'metadata'}: {input.filename}
|
||||
</p>
|
||||
)}
|
||||
{phase && (
|
||||
<p role="status">
|
||||
{phase === 'reading'
|
||||
|
|
@ -295,6 +349,13 @@ export function DatasetPreparation({ disabled, begin, onStateChange, onRetained
|
|||
)}
|
||||
{preview && (
|
||||
<section aria-label="Prepared dataset metadata" className="space-y-2 break-words">
|
||||
{mode === 'stored-eod' && (
|
||||
<p>
|
||||
Stored source: EOD · Query bounds (UTC, end exclusive):{' '}
|
||||
{instant(preview.manifest.bounds.warmupStart)} —{' '}
|
||||
{instant(preview.manifest.bounds.tradeEnd)}
|
||||
</p>
|
||||
)}
|
||||
<p className="break-all">Dataset hash: {preview.hash}</p>
|
||||
<p>
|
||||
{preview.manifest.barCount} bars · Eligibility: {preview.manifest.eligibility} ·{' '}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ import type {
|
|||
CanonicalReproductionComparison,
|
||||
CanonicalReproductionPreview,
|
||||
CanonicalRunCapability,
|
||||
CanonicalStoredSourcePreparation,
|
||||
ResearchRunResult,
|
||||
} from '@stock-bot/stock-config/canonical-research';
|
||||
import { canonicalStrategyJson } from '@stock-bot/stock-config/strategy';
|
||||
import type {
|
||||
BacktestRunDatasetSelection,
|
||||
BacktestRunResult,
|
||||
|
|
@ -260,6 +262,118 @@ export function parseDatasetPreparation(
|
|||
}
|
||||
return value;
|
||||
}
|
||||
const preparationMetadata = preparationManifest.pick({
|
||||
calendars: true,
|
||||
series: true,
|
||||
executionSeries: true,
|
||||
bounds: true,
|
||||
universe: true,
|
||||
corporateActions: true,
|
||||
});
|
||||
const storedSourceInput = z
|
||||
.object({
|
||||
metadata: preparationMetadata,
|
||||
bars: z
|
||||
.array(
|
||||
z
|
||||
.object({
|
||||
seriesId: preparationText,
|
||||
timestamp: preparationInstant,
|
||||
sourceSequence: z.number().int().nonnegative().safe(),
|
||||
open: z.number().finite().positive(),
|
||||
high: z.number().finite().positive(),
|
||||
low: z.number().finite().positive(),
|
||||
close: z.number().finite().positive(),
|
||||
volume: z.number().finite().nonnegative(),
|
||||
vwap: z.number().finite().positive().nullable().optional(),
|
||||
})
|
||||
.strict()
|
||||
)
|
||||
.min(1),
|
||||
})
|
||||
.strict();
|
||||
type PreparationMetadata = z.infer<typeof preparationMetadata>;
|
||||
const compareText = (left: string, right: string) => (left < right ? -1 : left > right ? 1 : 0);
|
||||
/** Compare declarations across server-normalized collection order; never normalize bars or calculate hashes. */
|
||||
function metadataIdentity(value: PreparationMetadata) {
|
||||
return canonicalStrategyJson({
|
||||
...value,
|
||||
calendars: value.calendars
|
||||
.map(calendar => ({
|
||||
...calendar,
|
||||
sessions: [...calendar.sessions].sort((a, b) => compareText(a.date, b.date)),
|
||||
}))
|
||||
.sort((a, b) => compareText(a.id, b.id)),
|
||||
series: [...value.series].sort((a, b) => compareText(a.id, b.id)),
|
||||
executionSeries: [...value.executionSeries].sort((a, b) =>
|
||||
compareText(a.instrumentId, b.instrumentId)
|
||||
),
|
||||
universe: {
|
||||
...value.universe,
|
||||
instrumentIds: [...value.universe.instrumentIds].sort(compareText),
|
||||
},
|
||||
corporateActions: value.corporateActions
|
||||
.map(coverage => ({
|
||||
...coverage,
|
||||
actions: [...coverage.actions].sort(
|
||||
(a, b) => a.effectiveAt - b.effectiveAt || compareText(a.reference, b.reference)
|
||||
),
|
||||
}))
|
||||
.sort((a, b) => compareText(a.instrumentId, b.instrumentId)),
|
||||
});
|
||||
}
|
||||
export function parseStoredDatasetPreparation(
|
||||
raw: unknown,
|
||||
suppliedMetadata: unknown
|
||||
): CanonicalStoredSourcePreparation {
|
||||
const envelope = z
|
||||
.object({ input: storedSourceInput, preparation: z.unknown() })
|
||||
.strict()
|
||||
.parse(raw);
|
||||
const preparation = parseDatasetPreparation(envelope.preparation);
|
||||
const expected = preparationMetadata.parse(suppliedMetadata);
|
||||
const { calendars, series, executionSeries, bounds, universe, corporateActions } =
|
||||
preparation.manifest;
|
||||
const retainedMetadata = {
|
||||
calendars,
|
||||
series,
|
||||
executionSeries,
|
||||
bounds,
|
||||
universe,
|
||||
corporateActions,
|
||||
};
|
||||
const input = envelope.input,
|
||||
metadata = input.metadata,
|
||||
selected = metadata.series[0];
|
||||
if (
|
||||
!selected ||
|
||||
metadata.series.length !== 1 ||
|
||||
metadata.executionSeries.length !== 1 ||
|
||||
metadata.universe.instrumentIds.length !== 1 ||
|
||||
selected.source.provider !== 'eod' ||
|
||||
!['1m', '5m', '1h'].includes(selected.interval) ||
|
||||
selected.adjustment !== 'raw' ||
|
||||
selected.timestamp !== 'interval-start' ||
|
||||
selected.availability !== 'interval-end-assumption' ||
|
||||
metadata.executionSeries[0]?.seriesId !== selected.id ||
|
||||
metadata.executionSeries[0]?.instrumentId !== selected.instrumentId ||
|
||||
metadata.universe.instrumentIds[0] !== selected.instrumentId ||
|
||||
metadataIdentity(metadata) !== metadataIdentity(expected) ||
|
||||
metadataIdentity(metadata) !== metadataIdentity(preparationMetadata.parse(retainedMetadata)) ||
|
||||
input.bars.length !== preparation.manifest.barCount ||
|
||||
input.bars.some(
|
||||
(bar, index) =>
|
||||
bar.seriesId !== selected.id ||
|
||||
bar.sourceSequence !== index ||
|
||||
bar.timestamp < metadata.bounds.warmupStart ||
|
||||
bar.timestamp >= metadata.bounds.tradeEnd ||
|
||||
(index > 0 && bar.timestamp <= (input.bars[index - 1]?.timestamp ?? Infinity))
|
||||
)
|
||||
) {
|
||||
throw new Error('The stored source response does not match its metadata and prepared dataset.');
|
||||
}
|
||||
return { input, preparation };
|
||||
}
|
||||
export class DatasetPreparationRequestError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
|
|
@ -305,6 +419,28 @@ export const backtestApiV2 = {
|
|||
prepareDatasetRequest({ input }, signal),
|
||||
retainDataset: (input: unknown, expectedHash: string, signal?: AbortSignal) =>
|
||||
prepareDatasetRequest({ input, expectedHash }, signal),
|
||||
async previewStoredDataset(
|
||||
metadata: unknown,
|
||||
signal?: AbortSignal
|
||||
): Promise<CanonicalStoredSourcePreparation> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v2/datasets/canonical/stored-source`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ metadata }),
|
||||
signal,
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw await requestError(response, 'Could not load stored EOD bars');
|
||||
}
|
||||
try {
|
||||
if (response.status !== 200) {
|
||||
throw new Error('Unexpected stored source status');
|
||||
}
|
||||
return parseStoredDatasetPreparation(await response.json(), metadata);
|
||||
} catch {
|
||||
throw new Error('The stored source response could not be verified.');
|
||||
}
|
||||
},
|
||||
async reproductionPreview(
|
||||
id: string,
|
||||
signal?: AbortSignal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue