Inspiration Ticket resale never made sense to me. Prices for the same seat can swing wildly in the hours before a game, but every platform just lets a seller set one fixed price and that's it. I wanted to try building it more like a real stock exchange instead, where buyers and sellers post live prices and the market matches them automatically.

What it does TicketX is a live order book for sports tickets. People (or in this demo, a bot generating fake orders) post bids and asks, the engine matches them the moment prices cross, and the dashboard shows the order book and trades updating in real time. There's also a small risk calculator that estimates how much you'd lose on your holdings if prices dropped a certain percent, and a trading bot that buys dips and sells spikes with its own starting cash, with a chart showing whether its strategy actually made money.

How I built it I started with the core trading logic first: order and trade objects, then a matching engine using two heaps for bids and asks. I wrote tests for it before building anything visual, just to make sure the actual trading logic was solid. After that I built a small generator that creates random fake orders so the market has something to react to, wired it all up behind a Flask backend, and built a simple dashboard on top with plain JavaScript and a chart for the bot's performance.

Challenges I ran into The imports were annoying at first. I'd written some of the code assuming it would run as part of a package, and it broke as soon as I tried running it through Flask. Also ran into a weird issue where Flask kept serving an old cached version of my HTML even after I edited it, until I realized debug mode needed to be on for it to notice file changes. And early on the order book didn't check what item an order was for, so it would happily match a ticket for one event against a completely different one, which I had to catch and fix before it made it into the demo.

What I learned Building and testing the trading logic first, before touching any of the UI, saved me a lot of time. Every bug after that was just wiring things together, not the actual matching logic being wrong.

What's next Supporting more than one ticket at a time, real user accounts instead of a hardcoded holding, saving state so it doesn't reset every time the server restarts, and maybe a smarter version of the trading bot.

Share this project:

Updates

Submission history