Published on

(Verbose version) Introducing TailTitanPro: Reflections from 28 Months of Building an Algo Trading System

Authors
  • avatar
    Name
    Ang Yi Shuan
    Twitter
TailTitanPro logo

TailTitanPro Logo.

Note: Long read (~11 minutes). Want a short version? Click here

Legal disclaimer here.

Introduction

In my pursuit of trading strategies, I've found myself drawn to the allure of long naked calls and puts, driven by their combination of limited risk and unlimited profit potential. The existence of fat right tails suggests the presence of significant opportunities, akin to being in the right place at the right time. Curious to quantify these prospects, I've pondered whether I'd face the risk of a gradual decline through numerous small losses, or if genuine opportunities lie within reach.

Shifting Focus to Day Trading

To mitigate overnight risks such as gap risk, my focus has shifted towards day trading. Additionally, I've honed in on weeklies for equity options and dailies for index/ETF options, recognizing the potential for substantial gains within these shorter timeframes. This strategic approach aims to capitalise on fleeting opportunities while managing inherent risks effectively.

Leveraging Algorithms

Algorithms, or algos, have become indispensable tools for me, particularly in situations where manual intervention is limited by constraints such as time or capacity. Take, for instance, the realm of options trading, where the sheer volume of activity is overwhelming.

With over 400 tickers with options being actively traded daily, each offering multiple strike prices, and ETFs boasting even more options, it's simply impossible to monitor them all simultaneously. This is where algorithms truly shine, enabling me to manage a myriad of option contracts efficiently.

What truly drives my passion for algorithmic trading is the intellectual and creative challenge it presents. Developing the infrastructure and strategies for algo trading is not only fulfilling but also immensely enjoyable and exciting.

Even if my code doesn't always yield immediate profits, I know that the skills I'm honing in logic and programming will serve me well in other endeavors. The journey of crafting and refining these algorithms is as rewarding as the potential profits they may bring.

TailTitanPro: A Comprehensive Trading System

In TailTitanPro, my algorithmic trading system, several components come together to streamline my trading experience.

At its core is a user-friendly GUI developed using PyQt6. The main page organizes various tickers into tables categorized by stocks, calls, puts, and a timestamp indicating when these tickers were added. Through TailTitanPro, I'm able to seamlessly stream quote data for option contracts and their underlying stock symbols, all while tracking the timing of the highest bid/ask pair received via websocket—a crucial feature for my price action strategies.

Embedded within the program are the strategies themselves, with sell conditions evaluated for each ticker in real-time. Additionally, TailTitanPro offers insight into current positions held in both simulation and real trading environments through dedicated pages.

Beyond these core functionalities, several auxiliary tabs provide added convenience. "Moomoo trade" simplifies manual trading with fewer steps compared to using a broker's app. "Graph contract bid/ask" offers robust options data analysis, including bid/ask charting and intrinsic value calculations. "Ticker option table + suitable contracts" stores and displays options chain data for easy access. "Manually add tickers" allows me to dynamically monitor additional tickers by utilizing ZMQ to send tickers over a local TCP address.

With TailTitanPro, I have a comprehensive toolset at my disposal to enhance my algorithmic trading strategies.

TailTitanPro main page

TailTitanPro Main Page. Click the image to expand.

TailTitanPro positions page

TailTitanPro Positions / Orders Page. Click the image to expand.

TailTitanPro Moomoo Trading Window

TailTitanPro Moomoo Trading Window.

TailTitanPro Graph Contract Bid/Ask Window

TailTitanPro Graph Contract Bid/Ask Window. My options data analysis program.

TailTitanPro Check Option Chain Window - SPXW 0DTE option chain is displayed here.

TailTitanPro Check Option Chain Window - SPXW 0DTE option chain is displayed here. Click the image to expand.

TailTitanPro Check Option Chain Window - AAPL weeklies option chain is displayed here.

TailTitanPro Check Option Chain Window - AAPL weeklies option chain is displayed here. Click the image to expand.

TailTitanPro ZMQ Sender Window.

TailTitanPro ZMQ Sender Window: To manually add tickers into TailTitanPro Main Page.

Building My Own System

In building my own trading system, I made a deliberate decision to steer clear of the plethora of open-source tools available, including QuantConnect, backtesting.py, bt, and zipline. Despite their appeal, I chose not to utilise them for several reasons.

Firstly, there's a notable learning curve associated with these tools, and I foresaw potential limitations in customisation that might hinder my strategy's adaptability in the long run. Instead, I opted to develop my own system entirely in Python, spanning both backtesting and live trading functionalities.

This decision, while undoubtedly time-consuming, has provided me with an in-depth understanding of every aspect of the system, from its core algorithms to its minutiae. By building from scratch, I've honed my skills as a software engineer, fostering a comprehensive grasp of the inner workings of my creation.

However, I'm not opposed to leveraging existing resources where appropriate. For tasks like data visualisation, I rely on established charting libraries such as matplotlib and plotly, along with foundational tools like pandas and numpy.

