Skip to content

Repository files navigation

AlphaLab

Agent market simulator · auction theory lab · sports betting arbitrage scanner.

A market-microstructure research terminal that runs entirely in your browser. Three self-contained experiments — a continuous limit-order-book market driven by 100 heterogeneous rule-based agents, a Monte Carlo auction-theory lab, and a cross-bookmaker arbitrage scanner — with zero LLM calls and zero token spend. Every price, revenue and edge is computed locally from the mathematical models in src/lib/, which you can read end to end.

Screenshots

Landing — the three labs Market simulator — candles + fair value, order book, trades, events
landing market
Auction theory lab — Monte Carlo revenue comparison Arbitrage scanner — surebets & +EV
auctions arbitrage

The three labs

1. Agent-Based Market Simulator (/market)

100 agents — fundamentalists, chartists, noise traders and market makers — trade continuously on a price-time-priority limit order book (TICK_SIZE = 0.05).

  • Candlestick chart with a fundamental-value overlay
  • Live depth, spread, order flow, and regime detection
  • Four scenarios: Normal, Bubble & Burst, Fundamental Crash, and a Flash Crash (liquidity withdrawal → V-shaped recovery) that you can inject manually

The model blends Smith-style zero-intelligence mechanics with a Lux-style fundamentalist-vs-chartist interaction: chartists chase the EMA and create herding/overshoot, fundamentalists anchor on fair value and mean-revert, market makers supply liquidity that evaporates under stress. All randomness comes from a deterministic seeded PRNG (mulberry32), so every scenario is reproducible.

2. Auction Theory Lab (/auctions)

Compare the four canonical formats — English, Dutch, Vickrey (second-price sealed-bid), and first-price sealed-bid — under symmetric independent private values.

  • Thousands of Monte Carlo runs with risk-neutral or risk-averse bidders
  • Verify the Revenue Equivalence Theorem, then see why risk aversion favors the seller under first-price
  • Watch the winner's curse eat naive bidders — the reason eBay runs second-price proxy auctions
  • Live animated auction with per-bidder valuations

3. Sports Betting Arbitrage Scanner (/arbitrage)

Decimal odds from five sharp sportsbooks are normalized to implied probabilities and scanned for mispricing.

  • Surebet detection — back every outcome for a guaranteed return (arb % + ROI)
  • +EV scan — positive-expectation legs versus no-vig consensus fair lines
  • Kelly-style stake allocation with equal-payout splitting

Research / education only. Odds data is synthetic (static fixtures modeled on real market structure). The scanner never connects to a real bookmaker and never places wagers. Nothing on this site is investment advice.

Quick start

Requires Node 20+ and pnpm.

pnpm install

# development server on :5000
pnpm dev

# production build + bundled server (dist/server.js)
pnpm build
PORT=5000 pnpm start

Verification

The repo ships with headless test harnesses:

pnpm tsx scripts/validate-engines.ts   # engine math: order book, 4 scenarios, auctions, odds — 58 checks
pnpm tsx scripts/e2e-flows.ts          # user-flow replay: every button/slider/switch path — 39 checks
pnpm validate                          # eslint + tsc + stylelint

A full user-perspective test report is in USER_TEST_REPORT.md.

Project structure

src/
├── app/                     # Next.js App Router
│   ├── market/              # agent market simulator page
│   ├── auctions/            # auction theory lab page
│   └── arbitrage/           # arbitrage scanner page
├── components/
│   ├── market/              # agent-panel, order-book, price-chart, events-feed…
│   └── auctions/            # live-auction, revenue-chart
└── lib/
    ├── sim/                 # market-sim.ts (agents), order-book.ts (LOB), rng.ts
    ├── auctions/            # engine.ts (equilibrium bids, Monte Carlo)
    └── arb/                 # odds.ts (surebet/+EV), fixtures.ts
scripts/                     # build/dev/start + validation harnesses

Tech stack

Next.js 16 (App Router) · React 19 · TypeScript 5 (strict) · Tailwind CSS 4 · lightweight-charts 5 · zero runtime dependencies beyond React/Next.

License

Apache-2.0 — see LICENSE.

About

Agent-based market simulator, auction theory lab, and sports betting arbitrage scanner. Zero-LLM, all computation runs locally in the browser.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages