An intraday opening-range strategy on the Nasdaq-100 CFD (NAS100_USD), run as a paper-trading bot on OANDA's practice API. Each session is posted to X. The repository also holds a pre-registered, reproducible research log that tests whether the strategy still works and how to improve it.
Status (Nov 2026): the original rule (v1) was profitable in 2020–2024 backtests. Since 2025 its edge is about zero after costs, and it loses in 2026. A pre-registered test of published full-session designs (step 12) selected a noise-area intraday momentum strategy. It is the only candidate that also held up on the untouched 2025–26 holdout, so it is the candidate for forward paper trading. See
research/.
| Item | Rule |
|---|---|
| Opening range (OR) | High and low of 09:30–10:00 New York time, inclusive |
| Signal | When the 10:22 one-minute candle completes, close in the top 35% of the OR → long, bottom 35% → short, middle 30% → no trade |
| Entry | Next minute's open (10:23) |
| Stop / target | 25 points / 75 points, attached at the broker |
| Size | 80 units (about $80 per point) |
| Forced exit | 12:00 New York |
Config: config/strategy.yml for the signal and risk, config/instruments.yml for the market and session times.
The candidate selected in step 12, implemented in opening_range_bot/strategy_v2.py. The live decision function is the research engine itself, and a parity test checks this.
| Item | Rule |
|---|---|
| Noise area | For each minute, σ = the average absolute move from the 09:30 open over the last 14 sessions. Upper band = max(open, previous close)·(1+σ); lower band = min(open, previous close)·(1−σ) |
| Checks | 10:00, 10:30, …, 15:30 New York |
| Entry | Long above the upper band, short below the lower band |
| Exit | A long exits below max(upper band, VWAP) and reverses below the lower band; shorts mirror this. Flat at 16:00 |
| Size | Exposure = min(4, 2% / 14-day daily volatility) × account NAV. A broker-side disaster stop sits 3% away |
| Runtime | One short Cloud Run job per check (stateless: the tagged OANDA position is the state). One X recap per day at about 16:01, comparing v2 (real paper) with v1 and a 5-min ORB (simulated) |
Deploy with scripts/deploy_strategy_v2.sh. This pauses v1's scheduler.
All figures are in R (1R = the $2,000 risked per trade), with bid/ask fills, on 1,280 OANDA sessions in 2020–2024 plus 445 out-of-sample sessions in 2025–2026.
-
Sequential take-profit does not help. Scaling out at 1R/2R/3R or moving to breakeven cuts the 2020–2024 result by 25–55% and does not reduce drawdown. The profit comes from a few large trend days (the top 10% of trades make 2.2× the total). (step 9)
-
The 25-point stop has become too tight. NAS100 has roughly tripled since 2020, so 25 points went from 0.24% to 0.09% of price, and stop-outs rose to 78% in 2026. A stop scaled to the price (0.192%, target 3×, constant dollar risk) is better in- and out-of-sample, but it only brings 2025–26 back to about flat.
-
The entry signal has lost its edge. None of eight pre-registered entry variants beats the 10:22 signal (other times, trend/width/momentum filters, breakout-only, fade). (step 10)
-
A full-session momentum design does better. The noise-area strategy enters when price leaves a band of "normal" intraday movement, trails a band/VWAP stop and is flat at 16:00. It returned +110% in 2020–24 (Sharpe 1.17) and +9.7% on the 2025–26 holdout (Sharpe 0.40), while the v1 rule lost. (step 12)
-
This matches independent evidence. Replications find plain opening-range breakouts on Nasdaq are about zero net of CFD costs since ~2021. The best-documented intraday edge is momentum held to the close, conditioned on volatility and dealer gamma. (step 11, literature review)
Full log, methodology and next steps: research/README.md. Version history: CHANGELOG.md.
Create a .env (ignored by Git) from .env.example and fill in your broker creds:
cp .env.example .env
Variables:
OANDA_ACCOUNT_ID— your OANDA account ID (use practice for paper).OANDA_API_TOKEN— API token for the account. (Note: If you create a new sub-account, you must regenerate this token in the OANDA Hub).OANDA_ENV—practiceorlive(start withpractice).OANDA_INSTRUMENT— instrument symbol (e.g.,NAS100_USD).OANDA_TIMEZONE— assumed local session timezone (defaultAmerica/New_York).- X/Twitter posting (optional, via API v2):
TWITTER_API_KEY,TWITTER_API_SECRET,TWITTER_ACCESS_TOKEN,TWITTER_ACCESS_SECRET. Ensure Read and Write permissions are enabled in the Developer Portal. X API posting is currently credit-based; the bot minimizes usage to two posts on trade days and one on no-trade days.
See docs/assets/tweet-flow-examples.md for complete trade-day and no-trade examples with the dark-theme charts.
Keep the .env file out of version control; .gitignore already excludes it.
| Path | Contents |
|---|---|
opening_range_bot/ |
Runtime bot: main loop and replay (run_bot.py), OANDA client, data feed, logging, X notifier, charts |
src/ |
Shared strategy logic and the research simulator (research_*.py) |
config/ |
Versioned strategy and instrument YAML |
research/ |
Research log: README, phase1-validation/, phase2-improvement/, frozen protocols/ |
scripts/ |
Research, account and asset tools plus deployment entry points. Read scripts/README.md before running one |
notebooks/ |
Original backtest notebooks (blank, run only as ignored *.local.ipynb copies) |
tests/ |
Strategy and runtime parity and research tests (pytest) |
docs/assets/ |
README figures and X post examples |
data/, logs/, reports/ |
Git-ignored private data, runtime logs and generated outputs |
- Fetch a session day (NY 09:00–13:00) to CSV (example for 2025-11-27):
- Linux/macOS/WSL:
python scripts/research/fetch_session.py 2025-11-27 - PowerShell (Windows):
python scripts/research/fetch_session.py 2025-11-27Output:data/raw/replay_2025-11-27.csv
- Linux/macOS/WSL:
- Run the bot in replay mode against that file (no live calls):
- Basic Replay (Logs only):
- PowerShell:
$env:REPLAY_FILE="data/raw/replay_2025-11-27.csv"; python -m opening_range_bot.run_bot - Linux/macOS:
REPLAY_FILE=data/raw/replay_2025-11-27.csv python -m opening_range_bot.run_bot
- PowerShell:
- Full Replay (Logs + Tweet + Chart):
- PowerShell:
$env:REPLAY_TWEETS="true"; $env:REPLAY_FILE="data/raw/replay_2025-11-27.csv"; python -m opening_range_bot.run_bot - Linux/macOS:
REPLAY_TWEETS=true REPLAY_FILE=data/raw/replay_2025-11-27.csv python -m opening_range_bot.run_botGenerates a consolidated report with OR levels, trade signal, PnL, MFE/MAE stats, and attaches a chart image.
- PowerShell:
- Basic Replay (Logs only):
Once the bot is running in Docker (see DEPLOYMENT.md), use these commands to verify health and connectivity:
-
Verify Account & Margin:
sudo docker exec trading-bot python scripts/account/verify_account.pyChecks connection to OANDA, confirms USD currency, and verifies sufficient margin (~$105k) for the strategy.
-
List Available Accounts:
sudo docker exec trading-bot python scripts/account/list_accounts.pyLists all sub-accounts your API token can access. Useful if you get 403 Forbidden errors.
-
Check Live Logs:
sudo docker logs -f trading-bot
- Clock/timezone: sync NTP; convert OANDA UTC to NY; handle DST.
- Symbol mapping:
NAS100_USD(or broker equivalent), tick size, min stop distance. - Risk rails: one trade/day; skip if 10:22/12:00 missing or OR range ≤0; fail-safe flatten at 12:00; cap position size/daily loss.
- Logging/alerts: log every bar/decision/order/fill; alert on errors/missed exits; keep a heartbeat.
- Costs/size: use broker-accurate spread/fees in config; set fixed size or vol-based sizing if needed.




