Expand options tape display and retention

- Add a dedicated hot-window limit for options prints
- Improve option contract and notional formatting in the tape
- Update docs, env sample, and tests
This commit is contained in:
dirtydishes 2026-04-29 00:10:37 -04:00
parent da942079f3
commit 9131e046cb
5 changed files with 235 additions and 18 deletions

View file

@ -2,6 +2,8 @@ import { describe, expect, it } from "bun:test";
import {
buildDefaultFlowFilters,
countActiveFlowFilterGroups,
formatCompactUsd,
formatOptionContractLabel,
flushPausableTapeData,
getLiveFeedStatus,
nextFlowFilterPopoverState,
@ -51,6 +53,18 @@ describe("live tape pausable helpers", () => {
expect(state.visible.map((item) => item.trace_id)).toEqual(["a"]);
});
it("applies custom retention limits when requested", () => {
const state = reducePausableTapeData(
{ visible: [], queued: [], seenKeys: new Set<string>(), dropped: 0 },
[makeItem("a", 1, 100), makeItem("b", 2, 200), makeItem("c", 3, 300)],
false,
2
);
expect(state.visible.map((item) => item.trace_id)).toEqual(["c", "b"]);
expect(state.visible).toHaveLength(2);
});
it("marks connected feeds stale once their freshest event ages past the threshold", () => {
expect(getLiveFeedStatus("connected", 1000, 500, 1400)).toBe("connected");
expect(getLiveFeedStatus("connected", 1000, 500, 1601)).toBe("stale");
@ -107,6 +121,43 @@ describe("live tape pausable helpers", () => {
});
});
describe("options display formatters", () => {
it("formats dashed option contracts as ticker strike expiry", () => {
expect(formatOptionContractLabel("SPY-2025-01-17-450-C")).toEqual({
ticker: "SPY",
strike: "450C",
expiration: "01-17-25"
});
});
it("formats OCC contracts as ticker strike expiry", () => {
expect(formatOptionContractLabel("AAPL250117P00150000")).toEqual({
ticker: "AAPL",
strike: "150P",
expiration: "01-17-25"
});
});
it("preserves decimal strikes and side suffix", () => {
expect(formatOptionContractLabel("QQQ-2025-01-17-509.5-C")).toEqual({
ticker: "QQQ",
strike: "509.5C",
expiration: "01-17-25"
});
});
it("returns null when contract parsing fails", () => {
expect(formatOptionContractLabel("not-a-contract")).toBeNull();
});
it("formats compact notional values", () => {
expect(formatCompactUsd(999)).toBe("999.00");
expect(formatCompactUsd(11_430)).toBe("11.4K");
expect(formatCompactUsd(1_250_000)).toBe("1.3M");
expect(formatCompactUsd(Number.NaN)).toBe("0.00");
});
});
describe("flow filter popup helpers", () => {
it("opens and closes the popup via toggle and dismiss actions", () => {
expect(nextFlowFilterPopoverState(false, "toggle")).toBe(true);