Spencer Morris
← Project index
ENGINEERING NOTES / 15 3 MIN READ

Trading Desk

A rules-driven prediction-market execution experiment with explicit outcome coverage, order-book costing, sequential hedge execution, and fail-closed controls.

Execution / research experiment
Trading Desk market pulse dashboard with exchange-offline statusView full size ↗
Actual locally running trading terminal during market-data initialization. The exchange-offline state is visible: this capture demonstrates the monitoring interface, not live quotes, executed trades or investment performance.
01 / THE PROBLEM

What needed solving.

Related contracts can appear to offer a guaranteed payout, but titles alone do not establish identical settlement rules; fees, book depth, partial fills, and broken legs can erase the apparent edge. The desk requires human-approved outcome relationships and models full package cost before execution.

02 / SYSTEM OUTLINE
  1. 01Approved outcome relationships
  2. 02Cost + depth + execution checks
  3. 03Hedged package or halt

Simplified from the implementation and project notes.

03 / TECHNICAL DECISIONS

How it fits together.

Approved relationship data enumerates exhaustive mutually exclusive outcome states and which YES legs pay in each state. The engine enumerates 2–3 leg YES/NO combinations whose payoff is at least one dollar in every state, walks order books leg by leg, adds venue fees and execution allowance, then applies entry price, profit, depth, and risk gates. The executor requotes, enters the thinnest leg first, uses fill-or-kill and limited completion attempts, unwinds unresolved exposure, and halts.

Risk controls include paper-by-default behavior, size and capital caps, minimum venue cash, exposure limits, a loss stop, and halts on broken hedges, unknown order state, fee mismatch, or stale quotes. Venue integrations are isolated behind adapters. A server/dashboard and event stream expose system state.

The separate replay tool is offline-only and cannot submit orders. It uses receipt-time ordering, preregistered policy/eligibility files, latency and queue assumptions, explicit fee metadata, sequence-gap handling, candidate denominators, and censored unknown execution risk. The replay labels its results as hypothetical and unpriced; public L2/trades cannot prove routing priority or counterfactual fills.

FEATURE WALKTHROUGH

Inside the software.

Prediction-market research and execution tooling: human-approved settlement relationships, package cost and depth checks, and fail-closed order handling. Offline replays and research studies retain their assumptions; modeled returns are not verified fills or evidence of a profitable strategy.

01 / FEATURE

Market pulse dashboard

Monitor venue connectivity, market data and desk state through a local dashboard and event stream.

HOW IT WORKS

Node/TypeScript service exposes status and server-sent events alongside venue adapters; the portfolio image intentionally shows exchange-offline initialization state.

Implemented; live data depends on venue connectivity and credentials.

Implementation references
  • trading-desk/README.md
  • trading-desk/src
  • trading-desk/config/desk.json
02 / FEATURE

Explicit settlement relationship model

Require approved, exhaustive, mutually exclusive outcome states before treating related contracts as a hedged package.

HOW IT WORKS

Relationship config enumerates settlement states and paying YES legs; validation checks coverage and supports two- or three-leg combinations.

Implemented; relationships require human review and approval.

Implementation references
  • trading-desk/config/relationships.json
  • trading-desk/README.md
  • trading-desk/src
03 / FEATURE

Package cost and depth scanner

Enumerate combinations that cover every approved outcome, walk order books, include fees and execution allowance, then apply price, profit, depth and risk gates.

HOW IT WORKS

Rules engine calculates worst-state payout and full package cost from available levels, with venue fee assumptions and configured limits.

Implemented; market inputs and fee assumptions can change.

Implementation references
  • trading-desk/src
  • trading-desk/src/risk.ts
  • trading-desk/config/desk.json
  • trading-desk/README.md
04 / FEATURE

Sequential hedge execution and fail-closed risk

Requote and execute the thinnest leg first with limited completion attempts; unwind unresolved exposure and halt on uncertain state.

