← Docs
🎓 Tutorial

Trade the regimes, step by step.

A 10-minute read covering everything you need to know before launching your first hosted bot.

1. What HMM Trade is (and isn't)

HMM Trade is a volatility-classification system, not a directional-prediction system. Instead of asking “will SPY go up tomorrow?” the bot asks “is the market currently calm, choppy, or panicking?” and sizes positions accordingly.

A Hidden Markov Model (HMM) reads short-window features (realized vol, ATR, ADX, RSI) and emits a regime label every bar — typically 0–4 distinct states. Each regime maps to a strategy: in calm regimes the bot leans into trends with moderate leverage, in chop it goes flat, in panic regimes it sometimes shorts.

It is NOT a get-rich-quick system, an alpha generator, or financial advice. It's a risk-management framework with strategies plugged in — the goal is to lose less in bad regimes, not to win more in good ones.

2. How the bot makes decisions

Every bar (1 minute by default), the bot runs:

  1. Features — compute realized vol, ATR, ADX, RSI, and a few macro proxies for each symbol.
  2. HMM forward pass — feed the features to the trained HMM, get back a regime label + a confidence score (the probability of the most-likely state).
  3. Routing — based on regime, pick which strategy fires (low-vol trend, high-vol mean-reversion, or stand-aside).
  4. Risk gates — strategy proposes a trade, risk manager checks every cap (max position, daily DD, exposure ceiling, daily-trade count). Any failed cap rejects the trade with a reason logged to the audit DB.
  5. Execution — broker order goes out; response (fill, partial, reject) recorded.

Step 4 is where most rejected trades come from. If a bot looks idle, check the risk glossary and the bot detail page's log tail — the rejection reason is always there.

3. Setting up paper trading

The cloud workflow takes about 3 minutes:

  1. Sign up at /signup with your email or Google.
  2. Upgrade to Pro on the pricing page (Stripe-hosted checkout — test cards welcome in dev).
  3. Get an Alpaca paper key pair from Alpaca's paper dashboard and connect it on /brokers — the form validates the keys against /v2/account before saving.
  4. Click “+ New bot” on the dashboard. The 6-step wizard walks you through naming, picking the connection, choosing a universe, picking a risk preset, toggling features, and reviewing.

At commit, the cloud spins up a Fly Machine running the regime-trader-bot container. It pulls the profile JSON from Supabase, mints a short-lived broker access token via KMS-decrypted creds, and starts trading. Watch the live tail on /bots/<id>.

4. Choosing a risk preset

The wizard's step 4 has three preset cards. They map to the same numbers we use for the project's default walk-forward backtests:

  • Conservative — 2.5% per position, 1.0× leverage (cash only), 2% daily drawdown halt. Use this for live money or anything you wouldn't lose sleep over losing.
  • Balanced (default) — 5% per position, 1.5× leverage, 4% daily DD halt. Mirrors settings.yaml's shipped defaults. Most paper testing should start here.
  • Aggressive — 10% per position, 2.0× leverage, 6% daily DD halt. Stress-tests the risk manager itself; not appropriate for live money.

The Advanced expander lets you tweak any of the six individual knobs. Editing one auto-flips the preset to “custom”.

5. Going live

Once a paper bot has run cleanly for at least a couple of full sessions, you can graduate to live by:

  1. Connecting an Alpaca live key pair on /brokers with a clear label (“Live $25k”, etc.).
  2. Creating a NEW bot via the wizard and selecting the live connection in step 2. The wizard's step 6 review will show a red live banner — confirm before clicking Create.
  3. Starting the live bot with the same settings that worked in paper. Don't increase risk caps in the same step.

Live trading uses real money. Every order is live the moment the Fly Machine boots. The platform doesn't know if your strategy works — it executes whatever the bot decides. You are the operator and you carry the risk; see the risk disclaimer.

6. Monitoring a running bot

The bot detail page (/bots/<id>) live-tails the Fly container's log + every audit event. Filter by kind (bar, order, fill, halt, error, log, warn) and the page polls every 5 seconds.

If you enabled email or webhook alerts on step 5, the bot will:

  • Send a fill alert per executed order
  • Send a halt alert when any circuit breaker fires
  • Send an error alert on uncaught exceptions

For richer visualization (per-regime returns, walk-forward attribution, options Greeks panels) install the local agent — paid users can run it side-by-side with hosted bots; both UIs read the same cloud bot list.

7. Common troubleshooting

  • Bot never trades — Check the audit log for rejection reasons. The most common: confidence below threshold, max_daily_trades hit, exposure cap full, market closed (stocks-only bots only fire during regular hours).
  • “PDT rule” rejection — Pattern Day Trader rule: under $25k equity in a margin account, you're limited to 3 day trades per 5-day window. Switch to a cash account or fund above $25k.
  • BROKER_NOT_CONNECTED — The connection this bot was pinned to was disconnected (or its label was deleted). Re-connect on /brokers and re-create the bot.
  • Bot crash-loops on Fly — Memory ceiling hit; the platform runs each bot at 1GB. If your custom universe is huge, switch to top-N mode.
  • HTTP 530 from cloud — During development with a Cloudflare quick tunnel, the URL is ephemeral. The production deploy lives on a stable domain.

8. Disclaimer

HMM Trade is research software. Backtest performance is not a guarantee of live results — slippage, regime drift, broker outages, and your own panic-stops can all destroy a strategy that looked great on historical data. Don't trade money you can't afford to lose. Read the full risk disclaimer before going live.