Implement options snapshot tape table

This commit is contained in:
dirtydishes 2026-05-04 01:14:52 -04:00
parent 6abfff30d3
commit e78387130a
15 changed files with 904 additions and 128 deletions

View file

@ -22,6 +22,31 @@ export const OptionPrintSchema = EventMetaSchema.merge(
option_type: z.preprocess((value) => (value === null ? undefined : value), OptionTypeSchema.optional()),
notional: z.preprocess((value) => (value === null ? undefined : value), z.number().nonnegative().optional()),
nbbo_side: z.preprocess((value) => (value === null ? undefined : value), OptionNbboSideSchema.optional()),
execution_nbbo_bid: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_nbbo_ask: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_nbbo_mid: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_nbbo_spread: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_nbbo_bid_size: z.preprocess((value) => (value === null ? undefined : value), z.number().int().nonnegative().optional()),
execution_nbbo_ask_size: z.preprocess((value) => (value === null ? undefined : value), z.number().int().nonnegative().optional()),
execution_nbbo_ts: z.preprocess((value) => (value === null ? undefined : value), z.number().int().nonnegative().optional()),
execution_nbbo_age_ms: z.preprocess((value) => (value === null ? undefined : value), z.number().nonnegative().optional()),
execution_nbbo_side: z.preprocess((value) => (value === null ? undefined : value), OptionNbboSideSchema.optional()),
execution_underlying_spot: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_underlying_bid: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_underlying_ask: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_underlying_mid: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_underlying_spread: z.preprocess((value) => (value === null ? undefined : value), z.number().optional()),
execution_underlying_ts: z.preprocess((value) => (value === null ? undefined : value), z.number().int().nonnegative().optional()),
execution_underlying_age_ms: z.preprocess((value) => (value === null ? undefined : value), z.number().nonnegative().optional()),
execution_underlying_source: z.preprocess(
(value) => (value === null ? undefined : value),
z.literal("equity_quote_mid").optional()
),
execution_iv: z.preprocess((value) => (value === null ? undefined : value), z.number().nonnegative().optional()),
execution_iv_source: z.preprocess(
(value) => (value === null ? undefined : value),
z.enum(["provider", "synthetic_pressure_model"]).optional()
),
is_etf: z.preprocess((value) => (value === null ? undefined : value), z.boolean().optional()),
signal_pass: z.preprocess((value) => (value === null ? undefined : value), z.boolean().optional()),
signal_reasons: z.array(z.string().min(1)).optional(),

View file

@ -0,0 +1,41 @@
import { describe, expect, it } from "bun:test";
import { OptionPrintSchema } from "../src/events";
describe("event schemas", () => {
it("accepts option print execution context fields", () => {
const parsed = OptionPrintSchema.parse({
source_ts: 100,
ingest_ts: 101,
seq: 1,
trace_id: "trace-1",
ts: 100,
option_contract_id: "SPY-2025-01-17-450-C",
price: 1.25,
size: 10,
exchange: "TEST",
execution_nbbo_bid: 1.2,
execution_nbbo_ask: 1.3,
execution_nbbo_mid: 1.25,
execution_nbbo_spread: 0.1,
execution_nbbo_bid_size: 20,
execution_nbbo_ask_size: 30,
execution_nbbo_ts: 99,
execution_nbbo_age_ms: 1,
execution_nbbo_side: "MID",
execution_underlying_spot: 450.05,
execution_underlying_bid: 450,
execution_underlying_ask: 450.1,
execution_underlying_mid: 450.05,
execution_underlying_spread: 0.1,
execution_underlying_ts: 98,
execution_underlying_age_ms: 2,
execution_underlying_source: "equity_quote_mid",
execution_iv: 0.42,
execution_iv_source: "synthetic_pressure_model"
});
expect(parsed.execution_nbbo_side).toBe("MID");
expect(parsed.execution_underlying_spot).toBe(450.05);
expect(parsed.execution_iv_source).toBe("synthetic_pressure_model");
});
});