HOW IT WORKS

Paper mode is default; caps cover size, capital, venue cash, exposure and loss. Broken hedges, unknown order state, fee mismatch and stale quotes stop execution.

Implemented; live execution requires deliberate configuration/authentication and carries execution risk.

Implementation references
  • trading-desk/src/executor.ts
  • trading-desk/src/risk.ts
  • trading-desk/config/desk.json
  • trading-desk/README.md
05 / FEATURE

Isolated Kalshi and Polymarket US adapters

Keep venue-specific market data, fee and order operations behind adapter boundaries.

HOW IT WORKS

Adapters normalize venue operations for scanner and executor; fee checks halt when realized fees exceed modeled assumptions.

Implemented; API availability and account configuration are external dependencies.

Implementation references
  • trading-desk/src
  • trading-desk/README.md
  • trading-desk/config/desk.json
06 / FEATURE

Offline execution replay

Replay a recorder cohort in receipt-time order under preregistered eligibility, latency and queue assumptions, with unresolved execution risk censored.

HOW IT WORKS

Standalone research replay cannot submit orders; writes candidate and order lifecycle evidence with explicit fees and sequence-gap handling.

Implemented research tool; outputs are hypothetical and cannot establish routing priority, counterfactual fills or profitability.

Implementation references
  • trading-desk/research/REPLAY.md
  • trading-desk/research
  • trading-desk/README.md
07 / FEATURE

Registered market research studies

Maintain separate reproducible research modules for market structure, crypto, sports, books and trade-tape questions, with preregistration, hashes, tests and review handoffs.

Registered market research studies in the running trading-desk interfaceView full size ↗
Actual research UI rendering the repository baseline study: calibration, fee-adjusted returns, and confidence intervals. Aggregate historical study data, served locally with live feeds disabled. Modeled trades are not verified fills.
Registered market research studies in the running trading-desk interfaceView full size ↗
Repricing study with its out-of-sample result and uncertainty. Actual UI and saved aggregate research data; the live opportunity table is intentionally offline.
HOW IT WORKS

Research subprojects hold frozen/registered configs, data capture and audit scripts, statistical outputs, amendments and explicit evidence classifications; each study has its own assumptions and data window.

Implemented research artifacts. Each report records its sample, window, and uncertainty. These studies do not establish general profitability.

Implementation references
  • trading-desk/research/REPLAY.md
  • trading-desk/research/run_registered_batch.py
  • trading-desk/research/sports_push_live_v4/REGISTERED.md
  • trading-desk/research/crypto_economics_v2/README.md
  • trading-desk/research/book_v1/README.md
04 / WORKING METHOD

Building and checking it.

Operators inspect contract rules and approve a relationship, run read-only scans, then authenticate and use paper mode unless live behavior is explicitly configured and invoked. Before approval, each leg's settlement source, rounding, release, outcome coverage, and resolution timing are checked. The sequential executor halts on uncertain state rather than continuing with an incomplete hedge.

Research replay consumes one recorder cohort in receipt order under predeclared policy and eligibility assumptions, writing per-candidate/order lifecycle evidence and censoring unresolved positions. Its purpose is diagnostic evaluation, not a backtest claim of profitability.

05 / STATUS & LIMITS

No profitability or realized execution result is asserted. Replay fills use explicit queue, latency, and fee assumptions; they cannot reconstruct routing priority, market impact, or settlement. A complete hedge on paper can still fail during execution.

Source notes

Based on repository code and project records reviewed on October 30, 2026. Historical checks are described as recorded, not rerun for this article. Screenshots, renders, and mockups are labeled individually.

  • trading-desk/README.md
  • trading-desk/config/desk.json
  • trading-desk/config/relationships.json
  • trading-desk/src/executor.ts
  • trading-desk/src/risk.ts
  • trading-desk/research/REPLAY.md
← All projectsNEXT PROJECTDebridFlix →