This approach ensures that my system remains agnostic to any particular broker or library, offering flexibility and scalability as I continue to refine and optimise my trading strategies.

Data Management

Embarking on this journey, my initial task was to devise a system for gathering live data. Recognizing the critical importance of using live data to ensure the fidelity of my backtest system, I tackled the challenges associated with collecting such data head-on.

Issues like network conditions and latency demanded my attention if I aimed to replicate real-world trading scenarios accurately. As a recent graduate, resourcefulness became my ally, leading me to rely on freely available data sources.

Initially experimenting with an unofficial Yahoo Finance API, I swiftly abandoned it due to its unreliability. Fortunately, I found reliable real-time option data through my broker, Moomoo, alongside free real-time stock data from Tradier and backup data from Finnhub.

Historical data, essential for comprehensive analysis, was sourced from barchart.com and Alpha Vantage at minimal cost. Keeping data storage simple, I opted for Excel files (XLSX), each representing a single trading day.

Leveraging the openPYXL library, I organized each ticker's data into sheets within the Excel files, facilitating easy manual verification when necessary. However, I encountered a bottleneck when loading data into Pandas, prompting me to implement a caching mechanism.

By pickling the results of read_excel, subsequent data loads became nearly instantaneous. Each trading day's Excel file occupies roughly 80MB, while its pickled counterpart consumes around 150MB, totaling approximately 230MB per day.

This meticulous approach ensures both the accuracy and efficiency of my trading system's data management.

Technical or fundamental?

My mentor is a discretionary technical options day trader who hardly uses any fundamental information. He firmly believes that technical systems are easier to build and run, albeit with the understanding that incorporating fundamental rules can often lead to additional profits.

As a one-man team, I found myself facing the dilemma of whether to allocate the extra effort needed for integrating fundamental analysis into my trading strategy. Ultimately, I decided to stick with building a straightforward technical system, as I wasn't willing to invest the additional time and resources required.

Strategy and Analysis

My primary strategy centers on price action analysis. I meticulously document each strategy employed during backtesting sessions using an Excel spreadsheet. This includes the specific tickers tested and the resulting outcomes. Throughout these backtests, I maintain a fixed investment amount for each trading day. Additionally, I create cumulative profit and loss (PnL) graphs to enhance visualisation and better understand the performance trends. This structured approach aids in refining my trading techniques and making informed decisions based on historical data.

Risk Management

In my ideal trading scenario, I envision my PnL chart forming a sleek 45-degree line ascending from the bottom left corner to the top right, but I realise this is merely wishful thinking. Like most people, I'm inherently loss-averse; the sting of losing $100 tends to outweigh the joy of gaining the same amount.

Consequently, my primary concern lies in assessing Peak-To-Valley or maximum drawdown. Focusing primarily on capturing the fat tails in my strategy, conventional metrics such as Sharpe ratio (which presupposes a normal distribution of returns), mean, variance, standard deviation, and linear regression fall short in accurately encapsulating the behaviour of fat-tailed distributions.

In the world of trading, there's a saying I hold dear: "Live to trade another day." With this mantra in mind, I understand the paramount importance of proper risk management. Through meticulous backtesting, I've diligently ensured that the maximum drawdown in my trading strategy doesn't surpass a threshold I'm comfortable with losing.

It's a safety net, a boundary that protects my capital and preserves my ability to continue trading. Should I encounter a drawdown in live trading that exceeds my historical maximum, it serves as a signal to pause and reassess the strategy. It's about adaptability, staying agile in the face of market challenges, and ultimately, safeguarding my longevity as a trader.

Ensuring Reliability

When developing a trading strategy, it's crucial to ensure its reliability and effectiveness across various scenarios and to detect if the strategy is potentially overfitting. One approach I employ is to vary the parameters slightly to gauge how sensitive the results are.

For instance, if my system considers the Simple Moving Average of the last 10 values (SMA10), I explore how altering it to SMA8/9 or SMA11/12 affects the outcomes. If even slight variations significantly skew the results, it's indicative of potential overfitting, signalling the need for refinement.

Additionally, I implement cross-asset validation to assess the strategy's performance across different assets sharing similar characteristics or market dynamics. For example, I test a model designed for SPY options on QQQ options due to their high correlation, approximately 0.86, stemming from their exposure to the broader US equity market.

This method ensures the strategy's generalisability and effectiveness beyond its original asset, providing valuable insights into its robustness and predictive power.

Real-world Challenges

Since mid-January 2024, my algorithmic trading system, TailTitanPro, has been operational, specializing in trading out-of-the-money (OTM) 0DTE (zero days to expiration) index options. To ensure its effectiveness in real-time scenarios, I've personally invested a small amount of capital into the system before contemplating scaling it up further.

TailTitanPro has the potential to be invaluable in professional environments, catering to financial institutions, hedge funds, or proprietary trading firms aiming to refine their strategies in high-speed markets. Its focus on short-term options facilitates automated trading, enabling the possibility of profitable ventures within a single trading day.

