Automated Momentum Trading
QuantMyStocks publishes a weekly automated momentum strategy as open-source code you self-host on GitHub Actions (free), Docker, or your own cloud VM. The bot rebalances your Alpaca, Webull, or Tradier account into the S&P 500 / 400 / 600 / NASDAQ-100 momentum leaders every Monday morning. Your broker keys live in your own GitHub secrets, never on QMS servers.
How it works
- Rank. Every Sunday the QMS pipeline scores every constituent in each US index by risk-adjusted relative strength and publishes a leaderboard API.
- Trigger. Monday 09:30 ET, GitHub Actions inside your forked repo fires the rebalance workflow.
- Diff. The bot fetches the leaderboard with your QMS API token, reads your current broker holdings with your broker API key, and computes the trades needed to match the top-N.
- Trade. Stocks no longer in the top-N are sold; new entries are bought; existing holdings are kept. Capital is allocated equal-weight across the target positions.
- Report. An email (SMTP / SendGrid / AWS SES) summarises the trades, new holdings, and resulting cash position.
Broker support
- Alpaca — recommended. Commission-free US equities, robust API, free paper-trading environment. See our Alpaca setup page.
- Webull — commission-free, options if you opt in, OpenAPI via the Webull SDK.
- Tradier — REST API, supports running multiple portfolio sub-accounts (one per index universe) with independent capital tracking.
The strategy
Cross-sectional momentum: rank stocks within the index universe by risk-adjusted multi-window return, then hold the top-N for a week. This is the classic factor described in Jegadeesh & Titman (1993) and packaged operationally by Asness, Moskowitz & Pedersen (2013). See our methodology page for the full computation.
Frequently asked questions
What is automated momentum trading?
Automated momentum trading is the practice of mechanically buying the strongest-performing stocks in a defined universe and rotating into the next strongest names on a fixed schedule. A bot reads a leaderboard ranked by relative strength, compares it to current holdings, and places the trades needed to bring the portfolio into alignment — with no human discretion between signal and order.
Which brokers does QuantMyStocks support?
The QMS trading bot supports Alpaca (commission-free US equities + paper trading), Webull (commission-free, API via Webull SDK), and Tradier (REST API + per-portfolio sub-account routing). You pick the broker, capital allocation, and which index universes (S&P 500 / 400 / 600 / NASDAQ-100) the bot tracks — multiple indices can run simultaneously with independent capital.
How often does the bot trade?
Once per week. The rebalance runs Monday 09:30–10:00 ET, after the Sunday momentum leaderboard refresh and right after the US market opens. A weekly cadence matches the standard cross-sectional momentum implementation and avoids overtrading the noise inside a week.
Where do my broker API keys live? Does QuantMyStocks store them?
No. The trading bot is open-source and you self-host it on your own GitHub Actions (recommended, free), Docker, or cloud VM. Your broker API keys live in your fork's GitHub Actions secrets or your local .env — never on QMS servers. QMS only hosts the momentum-leaderboard API the bot calls; the broker connection is between your deployment and your broker.
Can I paper-trade before risking real capital?
Yes — Alpaca offers a free paper-trading endpoint that the QMS bot supports out of the box. Set ALPACA_BASE_URL=https://paper-api.alpaca.markets in your fork's secrets and use a paper API key. Watch a few weekly cycles, then swap to live secrets when ready.
Is automated momentum trading risky?
The technical risk is low — modern broker APIs are stable, and a momentum rebalance is a small state machine running in your own GitHub Actions. The investment risk is the same as any momentum strategy: significant drawdowns at sentiment turning points (the "momentum crash" phenomenon), tracking error vs the broader market, and the behavioural risk of turning the bot off after losses. Past backtested performance does not guarantee future results.