Inspiration

We took inspiration from biological adaptability. We wanted to build a system that acts like a seasoned trader: aggressive when conditions are clear, passive when uncertainty rises, and purely defensive when the market breaks.

What it does

Our bot functions as an autonomous Regime-Based Strategy Router that operates on a high-frequency loop:

  1. Diagnoses: It calculates real-time metrics (velocity, imbalance, spread ratios) to classify the market into one of 6 regimes (e.g., NORMAL, STRESSED, CRASH).
  2. Routes: It dynamically switches between specialist agents. It runs an Aggressive Market Maker in calm markets, a Mean Reversion sniper for statistical anomalies, and a Passive strategy during high volatility.
  3. Survives: In extreme events, a Crash Protocol overrides all logic to aggressively flatten inventory and preserve capital.

How we built it

The system is built in Python with a modular architecture separating signal detection from execution.

  • The Brain: The RegimeClassifier uses compound signal detection (e.g., Spread Ratio > 2.0 + High Velocity) to prevent false positives.
  • The Math: We implemented Inventory Skew (adjusting quotes by -0.0002 * inventory) to naturally unwind positions and Z-Score analysis to identify entry/exit points for mean reversion.
  • The Safety: A global Risk Overlay acts as a final gatekeeper, intercepting every order to enforce hard inventory limits (4,500 shares) regardless of the active strategy.

Challenges we ran into

Signal Noise vs. Lag: Tuning the classifier was difficult. If it was too sensitive, the bot flickered between strategies; too slow, and we reacted to crashes after the damage was done. We solved this by requiring multiple concurrent weak signals to confirm a regime change.

The "Falling Knife": Early versions of our Mean Reversion strategy tried to "buy the dip" during crashes. We fixed this by implementing a strict hierarchy where the CRASH regime overrides all profit-seeking logic.

Accomplishments that we're proud of

The Architecture: We successfully implemented a state machine that switches strategies in sub-second time without dropping orders or losing state.

Zero-Loss Survival: We are most proud of the crash_survival.py module. Watching it kick in during a simulated flash crash to dump inventory—while competitors kept buying—was a definitive validation of our "Survival First" philosophy.

What we learned

Microstructure is King: We learned that order book depth and imbalance are often faster predictors of price movement than the price itself.

Survival > Profit: The biggest lesson was that long-term victory isn't about winning every trade; it's about avoiding the one trade that wipes you out.

What's next for Three Bayesians

ML Integration: We plan to replace hard-coded thresholds with lightweight Machine Learning models to detect market regimes dynamically.

Built With

Share this project:

Updates