Welcome To Stockfighter

A free programming challenge. Write code to trade on a simulated stock exchange. Solve levels, beat bots, learn how markets work.

Sign Up

Sign In

Your API key (save this — you'll need it for every request):

Open Dashboard →

What is Stockfighter?

Stockfighter gives you access to an electronic trading market that mimics real-world exchanges. You write code to solve a series of challenges in that market. Software engineering, distributed systems, and automated trading are the themes — but you don't need to know any of that to start.

Trading Levels

15 puzzle levels from "buy 100 shares" to portfolio management with adversarial bots and dark pools. Plus a 50-stock open market for free trading.

Real Matching Engine

Price/time priority orderbook. Limit, market, FOK, IOC orders. WebSocket feeds for quotes and fills.

Bot Traders

Market makers, noise traders, snipers, trend followers, front runners, whales, and spoofers.

  • Learn how markets work — orderbooks, spreads, fills, and market impact become concrete when your code trades against bots that fight back.
  • Practice real engineering — WebSocket streaming, rate limiting, concurrent state, unreliable networks. The later levels are distributed systems problems.
  • Use your own tools — no browser IDE, no sandbox language. Write solutions in whatever you want.
  • Free and open source — run the server locally or use the hosted instance. Read the source. Modify the levels. Add your own bots.

Any Language, Just HTTP

If you can make an HTTP request, you can play.

FAQ

Levels

Start a level with POST /ob/api/levels/:id. Solo levels give you a private venue. PvP and market levels share a venue across all players.

Connect to a server to load levels.

API Documentation

The full interactive docs are served by the Stockfighter server. Open full API docs →

Quick Reference

WebSocket Feeds

Authentication

Pass your API key in the X-Stockfighter-Authorization) header.

curl -H "X-Stockfighter-Authorization: YOUR_API_KEY" https://play.stockfightergame.com/ob/api/venues/TESTEX/stocks

Walkthrough: First Steps

Level 1 asks you to buy 100 shares of FOOBAR on the TESTEX exchange. Here's how to solve it from scratch.

1. Register & get your API key

2. Start the level

curl -X POST https://play.stockfightergame.com/ob/api/levels/first_steps \
  -H "X-Starfighter-Authorization: YOUR_API_KEY"

# Response includes: venue, account, stocks, instructions

The response tells you which venue and account to use. Bots start trading immediately.

3. Check the quote

curl https://play.stockfightergame.com/ob/api/venues/TESTEX/stocks/FOOBAR/quote

# Shows bid, ask, last price, depth

Look at the ask price — that's what sellers are offering. You'll buy at or near this price.

4. Place a buy order

curl -X POST https://play.stockfightergame.com/ob/api/venues/TESTEX/stocks/FOOBAR/orders \
  -H "X-Starfighter-Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "account": "YOURNAME",
    "venue": "TESTEX",
    "symbol": "FOOBAR",
    "price": 5100,
    "qty": 100,
    "direction": "buy",
    "orderType": "limit"
  }'

Prices are in cents — 5100 = $51.00. Set your price at or above the ask to fill immediately. You'll pay the ask price, not your limit.

5. Check level status

curl https://play.stockfightergame.com/ob/api/levels/first_steps \
  -H "X-Starfighter-Authorization: YOUR_API_KEY"

# When status is "won", you've completed the level!

Tips

  • Use market orderType to buy at whatever price is available (no price needed)
  • Use the WebSocket feed to watch fills in real time instead of polling
  • The dashboard at https://play.stockfightergame.com/ shows live orderbook and position
  • For level 2 (Chock a Block), you need to buy 10,000 shares without moving the price too much — split into smaller orders