- Automated tests
- 204
- Stocks screened
- 300+
- Discord slash commands
- 9
Problem
Most trading bots try to predict where the price goes next, and most of them fail quietly: a backtest looks brilliant because the model saw tomorrow's data, then the live account bleeds. I wanted a bot whose first job is not to lose much, built so that every number it reports could be trusted, and I wanted the research and the account in the one place I already check every day: Discord.
Process
Two bots carry it into Discord, in a server called Regime Trade Insider. Every weekday at 22:00 UTC, after the US close, a GitHub Actions job scores about 320 stocks on two horizons (momentum, RSI, volume, distance from the 52-week high, trend and a one-year Sharpe ratio), pulls the latest headlines and hands the top ten of each screen to Claude. Claude returns the market overview, up to three picks per horizon with a thesis, an entry, the risks and a conviction, and what to avoid. The Trade Analyzer webhook posts it as a set of embeds in the #smart-analyzer channel.
The second bot, RTI trading monitor, is a discord.py slash-command bot that reads a Questrade account read-only and answers to its owner alone: a daily digest of profit and loss, cash and concentration, a note whenever a trade appears that was not in the plan, price alerts checked every fifteen minutes, and a weekly chart of the account against the S&P 500. It runs on a scheduler in Toronto time and ships as a Docker image.
Underneath sits the trader itself. It reads daily price bars and turns them into rolling features (returns, realized volatility, trend strength, momentum), each one computed only from the bars up to that day. A Gaussian hidden Markov model classifies the market's volatility environment as calm, moderate or turbulent. It does not predict direction. For every training window it tries between three and seven regimes with ten random restarts each, keeps the simplest one that explains the data (by the Bayesian information criterion), and waits three bars before believing a regime change.
The strategy layer turns the regime into an allocation: fully invested with a little leverage when the market is calm, more cautious when it is not, and still long but at 60% when it is turbulent. Then a separate risk manager gets the final word on every order: a stop on every position, 1% risk per trade, caps on exposure, leverage and correlated positions, and circuit breakers on the account's actual profit and loss.
Key Decisions
- Research informs, people decide: the brief and the monitor's signals are suggestions with a written reason, and neither can reach an order. Questrade's retail API cannot place orders, and the analyst's picks for stocks it was never sent are thrown away.
- Webhooks for reports, a bot for conversation: the one-way posts go through plain webhooks, so they keep arriving even when the bot is down, and the slash-command bot only answers its owner.
- The forward algorithm, never Viterbi: the usual "predict" call revises past regimes using future data, which makes backtests look better than reality. The bot only asks what was knowable at each day, and a test proves the estimate for a day is identical whether the model has seen 400 or 500 bars.
- Reduced but long, never short: shorting in turbulent markets was tested and destroyed returns, because a regime is only confirmed a few days late and sharp recoveries erase the gains. Staying 60% invested contains the drawdown and still catches the rebound.
- Circuit breakers on real losses, not on signals: trading slows at a 2% daily or 5% weekly loss, stops for the day at 3% and the week at 7%, and halts outright at 10% below the peak, writing a lock file that a person has to remove.
- Paper by default: going live takes two separate switches and a typed confirmation at startup.
Outcome
The research brief lands in Discord every weekday, and the monitor covers the account side of the same server: digests, trade notes, alerts and the weekly report, so the research, the account and the bots' own health are read in one place. The trader runs end to end against Alpaca's paper-trading account: it synced the account, placed its first orders in July 2026, and when a limit order did not fill it cancelled and retried at market with the audit trail intact. The walk-forward backtester trains on a year and tests on the next six months, window by window, and compares the result with buy and hold, a 200-day trend rule and 100 random traders. On the synthetic market from its test suite, where holding lost 24.5%, the bot lost 2.7% and kept its worst drawdown to 26.7% against 42.1%: the risk layer doing its job, not a claim about future returns.



