Share backtest request contracts and isolate stored result mapping
This commit is contained in:
parent
007e35c747
commit
420c47704e
21 changed files with 777 additions and 244 deletions
|
|
@ -1,21 +1,11 @@
|
|||
import { z } from 'zod';
|
||||
import { parseInstrumentId } from '@stock-bot/types';
|
||||
import {
|
||||
datasetHashSchema,
|
||||
historicalDataPolicySchema,
|
||||
instrumentIdSchema,
|
||||
} from '@stock-bot/stock-config/backtest';
|
||||
|
||||
export const instrumentIdSchema = z.string().refine(id => {
|
||||
try {
|
||||
parseInstrumentId(id);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, 'Use an exchange-qualified instrument ID, for example AAPL.US');
|
||||
export const historicalDataPolicySchema = z
|
||||
.object({
|
||||
adjustment: z.enum(['raw', 'provider-adjusted']),
|
||||
timestamp: z.enum(['utc-session-date', 'utc-instant']),
|
||||
})
|
||||
.strict();
|
||||
export const datasetHashSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
||||
export { datasetHashSchema, historicalDataPolicySchema, instrumentIdSchema };
|
||||
const positive = z.number().finite().positive();
|
||||
export const datasetBarSchema = z
|
||||
.object({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue