Market Wizard – Market Making Bot

McHacks 13


Inspiration

Trading strategies often fail not because prices move unpredictably, but because market conditions change faster than the strategy can react. Most systems respond after volatility spikes or liquidity vanishes.

We wanted to build a system that understands how the market is behaving at a microstructure level, so trading strategies can adapt before instability causes losses.


What it does

Market Wizard is a real-time market regime detection and adaptive trading system that analyzes high-frequency bid/ask microstructure to classify hidden market states such as:

  • Normal market
  • Stressed market
  • HFT-dominated market
  • Flash and mini-flash events

Each detected regime activates a specialized trading algorithm designed for that specific market structure. The system also includes dynamic inventory management, which continuously monitors exposure and offloads inventory when position thresholds are exceeded. This keeps risk low, maintains compliance with competition rules, and limits vulnerability to flash crashes.

As a result, Market Wizard achieved positive PnL in all tested market regimes except the large flash crash scenario, where extreme discontinuities overwhelm any market-making strategy.


How we built it

We approached the simulator as a market to be studied, not a black box.

  • Streamed live bid/ask market data in real time
  • Logged and visualized raw microstructure data to understand regime behavior
  • Engineered relative microstructure features (spread, volatility, velocity, shocks)
  • Trained an XGBoost classifier on self-collected data to detect market regimes
  • Built specialized trading algorithms that activate only when their matching regime is detected
  • Implemented dynamic inventory controls using exposure thresholds and smart offloading logic to rapidly reduce risk when positions grew too large
  • Created visualization tools to inspect regime structure, feature importance, and model decisions

Our regime classifiers achieved 100% accuracy on held-out regime data prior to deployment, demonstrating that each market state has a distinct microstructure signature.


Challenges we ran into

  • Raw prices were misleading: In some scenarios prices barely moved, even while liquidity and spread dynamics changed dramatically.
  • Server-side zero-value data: We observed frequent periods where bid, ask, and mid prices were returned as zero specifically when pulling data from the server. These segments appeared to be either intentional obstacles or artifacts of the simulator’s data pipeline. We intentionally did not drop these rows, since identical behavior appeared during live runs and had to be handled safely in real time.
  • Simulator microstructure flaws:

    • Flat bid/ask prices in “normal” markets
    • Bots operating on rigid $0.25 price grids
    • Occasional pure arbitrage opportunities caused by synthetic behavior

Managing risk under these conditions required strict inventory limits, aggressive order cancellation, and fast offloading logic to avoid excessive exposure during sudden regime shifts.


Accomplishments that we're proud of

  • Built a real-time market regime classifier with near-perfect accuracy
  • Achieved positive PnL in every market regime except the large flash crash, validating our regime-adaptive strategy design
  • Maintained consistently low inventory exposure through dynamic offloading and threshold-based risk controls
  • Designed efficient, competition-compliant trading logic that respects order limits and execution rules
  • Designed explainable microstructure features similar to those used by professional quantitative trading firms
  • Developed specialized trading algorithms tailored to each detected regime
  • Discovered and documented critical simulator flaws affecting market realism
  • Built a complete data logging and visualization pipeline for interpretability and debugging

What we learned

We learned that understanding market structure matters more than predicting prices.

Successful trading systems must adapt to regime changes before losses occur, not after. Feature engineering, data integrity, interpretability, and risk and inventory controls proved far more important than raw model complexity.

We also learned how real-world trading systems must function in noisy, imperfect, and sometimes broken markets.


What's next for Market Wizard

  • Add trading commission fees and more realistic execution modeling
  • Train the regime classifier on larger and more diverse datasets
  • Expand regime coverage with additional edge cases
  • Improve handling of simulator artifacts and server-side data issues
  • Further refine inventory controls for extreme market dislocations
  • Ultimately, explore deployment on live market data

Contributors

Dan Moraru Carter Cameron Samuel Beaudoin Shuya Liu

Built With

Share this project:

Updates