Skip to content
Nat Lee

Keyboard shortcuts

Turn these off if they get in the way of a screen reader or voice control. The setting is saved in this browser.

1
Home
2
Work
3
Projects
4
About
5
Experience
/
Search projects
?
Show this panel

Web Development

Stock Trading Simulator

Real-time Trading Simulation with Learning Center

A trading simulator with a price-time matching engine, bot traders and a live order book. You can lose money here without losing any money.

Role
Creator & Maintainer
Period
2026 – Present
Status
Active
Categories
Web apps & extensions
Stack
  • Next.js
  • React
  • TypeScript
  • Tailwind CSS
  • Lucide React
  • Canvas API
  • Vitest
  • Real-time Matching Engine
Stock Trading Simulator, screenshot 1

Overview

A stock trading simulator that runs entirely in the browser. A real matching engine with price-time priority sits in the middle, supporting market and limit orders with GTC, IOC and FOK conditions, and three bots (MarketMakerBot, TrendBot, NoiseBot) trade against each other and against you every 100 ms, so the price, the order book and the candles all come out of actual trades rather than a price formula. Twelve market scenarios retune the bots, from a calm, empty market to a pump and dump; each one is tuned with seeded runs so it does what its name says, and five of them hand over to the next by themselves. The integrated Learning Center offers 19 courses across 4 categories (Beginner, Intermediate, Advanced, Investment) with interactive quizzes and progress tracking. The Practice Center enables risk-free pattern recognition training and trading practice with rewind/replay. A rule-based analysis panel reads the live market: trend direction and strength, order book pressure, RSI-style momentum and candle patterns, each with a confidence score.

What it's good for

Useful for someone new to the Taiwan market: tick sizes, odd lots, the minimum fee and the day-trade tax follow local rules, and red means up unless you switch it. The pattern drills let you rewind a chart, which real markets have so far declined to offer.

How it fits together

Simplified on purpose. The real thing has more arrows and at least one config file nobody understands.

Pattern practice has a rewind button. Real markets still don't.

  1. Traders

    You
    Three bots
    • Tuned by 12 scenarios
    → orders
  2. This oneStonk! simulator
    • MatchingEngine + OrderBook
    • 100 ms MarketSimulation tick
    • CandleAggregator
    → fills
  3. Trading screen
    • Canvas candlestick chart
    • Order book, holdings

Point at a box to see what it connects to.

Trading screen: candlesticks with moving averages, the order book and market depth
Trading screen: candlesticks with moving averages, the order book and market depth

Features

  • Real-time order matching engine with price-time priority and partial fills
  • Multiple order types: Market, Limit with GTC/IOC/FOK conditions
  • Interactive candlestick charts with multiple timeframes (15s, 1m, 5m, 30m), moving averages and volume
  • Bot-driven market simulation (MarketMakerBot, TrendBot, NoiseBot) on a 100 ms tick
  • Twelve market scenarios, from Bull and Crash to Pump & dump and Dead cat bounce; five hand over to the next by themselves
  • Learning Center with 19 courses across 4 categories
  • Practice Center for 44 chart patterns: pattern quizzes and trading practice with rewind/replay
  • Rule-based market analysis: trend, order book pressure, momentum and candle patterns with confidence scores
  • Lot-by-lot long and short positions with P&L, commission and Taiwan's transaction tax
  • Taiwan Stock Exchange tick rules for realistic price steps
  • Color theme toggle: Asian (red=up) vs Western (green=up)
  • Whole-lot and odd-lot modes with configurable commission, minimum fee and tax rates

The problem

  • Implementing accurate price-time priority matching engine
  • Real-time order book updates and candlestick chart rendering
  • Coordinating multiple trading bots with realistic market behavior
  • Building comprehensive learning content with interactive elements
  • Pattern recognition algorithm development for chart analysis
  • Maintaining performance with high-frequency trading simulation
  • Making each market scenario actually behave like its name

What I did

  • Developed custom MatchingEngine with OrderBook implementing price-time priority
  • Built efficient CandleAggregator for real-time K-line generation
  • Created BotManager to coordinate bot activities on configurable tick intervals
  • Implemented modular architecture separating matching, trading, and UI logic
  • Designed comprehensive course structure with JSON-based content management
  • Built interactive Practice Center with rewind/replay functionality for learning
  • Tuned every scenario with seeded runs and a headless simulator (npm run sim) so bull rises, a crash falls and a pump and dump pumps first
Twelve scenarios, twenty seeded runs each; calm barely moves in any of them
Twelve scenarios, twenty seeded runs each; calm barely moves in any of them

Results

  • Successfully implemented real-time matching engine supporting multiple order types
  • Created realistic market simulation with three distinct bot behaviors
  • Built comprehensive learning platform with 19 structured courses
  • Developed interactive practice environment for trading skill development
  • Implemented real-time market analysis tools for trend and pattern detection
  • Achieved smooth performance with high-frequency order processing

What I learned

  • Without the market maker's inventory shift nothing pulled its position back: in pump-and-dump runs it peaked at 770 lots, against 99 with the shift on.
  • Each scenario name is a promise checked in CI with seeded runs: a crash must fall 8–15% in its own phase in every run, and calm must stay within 1%.
  • Some quirks stay on purpose: the noise bot's 3-lot maximum can never come up, but fixing it would change how the game feels, so it is written down instead.
  • Settings: pick a scenario, set the market intensity, the lot size and Taiwan fees
    Settings: pick a scenario, set the market intensity, the lot size and Taiwan fees
  • Learning Center: 19 courses and 185 units, from the basics to trading psychology
    Learning Center: 19 courses and 185 units, from the basics to trading psychology
  • A lesson on the island reversal, with a drawn candle example and its OHLC values
    A lesson on the island reversal, with a drawn candle example and its OHLC values
  • Trading practice on a tweezer bottom: replay the candles, then buy or short
    Trading practice on a tweezer bottom: replay the candles, then buy or short
  • Pattern quiz: 20 seconds to pick the right pattern from four choices
    Pattern quiz: 20 seconds to pick the right pattern from four choices
  • One tick: bots send orders, the engine matches them, the last fill becomes the price
    One tick: bots send orders, the engine matches them, the last fill becomes the price
  • How the price moves one step: the market maker's quotes follow the last trade
    How the price moves one step: the market maker's quotes follow the last trade
  • Web apps & extensions77 stars on GitHub

    Streaming Player

    Twitch, YouTube live chat and chat bots share one song queue. A Rust backend keeps the OBS player, overlay and moderator dashboard in sync.

    2023Completed
  • Web apps & extensions11 stars on GitHub

    Gantt Studio

    Drag a schedule into place, draw dependencies and see the critical path. Switch to Mermaid text without losing the plan. Everything stays in your browser.

    2026Completed
  • Web apps & extensions33 stars on GitHub

    MorphKit

    Converts and edits images, audio, video, PDFs and documents entirely in the browser. Nothing gets uploaded, mostly because there is nowhere to upload it to.

    2026Active