Long-only Opening Range Breakout bot for SPY, QQQ, and IWM. Built with Python and the Alpaca trading API.
Independent · MIT licensed · Educational use
This bot trades the classic Opening Range Breakout strategy on three liquid U.S. index ETFs.
- 9:30–9:45 AM ET — records the high and low of each ETF over the first 15 minutes of trading. This is the "opening range."
- 9:45–11:30 AM ET — watches each ETF for a price breakout above its opening range high. When one breaks out, the bot enters a long position.
- Bracket order on entry:
- Stop loss at the opening range low
- Take profit at entry + 2.0 × range height
- 3:55 PM ET — force-closes any positions opened today. Never holds overnight.
Maximum 3 trades per day (one per symbol), no shorts, no leverage beyond Alpaca's default margin.
Run on May 1, 2026 using Alpaca's 1-minute historical bar data.
| Metric | Value |
|---|---|
| Total trades | 1,462 |
| Win rate | 44.32% |
| Total return | +10.99% |
| Sharpe ratio | 1.29 |
| Max drawdown | -2.54% |
| Profit factor | 1.18 |
| Metric | Value |
|---|---|
| Total trades | 734 |
| Win rate | 42.78% |
| Total return | +2.78% |
| Sharpe ratio | 0.74 |
| Max drawdown | -2.74% |
| Profit factor | 1.09 |
- 2-year results are solid for an intraday strategy on indices: +11% with a 1.29 Sharpe and just -2.54% max drawdown is a clean, low-volatility return profile.
- The 1-year results are markedly weaker than the 2-year — the strategy performed much better in 2024 than 2025. This may indicate the edge is degrading as the strategy gets more crowded, or it may be normal year-to-year variance.
- Long-only because the backtest showed shorts were a wash over 2 years and a net loser in the most recent year. We removed them.
- ORB is a well-known strategy with decades of academic and practitioner research. This is a vanilla implementation, not a proprietary edge.
Read the full review at idexa.one.
- Python 3.11 (3.14 has known issues with pandas/numpy wheels — avoid)
- An Alpaca account (sign up free)
- Paper trading API keys (live keys at your own risk)
git clone https://github.com/IDEXAONE/orb-bot.git
cd orb-bot
pip install -r requirements.txtSet your Alpaca paper trading keys as environment variables. Do not put them in the code.
macOS/Linux:
export ALPACA_API_KEY="your_paper_api_key"
export ALPACA_SECRET_KEY="your_paper_secret_key"Windows PowerShell:
$env:ALPACA_API_KEY="your_paper_api_key"
$env:ALPACA_SECRET_KEY="your_paper_secret_key"python orb_bot.pyThe bot will print its status every 2 minutes during market hours and stay idle outside them.
If you want the bot to run 24/7 instead of relying on your laptop:
- Push this repo (or your fork) to GitHub
- Create a new service on Railway from the GitHub repo
- Set environment variables in Railway:
ALPACA_API_KEY— your paper keyALPACA_SECRET_KEY— your paper secret
- Set the start command to:
python orb_bot.py - Deploy — Railway handles the rest
Free tier covers ~500 hours/month, which is more than enough for one bot.
Strategy parameters are at the top of orb_bot.py:
RANGE_MINUTES = 15 # 9:30-9:45 ET defines the opening range
TRADE_END_HOUR = 11 # stop entering new trades at 11:30 ET
TRADE_END_MIN = 30
FORCE_FLAT_HOUR = 15 # 3:55 PM ET — close any open positions
FORCE_FLAT_MIN = 55
TAKE_PROFIT_MULT = 2.0 # target = 2.0x range height
AMOUNT_PER_TRADE = 19759.0 # fixed budget per trade
MAX_TRADES_PER_DAY = 3 # one per symbol maxThree ETFs by default: SPY, QQQ, IWM. You can edit WATCHLIST to add or remove symbols. The strategy works best on liquid, high-volume names with tight bid-ask spreads — large-cap stocks (AAPL, MSFT, NVDA) work but have more noise than indices.
This software is provided for educational and research purposes only.
- This is not financial advice. Trading involves substantial risk of loss.
- Past backtest performance does not guarantee future results. Markets change, strategies degrade, edges disappear.
- Run on paper trading first. Paper-trade for at least 30 days before considering real capital.
- The author is not responsible for any losses incurred from using this bot. You assume full responsibility for any trades placed.
- The PDT (pattern day trader) rule was eliminated by the SEC in April 2026, but consult Alpaca's current docs for any restrictions on your account type.
MIT — free to use, modify, and redistribute. If you build something cool with it, a link back is appreciated but not required.
This is part of IDEXA — The Trading Bot Index, an independent, unaffiliated index of automated trading bots with honest ratings and verified backtests.
- IDEXA review of this bot — strategy, verdict, comparison
- Other bot reviews — stock bots, crypto bots, DIY and commercial