OrderFlow Buddy — Hackathon Submission

Inspiration

Prediction markets like Polymarket are theoretically efficient — but in practice, they're full of exploitable inefficiencies. Prices lag real information, orderbooks misprice correlated outcomes, and volume spikes go unnoticed by most participants. We wanted to build a system that operates like a quantitative analyst running 24/7: scanning every active market for edge, sizing positions rationally, and never acting on gut feeling. The inspiration was simple — bring systematic trading discipline to a market where most participants are still trading on instinct.

What it does

OrderFlow Buddy is a full-stack prediction market intelligence system built on top of Polymarket. It has four integrated modules:

  • Live Markets Dashboard — real-time feed of active Polymarket markets with probability bars, 24-hour volume, liquidity depth, and live orderbook data pulled directly from the CLOB API.
  • Signal Scanner — autonomous detection engine running four independent signal models (Probability Drift, Volume Spike, Mispricing, and Momentum) across all active markets simultaneously. Every signal includes a Kelly Criterion bet size recommendation.
  • Strategy & Risk Engine — configurable risk management layer with adjustable Kelly fraction, minimum edge threshold, confidence filters, and a live trade log with P&L tracking and an equity curve.
  • Backtesting Engine — historical simulation framework that runs three strategy models (Kelly Criterion, Fixed Fractional, Probability Drift) over 90-day scenarios and produces Sharpe ratio, annualized return, max drawdown, and a full equity curve.

Every number in the system is computed — there is no mock data in the signal or backtest output.

How we built it

We built a contract-first TypeScript monorepo using pnpm workspaces with two deployable artifacts:

  • Backend: Express 5 with four route modules (markets, signals, strategy, backtest). Core libraries handle Polymarket API integration (Gamma API for market data, CLOB API for orderbook depth), signal detection, portfolio metrics, and simulation.
  • Frontend: React + Vite with Wouter routing, TanStack Query for data fetching, Recharts for equity curves, and Framer Motion for animations. Styled with a dark terminal aesthetic using Tailwind CSS and shadcn/ui.
  • API contract: OpenAPI 3.1 spec as the source of truth, with codegen for the TypeScript client.
  • Deployment: Single Express process on Railway that serves both the REST API (/api/...) and the built React frontend as static files.

The signal engine was the most algorithmically interesting part — each of the four detectors uses a different market dimension (price deviation, volume ratios, probability sum, momentum regime) and feeds into a shared Kelly sizing function: f* = (p·b − q) / b, capped at the configured max fraction and scaled by confidence score.

Challenges we ran into

  • Polymarket API rate limits and CORS — the live Gamma API has restrictions that required a server-side proxy and a graceful fallback to realistic simulation data so the app remains functional during demos.
  • Express 5 breaking changes — Express 5 dropped support for bare wildcard routes ('*'). The catch-all SPA handler had to be updated to '/{*path}', which only surfaced as a crash in production.
  • Railway Nixpacks environment — the default Railway build environment used Node 18, which broke Vite 7 and Tailwind CSS v4 (both requiring Node 20+). Required adding a nixpacks.toml to explicitly pin the Node version.
  • Monorepo deployment — Railway detected all five workspace packages and tried to deploy each as a separate service. Only the API server needs to run, since it serves the built frontend as static files.
  • Kelly Criterion calibration — raw Kelly sizing on noisy market signals produces overbetting. Implementing confidence-scaled fractional Kelly and minimum edge thresholds required careful tuning to produce realistic bet sizes.

Accomplishments that we're proud of

  • Four independent signal models running in parallel, each detecting a different class of market inefficiency — and all producing real, computable edge estimates, not heuristic labels.
  • End-to-end backtesting that runs three strategies and produces a full set of quantitative performance metrics: Sharpe ratio, annualized return, max drawdown, win rate, and a per-trade equity curve.
  • Clean single-service production deployment at a custom Railway domain with zero Replit dependencies, no mock UI, and a polished landing page that explains the system to judges.
  • Contract-first API design — the OpenAPI spec was written before implementation, ensuring the frontend and backend stayed in sync throughout the build.

What we learned

  • Express 5 is a meaningful breaking change from Express 4, particularly around route parameter syntax. Testing only in development can hide production crashes.
  • Railway's Nixpacks auto-detection is powerful but opinionated — understanding how to override Node version, build command, and service isolation is essential for monorepo deployments.
  • Kelly Criterion is theoretically optimal but practically dangerous without confidence discounting. The difference between full Kelly and fractional Kelly on noisy signals is the difference between a useful tool and a bankroll-destroying one.
  • Polymarket's CLOB API gives genuine orderbook depth that most market participants ignore — the bid/ask spread and liquidity distribution often tells a more accurate story than the headline probability.

What's next for OrderFlow Buddy

  • Real trade execution — integrate with the Polymarket API's order submission endpoint so signals can be acted on automatically with configurable position limits.
  • Live P&L tracking — connect the trade log to a real wallet to track actual returns, not just simulated ones.
  • Additional signal models — news sentiment scoring using NLP on resolution criteria text, and cross-market correlation detection for related outcomes.
  • Alert system — push notifications when a high-confidence signal is detected above a configurable edge threshold.
  • Multi-user support — per-user strategy configs, trade histories, and performance dashboards with authentication.
  • Expanded backtesting — walk-forward optimization and Monte Carlo simulation to stress-test strategies against randomized market scenarios.

Built With

Share this project:

Updates