Alpaca Momentum Bot
QuantMyStocks publishes an open-source Alpaca momentum bot you self-host on GitHub Actions for free. Fork the repo, paste your Alpaca API key and a QuantMyStocks leaderboard token into your own GitHub secrets, and the bot rebalances your Alpaca account into the top momentum names every Monday morning. Your broker credentials never leave your GitHub.
Setup in 4 steps
- Generate API keys. Get an Alpaca API key + secret from your Alpaca dashboard (paper trading first, recommended), and a leaderboard API token from QuantMyStocks.
- Fork the bot repo. github.com/quantmystocks/qms-trading-bot — one click to create your own copy.
- Add secrets to your fork. In your fork’s Settings → Secrets and variables → Actions, paste
ALPACA_API_KEY,ALPACA_API_SECRET, andLEADERBOARD_API_TOKEN. Add the index universe and capital as variables. They never leave your repo. - Enable the workflow. Actions tab → "Trading Bot Rebalancing" → Run workflow. From then on it runs free every Monday on GitHub Actions and emails you a summary of the trades.
What you get
- Weekly momentum-driven rebalance across your chosen US index universe.
- Paper-trading mode (Alpaca’s free simulator) for risk-free testing — just point ALPACA_BASE_URL at the paper endpoint.
- Per-run email summary: trades placed, new holdings, cash position.
- Read-only access to the underlying leaderboard so you can sanity-check what the bot will do before it does it.
- Your secrets stay in your GitHub. QMS never sees your Alpaca keys.
The momentum strategy
Cross-sectional momentum: rank the index constituents by risk-adjusted multi-window return, hold the top-N for a week, rotate weekly. Full computation on the methodology page. Other brokers: Webull and Tradier setup.
Frequently asked questions
What is an Alpaca momentum bot?
An Alpaca momentum bot is an automated trading program that connects to your Alpaca brokerage account via API, ranks US stocks by momentum (recent risk-adjusted return), and rotates your positions into the top-ranked names on a fixed schedule. The QuantMyStocks Alpaca bot does this weekly against the S&P 500, 400, 600, or NASDAQ-100 universe.
Do I need to write any code to use this?
No Python. The bot is an open-source repository (qms-trading-bot) you fork on GitHub, and the strategy is already implemented inside. Configuration is environment variables: your Alpaca API key + secret, the index universe, the capital allocation, and a leaderboard API token from QuantMyStocks. You paste those into your fork's GitHub Actions secrets, enable the workflow, and the bot runs weekly on GitHub Actions for free.
Where do my Alpaca API keys live?
In your own GitHub repository's Actions secrets — not on QuantMyStocks servers. The bot runs on GitHub Actions inside your forked repo and reads the secrets there at execution time. QMS only hosts the public leaderboard API the bot calls; the broker connection is entirely between your fork and Alpaca.
Can I use Alpaca paper trading to test before going live?
Yes — paper trading is the recommended way to start. Generate a paper-trading API key in Alpaca's paper-trading dashboard, store it in your fork's ALPACA_API_KEY/SECRET secrets, and set ALPACA_BASE_URL=https://paper-api.alpaca.markets. Watch a few weekly cycles execute against simulated capital, then swap the secrets for live keys when ready.
What does it cost to run?
GitHub Actions covers the weekly compute on its free tier. Alpaca charges zero commissions on US equity trades, so the only broker-side cost is regulatory pass-through fees (TAF, SEC). Most weekly rebalances cost under one US dollar in fees on a typical retail-sized account. Paper trading is free end-to-end.
How does this compare to writing my own Alpaca bot?
A custom Alpaca bot in Python gives you full control but requires you to implement and maintain the ranking pipeline, handle scheduling and error recovery, keep up with API changes, and backtest before going live. QMS publishes the same kind of bot open-source: the strategy is pre-built and tested, the GitHub Actions workflow is included, and the leaderboard API is hosted for you. You still own the deployment (it runs in your fork) — you just don't own the strategy code.
Is this the same as Alpaca's built-in algorithmic trading?
No. Alpaca itself provides the brokerage and the API — it does not provide a strategy. QuantMyStocks publishes the strategy and the bot that runs on top of Alpaca's API. You self-host the bot (free, via GitHub Actions on your fork); Alpaca handles order execution and custody.