Crude oil volume spikes.
A trading bot walkthrough.
Published date: May 26, 2026
Last updated: September 26, 2026
THE WRITTEN WALKTHROUGH
Why build a crude oil volume-spike trading bot?
On March 23, 2026, trading in crude oil futures surged around 6:50 a.m. Eastern Time, roughly 15 minutes before President Donald Trump announced on Truth Social that planned strikes on Iran’s energy infrastructure would be postponed. Reuters reported a concentrated burst of trading in Brent and West Texas Intermediate (WTI) futures ahead of the post.
That sequence inspired a research question: can a trading bot identify abnormal volume in real time? The timing alone cannot establish who traded, why, or whether anyone possessed nonpublic information.
How the QuantConnect Python bot detects unusual volume
The system monitors minute-by-minute data for the most actively traded WTI crude oil futures contract, including extended trading hours. It disables fill-forward so artificial, repeated bars are not mistaken for genuine trading activity. It also tracks daily volume among contracts expiring within 60 days, allowing the monitored contract to change as liquidity shifts near expiration.
To define normal activity, the algorithm calculates a reference using one week of regular-session minute volume and a 14-day warm-up. A spike must exceed that baseline by three times outside regular hours or six times during regular hours. Separate thresholds matter because trading volume changes dramatically throughout the day.
Several filters reduce noise: the bot skips the first hour of Sunday trading, limits alerts to one every two hours and checks a spike against activity at the same time in the previous week’s stored minute bars. These rules seek to distinguish unexpected activity from routine surges; they cannot eliminate every false alert. In live deployment, qualifying alerts can be sent to a chosen Discord channel through a webhook.
Can volume-spike alerts lead to profitable trades?
The lesson’s bonus experiment converts alerts into a basic trading strategy. A green one-minute candle triggers a long position; a red candle triggers a short position. Opposing signals can reverse the position, while a 10% take-profit rule provides an exit. The example enters one futures contract at a time.
In the video, one backtest covering approximately March 20 to April 21, 2026, reports a 35.08% return and 68% win rate. These are results from the particular simulation shown, not verified live returns or evidence of a repeatable edge. Slippage, trading costs, liquidity, market changes and strategy crowding can materially change real-world results. An unusual volume alert identifies activity; it does not independently establish price direction or profitability.
For a broader explanation of why simulated results can differ from deployment, see our guide to backtesting vs paper trading vs live trading.
Go from following a project to designing your own.
Follow a structured path through Python fundamentals, trading-bot development and backtesting, with practical QuantConnect examples.