Opening Range Breakout (ORB) strategy for NSE equities using Upstox API.
Implements the ORB strategy based on academic research, achieving 41.6% annual returns with Sharpe ratio of 2.81 on U.S. equities (2016-2023).
- Pre-Market Screening: Filter stocks by price > ₹5, volume ≥ 1M shares, ATR > ₹0.50
- Opening Range: Track first 5-minute candle (9:15-9:20 AM IST)
- Stock Selection: Filter by relative volume ≥ 100%, select top 20 stocks
- Entry: Breakout above/below opening range with 1% risk sizing
- Stop Loss: 10% of 14-day ATR
- Exit: Close all positions at 3:25-3:30 PM
- Relative Volume Filter: Critical for identifying "Stocks in Play" with institutional activity
- Opening Range Direction: Predicts intraday trend continuation
- Risk Management: ATR-based stops and position sizing
- Research-based ORB strategy implementation
- Upstox V3 API integration with rate limiting
- Arrow columnar storage + DuckDB analytics
- Backtest, paper, and live trading modes
- Risk management with position sizing and stops
- Deterministic backtesting with fixed seeds
- SQLite manifest for instrument metadata
- Parallel data fetching with gap detection
- Java 17+
- Maven 3.8+
- Upstox trading account
git clone <repository>
cd hummingbird
mvn clean packageexport UPSTOX_API_KEY="your_key"
export UPSTOX_API_SECRET="your_secret"
java -jar target/hummingbird-trading-1.0.0-SNAPSHOT.jar auth
export UPSTOX_ACCESS_TOKEN="token_from_auth"java -jar target/hummingbird-trading-1.0.0-SNAPSHOT.jar download-instrumentsjava -jar target/hummingbird-trading-1.0.0-SNAPSHOT.jar fetch \
--from 2025-01-01 --to 2025-01-31 \
--interval 1 --unit minutesjava -jar target/hummingbird-trading-1.0.0-SNAPSHOT.jar backtest \
--from 2025-01-01 --to 2025-01-31java -jar target/hummingbird-trading-1.0.0-SNAPSHOT.jar paperjava -jar target/hummingbird-trading-1.0.0-SNAPSHOT.jar live --confirmEdit config.yaml or use CLI options:
| Parameter | Description | Default |
|---|---|---|
min_relative_volume_pct |
Minimum relative volume | 100% |
max_positions |
Maximum positions | 20 |
stop_loss_atr_pct |
Stop loss % of ATR | 10% |
risk_per_trade_pct |
Risk per trade | 1% |
fetch.rate_limit_per_sec |
API rate limit | 3.0 |
fetch.parallelism |
Parallel fetch threads | 8 |
initial_capital |
Starting capital | ₹10L |
atr_period |
ATR calculation period | 14 |
- Data Layer: Upstox API client, Arrow storage, SQLite manifest
- Strategy Engine: ORB with relative volume filtering and ATR stops
- Execution: Simulated/Paper/Live routers with realistic costs
- Risk Management: Position sizing, ATR stops, circuit breakers
- Download NSE instruments and metadata
- Fetch historical 1-minute bars for analysis
- Pre-market: Calculate ATR and volume statistics
- Intraday: Monitor opening range and execute breakouts
- Risk management: ATR-based stops and position sizing
Based on "A Profitable Day Trading Strategy For The U.S. Equity Market" (Zarattini et al., 2024).
Key findings:
- Basic ORB: 3.2% annual return
- With relative volume filter: 41.6% annual return (12x improvement)
- Sharpe ratio: 2.81, Max drawdown: 12%, Beta: 0.00
Trading involves substantial risk of loss. Past performance does not guarantee future results. Test thoroughly in paper mode before live trading. Ensure compliance with regulations.