In this article, we will show you how to run, customize, and analyze a backtest for the Opening Range Breakout (ORB) strategy, as presented in our 2023 paper “Can Day Trading Really Be Profitable” co-authored with Andrew Aziz.
If you haven’t read the paper yet, we recommend skimming through it first to fully understand the trading strategy at its core.
Instead of explaining every line of code, we’ll focus on how to execute the backtest, adjust key parameters, and interpret the results.

By the end, you’ll be able to:
🔹 Run the backtest in Google Colab with minimal setup.
🔹 Modify strategy settings to test variations of the base approach described in the paper.
🔹 Interpret the performance metrics to assess profitability.
How This Backtest Works
This backtesting project is organized into three key sections, each corresponding to specific cells in the notebook:
Cell 1: Setting Up the Backtest → Load essential libraries, define global parameters, and configure data sources.
Cell 2: Fetching and Processing Market Data → Retrieve historical stock data, clean it, and structure it for analysis. No parameter adjustments are required in this step.
Cell 3: Running the Backtest & Analyzing Results → Execute the strategy, review key performance metrics, and visualize the equity curve.
Instead of analyzing every function, we’ll focus on efficiently running, modifying, and interpreting the backtest.
Let’s get started!
Running the Backtest in Google Colab
The easiest way to run this backtest is in Google Colab, which requires no local setup.
Click the link below to open the backtest notebook in Google Colab:
This interactive notebook runs in Google Colab – a free online platform for writing and executing Python code in your browser.
Open in Google ColabNote: No installation required. Click the link above to view and run the code.
Cell 1: Setting Up Data Parameters for the Backtest
Once the notebook is open, you will see the first cell labeled Global Parameters and Imports, this cell initializes all the necessary libraries and configurations for the backtest.
🔧 Editing Parameters Before Running the Backtest
Before running the backtest, you need to edit the following parameters:
Parameter | Explanation |
API_KEY | Required for fetching data from Polygon.io. Replace "POLYGON_API_KEY" with your actual key. |
PAID_POLYGON_SUBSCRIPTION | Set to True if you have a paid Polygon.io account (gives access to more historical data); otherwise, set to False . |
TICKER | Defines the trading instrument (currently set to TQQQ ). |
START_DATE | Defines the backtest start date. If using a free API key, this must be within the last 2 years. |
END_DATE | Defines the end date of the backtest. |
- If you are using a free Polygon.io key, your
START_DATE
must be within the last 2 years, or the request will fail. - If you set
PAID_POLYGON_SUBSCRIPTION = True
but do not have a paid plan, the backtest will fail because it will reach the 5 requests per minute limit. - The default ticker is
TQQQ
, a 3x leveraged ETF.
Cell 2: Fetching Market Data, Processing, and Preparing Functions for Backtesting
Now that we have configured our data parameters in Cell 1, the next step is to fetch, process, and structure historical market data.
This cell does the heavy lifting by:
🔹 Retrieving intraday stock price data (minute-by-minute candles).
🔹 Fetching daily price data (used for ATR-based stop-loss calculation).
🔹 Processing and cleaning the raw data into a structured format.
🔹 Loading essential functions that the backtest needs.
Cell 3: Running the ORB Backtest & Analyzing Performance
Now that we have set up our data parameters (Cell 1) and fetched and processed market data (Cell 2), it’s time to run the actual backtest and analyze the results.
This cell is responsible for:
🔹 Configuring the backtest parameters (trade risk, stop losses, leverage, etc.).
🔹 Executing the ORB (Opening Range Breakout) strategy over the historical data.
🔹 Generating key performance metrics such as returns, Sharpe ratio, and drawdowns.
🔹 Visualizing the backtest performance with an equity curve.
🔧 Adjusting Strategy Parameters (Optional)
Parameter | Description |
orb_m = 5 | The opening range breakout window in minutes (e.g., 5 means the strategy looks at the first 5-minute candle). |
target_R = float('inf') | Defines the profit target in multiples of risk (set to float('inf') for no target). |
commission = 0.0005 | Trading cost per share. |
risk = 0.01 | Risk per trade (as a percentage of AUM). |
max_Lev = 4 | Maximum leverage allowed in the backtest. |
AUM_0 = 25000 | Initial account balance. |
📌 What Happens Here?
🔹 The function backtest()
takes in historical price data and applies the ORB trading strategy.
🔹 It simulates buying and selling trades based on breakout signals.
🔹 It tracks account balance, risk management, and returns over time.
Analyzing Performance Metrics
After running the backtest, the next step is to evaluate the strategy’s effectiveness.
This section calculates:
🔹 Total returns over the backtest period.
🔹 Compound Annual Growth Rate (CAGR)—how much the strategy grows per year.
🔹 Volatility and Sharpe Ratio—risk-adjusted performance.
🔹 Max Drawdown (MDD)—largest peak-to-trough loss.
🔹 Monthly return breakdown—helps identify profitable vs. losing months.
Performance Summary
Metric | Value | Interpretation |
Starting AUM | $25,000.00 | Initial investment amount. |
Final AUM | $606,941.49 | Total account value on the final day of the backtest. |
Total Return | 2327.77% | The strategy grew the capital 23x over the backtest period. |
CAGR (Annual Growth Rate) | 41.90% | This is a strong return for a trading strategy. |
Volatility | 39.90% | Measures the average annualized fluctuations. |
Sharpe Ratio | 1.067 | Annualized risk-adjusted return |
Max Drawdown | -37.09% | Largest peak-to-trough decline (high but reasonable). |
Monthly Performance Breakdown
The following table provides month-by-month performance across different years:
Year | Best Month | Worst Month | Yearly Return (%) |
---|---|---|---|
2016 | +19.67% (Nov) | -7.69% (Jul) | +92.20% |
2017 | +27.11% (Feb) | -11.83% (Mar) | +11.55% |
2018 | +26.74% (Jul) | -11.72% (Dec) | +89.84% |
2019 | +18.92% (Dec) | -12.83% (Feb) | +50.16% |
2020 | +15.64% (Jun) | -14.03% (Mar) | +12.85% |
2021 | +18.85% (Apr) | -5.77% (Feb) | +44.14% |
2022 | +21.57% (Oct) | -11.49% (Feb) | +32.63% |
2023 | +61.51% (Aug) | -11.99% (Jan) | +13.12% |
2024 | +26.64% (Dec) | -9.44% (Jan) | +33.16% |
2025 | +16.40% (Feb) | +5.01% (Jan) | +22.23% (so far, 21-02-2025) |
Visualizing the Equity Curve
The final step is plotting the performance of the strategy over time.

📌 What This Chart Shows:
🔹 Account growth over time—how the capital increased/decreased.
🔹 Risk-adjusted performance—volatile equity curve with significant yearly returns.
🔹 Major drawdowns—where the strategy experienced losses.
Conclusion: The Backtest Runs Successfully
This guide demonstrates a fully functional ORB backtest running in Google Colab. The code seamlessly fetches market data, processes it, and executes the strategy, producing key performance metrics and an equity curve.
The backtest is ready to use—simply open the Colab notebook, run the cells, and adjust parameters as needed to explore different strategy variations.