Skip to content

IDEXAONE/orb-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ORB Intraday Bot — Alpaca

Long-only Opening Range Breakout bot for SPY, QQQ, and IWM. Built with Python and the Alpaca trading API.

Independent · MIT licensed · Educational use


What it does

This bot trades the classic Opening Range Breakout strategy on three liquid U.S. index ETFs.

  1. 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."
  2. 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.
  3. Bracket order on entry:
    • Stop loss at the opening range low
    • Take profit at entry + 2.0 × range height
  4. 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.


Verified backtest

Run on May 1, 2026 using Alpaca's 1-minute historical bar data.

2-year window (2024-05-01 → 2026-05-01)

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

1-year window (2025-05-01 → 2026-05-01)

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

Honest verdict

  • 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.


Setup

Requirements

  • 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)

Installation

git clone https://github.com/IDEXAONE/orb-bot.git
cd orb-bot
pip install -r requirements.txt

Environment variables

Set 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"

Run

python orb_bot.py

The bot will print its status every 2 minutes during market hours and stay idle outside them.


Deploying to Railway

If you want the bot to run 24/7 instead of relying on your laptop:

  1. Push this repo (or your fork) to GitHub
  2. Create a new service on Railway from the GitHub repo
  3. Set environment variables in Railway:
    • ALPACA_API_KEY — your paper key
    • ALPACA_SECRET_KEY — your paper secret
  4. Set the start command to: python orb_bot.py
  5. Deploy — Railway handles the rest

Free tier covers ~500 hours/month, which is more than enough for one bot.


Configuration

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 max

Watchlist

Three 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.


Disclaimer

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.

License

MIT — free to use, modify, and redistribute. If you build something cool with it, a link back is appreciated but not required.


More from IDEXA

This is part of IDEXA — The Trading Bot Index, an independent, unaffiliated index of automated trading bots with honest ratings and verified backtests.

About

An Opening Range Breakout strategy bot that watches the first 60 minutes of market open, calculates the high/low range, then buys if price breaks above it with volume confirmation. Proven intraday strategy used by professional traders. Requires discipline — best suited for those comfortable with Python and Alpaca.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages