In the world of stock trading, developing an effective and scalable trading strategy can be the difference between success and failure. Mark Rendle, an EPAT alumnus, embarked on a project that combined both technical analysis and Python programming to create an automated Bollinger Band-based trading system.
About Mark Rendle (Engineering Fellow):
Mark Rendle is an Engineering Fellow at a US Fortune 500 company, based in Houston. His focus is on complex problem-solving, decision quality and integrated planning. He holds a bachelor’s degree in Mechanical Engineering and a master’s in Business Administration. He has 20+ years of algorithmic trading experience, generally using the TradeStation platform.
About the EPAT project:
Mark Rendle’s EPAT project demonstrates the power of algorithmic trading combined with a clear strategy for managing multiple positions. The project is built around a Bollinger Band-based strategy, with a focus on using Python for backtesting, signal generation, and portfolio management. Below is a breakdown of the journey from implementing the strategy to evolving it into a sophisticated trading platform.
The Core of the Bollinger Band Strategy
Rendle's approach to stock trading started with a simple yet powerful strategy based on Bollinger Bands, a popular technical indicator used to measure price volatility. For a single stock, he used daily price data to trigger various trade signals. These signals were based on the stock's interaction with the Bollinger Bands, which consist of three components: a simple moving average (SMA), the upper band, and the lower band.
- Buy Signal: A buy was triggered when the stock price fell below the lower Bollinger Band, signaling that the stock might be undervalued or oversold.
- Sell Signal (To exit long positions): The strategy called for a sell when the stock price rose above the SMA, indicating the price had moved back to a more neutral level.
- Short Signal: A short position was initiated when the stock price exceeded the upper Bollinger Band, suggesting the stock might be overbought.
- Cover Signal: The cover signal occurred when the price fell back below the SMA, prompting the closure of the short position.
Rendle used this strategy to calculate both daily and annual returns across individual stocks as well as a portfolio of long and short positions across a stock universe, which helped him gauge the effectiveness of each trade and fine-tune the strategy over time.
Scaling the Strategy: From Single Stock to Portfolio
Once the basic Bollinger Band strategy was working for a single stock, Rendle took it a step further by expanding the system to handle multiple positions. He began by downloading additional stock data from Interactive Brokers, replacing Yahoo Finance as his data source. This allowed him to create a diversified portfolio of long positions, enhancing the strategy's robustness.
Rendle wrote a loop in Python to generate buy/sell signals for each stock in his portfolio. Additionally, he tracked the profit and loss (P&L) for individual stocks, as well as the overall P&L for the entire portfolio. This move made the strategy more practical for real-world trading, as managing multiple positions and portfolios is a common requirement for most traders.
Integrating with Interactive Brokers Using iBridgePy
A crucial part of Rendle’s strategy was connecting his platform to Interactive Brokers, one of the most widely used brokers for algorithmic and high-frequency trading. To achieve this, he utilized iBridgePy, a Python library that serves as a bridge between Python and Interactive Brokers. iBridgePy allowed him to access real-time market data, execute trades, and monitor his positions directly through the Interactive Brokers interface.
Setting up iBridgePy involved several steps. First, Rendle created a paper trading account with Interactive Brokers and subscribed to the necessary data. He then tested the functionality of his strategy on this paper trading account to ensure it performed as expected before going live. This integration was pivotal in scaling the trading strategy and giving Rendle access to real-time data and execution capabilities.
Analyzing Strategy Performance
Once the system was up and running, Rendle focused on creating simple yet effective analytics to evaluate his strategy's performance. He built a reporting tool that displayed:
- Cumulative P&L: This showed the profit and loss for each stock, separated into long and short positions, as well as the combined result for the entire portfolio.
- Capital Deployment: Rendle tracked how capital was allocated across different positions to ensure his account was neither over-leveraged nor under-utilized.
These analytics provided valuable insights into the effectiveness of the trading strategy and allowed Rendle to make data-driven decisions for future trades.
Overcoming Challenges
Like any complex project, Rendle faced several challenges along the way. One of the primary hurdles was his initial lack of proficiency in Python. Learning the programming language's ins and outs, especially in algorithmic trading, was a steep learning curve. Setting up iBridgePy and connecting it with Interactive Brokers was also tricky at first, especially when compared to more user-friendly platforms like TradeStation.
However, Rendle’s passion for trading kept him motivated. With persistence and support from the EPAT faculty and the iBridgePy community, he navigated these challenges. Over time, he became proficient in Python and learned how to troubleshoot and resolve issues on his own.
Also, in the words of Mark Rendle:
“The EPAT program has been instrumental in helping me pivot into more modern tools like Python and IB integration. Most of my background was in TradeStation, which is great for discretionary or semi-automated strategies, but for full-scale algorithmic trading, EPAT gave me the structure and technical knowledge I needed.
The faculty was incredibly helpful, especially when I ran into issues setting up iBridgePy and connecting with Interactive Brokers. I also learned to break my code into more manageable modules, which helped with scaling the strategy.
I came into the course without much Python knowledge, and by the end, I had a working trading system connected to live market data and execution logic, and it worked reliably. That journey would’ve taken me far longer on my own.”
Improving the Strategy: From Code to Efficiency
As the project progressed, Rendle focused on making his code more efficient. Initially, the code was written as a monolithic script, which was difficult to manage and scale. Rendle improved the code by breaking it down into smaller functions, making it more modular, robust, and easier to maintain.
Additionally, he upgraded the system to handle intraday data, which allowed for more granular analysis of stock price movements. He also introduced the ability to loop through various portfolios and timeframes, enabling the system to evaluate the strategy's performance over longer periods and in different market conditions.
The Current State of the Trading Platform
Today, Rendle’s platform has evolved into a powerful tool for evaluating different entry signals, managing trades, and analyzing portfolio performance across various time frames. It supports extended datasets and provides a comprehensive view of strategy efficacy. The platform now handles multiple positions with ease and offers robust reporting features that help traders make informed decisions.
Rendle’s journey from a simple Bollinger Band strategy to a fully-fledged trading system highlights the power of combining technical analysis with algorithmic trading and programming. His experience underscores the importance of persistence, continuous learning, and the value of leveraging the right tools to build and optimize a trading platform.
Next Steps: Going Beyond Bollinger Bands
To deepen your understanding of the concepts explored in this blog, start with the Bollinger Bands blog, which provides a foundational overview of the indicator used in Mark Rendle’s strategy. Follow that with Five Indicators to Build Trend-Following Strategies to expand your technical analysis toolkit.
To implement and customize your own trading strategy, strengthen your Python skills with Basics of Python Programming and explore Python Trading Library for hands-on coding support. For building interactive visualizations of your strategies, Plotly Python Tutorial is a great resource.
As you move toward full strategy deployment, understanding evaluation is crucial. The Backtesting blog offers guidance on how to test and refine strategies effectively.
For structured, practical learning, explore Quantra’s Python for Trading: Basic and Getting Market Data. If you want to go deeper into strategy building using popular indicators like Bollinger Bands, RSI, and MACD, take the Technical Indicators Strategies using Python course on Quantra, which offers a practical walk-through of multiple strategies and their implementation.
For those aiming to transform their career in algorithmic trading like Mark Rendle, the Executive Programme in Algorithmic Trading (EPAT) offers a complete, application-driven education in strategy development, Python, data handling, and live trading integrations.
Connect with an EPAT career counsellor to discuss the right quant role for your background.