continuation

This commit is contained in:
Boki 2026-10-20 16:57:59 -04:00
parent 32e43c9243
commit 879e9b4228
42 changed files with 2607 additions and 1306 deletions

View file

@ -0,0 +1,30 @@
import { z } from 'zod';
import { BacktestConfigSchema } from '../types';
const finite = z.number().finite();
export const nativeWorkerRequestSchema = z.object({
type: z.literal('run'),
config: BacktestConfigSchema,
data: z.array(
z.object({
symbol: z.string(),
timestamp: finite,
type: z.literal('bar'),
open: finite,
high: finite,
low: finite,
close: finite,
volume: finite,
vwap: finite,
})
),
});
export const nativeWorkerMessageSchema = z.discriminatedUnion('type', [
z.object({ type: z.literal('progress'), progress: finite.min(0).max(100), message: z.string() }),
z.object({ type: z.literal('result'), result: z.string() }),
z.object({ type: z.literal('error'), message: z.string() }),
]);
export type NativeWorkerRequest = z.infer<typeof nativeWorkerRequestSchema>;
export type NativeWorkerMessage = z.infer<typeof nativeWorkerMessageSchema>;