When considering the integration of such a model into professional settings, numerous risks warrant careful consideration. Firstly, capital losses loom as a significant concern. Venturing into trading out-of-the-money (OTM) zero-day-to-expiration (0DTE) options carries substantial risk, potentially resulting in the loss of invested capital.

Despite favorable outcomes in backtesting, real-time trading introduces variability due to market volatility and unforeseen events, which may diverge from expected results. Moreover, transitioning from backtesting to live trading poses execution risks, including the potential for errors or delays that could impact the system's performance.

Factors such as slippage, order fills, and latency issues may influence trade accuracy and profitability. Market dynamics further compound these challenges, as strategies that excel in backtests may falter in live environments due to sudden shifts, liquidity constraints, or volatility fluctuations.

Regulatory and compliance risks also come into play, as algorithmic trading is subject to oversight and adherence to regulatory guidelines is imperative. Failure to comply with risk management protocols or reporting requirements could lead to legal and financial repercussions.

Additionally, the model's performance may degrade over time as market conditions evolve, necessitating continuous monitoring and adaptation to maintain relevance and effectiveness in dynamic environments.

In my journey into algorithmic trading, I found myself taking on three distinct roles simultaneously: the quant modeler, the software developer, and the operations specialist. As a quant modeler, my focus was on uncovering profitable patterns in data, constantly refining strategies to generate alpha signals.

Transitioning into the role of a software developer, my aim was to translate these strategies into a functional trading system, prioritizing efficiency and robustness in the code. Simultaneously, wearing the hat of an operations specialist, I brought a business-oriented perspective, emphasizing risk management, scalability, and the overall viability of the strategy in the market.

Challenges and Reflections

Reflecting on this experience, I realised the importance of balance across these perspectives. While the quant modeller might be consumed with refining alpha, the operations specialist may highlight concerns about profitability given market conditions. By integrating insights from all three roles, I discovered the value of creating a holistic and robust algorithmic trading system. It became evident that success wasn't solely reliant on a great strategy but also on its implementability, scalability, and profitability in real-world market conditions.

Lessons Learned

In hindsight, I recognised some early missteps. I spent a significant amount of time exploring technical indicators, particularly lagging ones, without fully grasping their purpose. However, I eventually realised that while technical indicators have their place, especially in longer time frames, their application to options trading, where understanding the Greeks is paramount, was misguided. This phase of exploration, though, seems to be a rite of passage for new algorithmic traders.

Additionally, I used to believe that a sophisticated strategy required a multitude of parameters, but I've since learned otherwise. Simple algorithms often yield better results through consistent execution and reduce the risk of overfitting. This realisation has reshaped my approach, emphasising simplicity and efficiency in algorithmic trading.

Customizability and Integration

One aspect that truly sets my project apart is its remarkable level of customisability. Right from the outset, I took on the challenge of building the entire system independently, giving me a level of control and adaptability rarely seen in pre-packaged solutions. This means I can finely tune the system to match my unique preferences, risk tolerances, and prevailing market conditions, amplifying its versatility and effectiveness across diverse trading landscapes.

Moreover, a crucial distinguishing factor of my project is the seamless integration between the backtest and live trading code. Taking a meticulous approach, I began with the live trading code, ensuring a close coupling with the backtest code.

This meticulous alignment guarantees that the results obtained during backtesting closely mirror the outcomes achieved in live trading environments. This not only bolsters the reliability and trustworthiness of the system but also fosters confidence among potential users in its ability to deliver consistent performance across theoretical simulations and real-world executions.

Conclusion

In concluding my reflections on my algorithmic trading system project, I wish to address potential employers or collaborators with a sense of honesty and humility.

This endeavor has marked a significant milestone in my journey as a developer and quant enthusiast, spanning the past 28 months. It stands as both a testament to my dedication and technical acumen in navigating the complexities of algorithmic trading.

Throughout rigorous backtesting, the system has shown promise, offering glimpses of its potential effectiveness. However, I am keenly aware of the challenges and inherent risks that lie ahead, particularly in transitioning it to a live trading environment within a professional setting.

While the project showcases my skills and passion, it does so with a recognition of its limitations. It is not a definitive solution but rather a foundation that requires further refinement, validation, and careful consideration of potential production risks.

My commitment to this project underscores my eagerness to continue learning and improving, and I am eager to collaborate with others who share my passion and dedication to the field.

Invitation to Readers

After delving into my portfolio piece, I extend a warm invitation to readers to delve deeper into the realms of algorithmic trading, quantitative finance, and associated fields.

I value and encourage any feedback, insights, or constructive criticism that can aid in my ongoing development as both a developer and researcher. Whether you're intrigued by potential collaborations, eager to explore ideas, or simply keen on exchanging experiences within the dynamic world of algorithmic trading, I'm here to engage.

Let's embark on a journey together, navigating the intricate landscape of quantitative finance with humility and a keen awareness of the obstacles that lie ahead. Don't hesitate to reach out – our combined efforts can lead us towards innovative solutions and meaningful progress.