Inspiration

I am a Computer Science and Math major, and I'm trying to get into quantitative finance, so when I learned about a Database that allowed for real-time updates, I got ecstatic and immediately thought of real-time order books/trading games that could be created with this. However, a simple, static-looking trading game website is bland and overdone, so I wanted to add my own flavor and turn it into a 2D, pixel-art, retro-style video game that simulates open outcry trading, where you are a trader at the physical exchange placing orders. I leaned into the Ed Tech side since I am studying pedagogy, and one tool that can help students learn is gamifying topics and friendly competition. Central Limit Order Books and quantitative trading in particular can be incredibly intimidating for students. By wrapping these concepts in a game, I created an interactive learning tool. It transforms passive studying into a high-stakes, multiplayer simulation where a classroom can actively trade historical events, macroeconomic shocks, probability puzzles, etc.

What it does

Serious Trading is a 2D top-down multiplayer prediction market and open-outcry trading floor built for helping students learn about trading. Players walk 32x32 retro avatars across a floor with designated market pits. When a trader steps into a pit, pressing [E] pops open an arcade financial terminal. When a trade executes, speech bubbles float over the maker and taker across the room (e.g., "10 YES @ 65¢!"). I implemented a full Central Limit Order Book (CLOB) that strictly implements price-time priority. Additionally, students can compete against other peers, bots, and/or AI models (Claude Haiku 5.5 or Gemini 3.8 Flash). Hosts can spin up custom lobbies (with QR code onboarding), deploy markets onto floor coordinates, broadcast breaking-news ticker alerts, release asymmetric clues that shift fair market probabilities, and trigger the podium leaderboard reveal with confetti celebrations. But if a person wants to practice on their own, they can play in a solo private lobby where they have control over the market questions and can play against bots/AI Agents.

How I built it

  • Backend & Database (SpacetimeDB): We eliminated the traditional web/API server layer entirely (no Express, FastAPI, or Postgres). The entire exchange, player spatial coordinates, room routing, wallet accounting, and the order-matching engine are written in TypeScript running directly inside SpacetimeDB. All clients subscribe to relational database queries over WebSockets with sub-10ms atomic updates.
  • Game Engine (Phaser 4): Wrapped in React with an internal 640x360 canvas resolution, pixelArt: true, and strict grid movement.
  • Financial Terminal & Frontend (React TS and Tailwind CSS): arcade theme (chunky 4px borders, hard drop shadows, retro pixel fonts like Press Start 2P, and aggregated order-book volume ladders).
  • AI Whale Bot Engine: A standalone Node.js daemon using the Anthropic Claude API (claude-haiku-5-5 via zodOutputFormat) and the Google Gemini API (@google/genai via structured JSON schemas). Includes an automated fallback Gemini Ladder (gemini-3.8-flash down to 3.5-flash) and a local Bayesian Expected-Value (EV) sniper.
  • Production Deployment: Live on SpacetimeDB Maincloud at "serioustrading.ink" ## Challenges I ran into
  • Creating the graphics (I'm not an artist whatsoever). From assets and sprite sheets to actual implementation
  • Order book time priority and making sure that the correct orders are matched back to you. Making sure that your own orders shouldn't interact with each other, and implementing multiplayer ability.
  • Handling latency was also a big issue. The DB works a lot faster than the API calls themselves, so we need to make sure to stall when needed and prevent race conditions. ## Accomplishments that I'm proud of
  • Actually implementing the assets into the web app using Phaser.

- Toggling between Anthropic's Claude and Google's Gemini in real time, comparing how different frontier models interpret financial clues and quote spreads.

What I learned

  • How to use Phraser and SpacetimeDB architecture
  • Coding with AI Agents
  • How to enforce strict schemas with Zod and Gemini's JSON mode to turn qualitative news text into rigorous, quantitative trading actions.
  • Self-trade prevention ## What's next for Serious Trading
  • Fixes small bugs here and there that still exist
  • Having multiple Whale AIs in the lobby at once so AI Agents can also play against each other.
  • Nicer UI and adding music and SFX.
  • A Python/TypeScript SDK enabling students to code and deploy their own custom algorithmic trading bots onto the floor in automated class tournaments.

Built With

Share this project:

Updates

Submission history