25 lines
747 B
TypeScript
25 lines
747 B
TypeScript
import { z } from 'zod';
|
|
import {
|
|
datasetHashSchema,
|
|
datasetManifestSchema,
|
|
historicalDataPolicySchema,
|
|
instrumentIdSchema,
|
|
} from '@stock-bot/stock-config/backtest';
|
|
|
|
export { datasetHashSchema, datasetManifestSchema, historicalDataPolicySchema, instrumentIdSchema };
|
|
const positive = z.number().finite().positive();
|
|
export const datasetBarSchema = z
|
|
.object({
|
|
symbol: instrumentIdSchema,
|
|
timestamp: z.number().int().nonnegative(),
|
|
open: positive,
|
|
high: positive,
|
|
low: positive,
|
|
close: positive,
|
|
volume: z.number().finite().nonnegative(),
|
|
vwap: positive,
|
|
})
|
|
.strict();
|
|
export const datasetSchema = z
|
|
.object({ manifest: datasetManifestSchema, bars: z.array(datasetBarSchema).min(1) })
|
|
.strict();
|