Halal Alpha
My journey of dipping into the Islamic finance world by attempting to build a fully sharia-compliant novice quant trading algorithm
Growing up Muslim in North America, investing was always one of those topics that seemed simultaneously important and confusing. The importance was obvious enough. Whether it was retirement accounts, index funds, real estate, or simply the idea of “putting money to work” rather than letting it collect dust in a bank account, investing seemed to be one of the primary ways that people built long-term financial security. The confusing part was figuring out how that fit into an Islamic framework.
I remember hearing discussions about halal investing from a fairly young age, but most of the conversations seemed to focus on conclusions rather than explanations. Certain investments were halal. Others were not. Certain companies were acceptable to own. Others were not. There were discussions about riba (interest), dayn (debt), and Shariah compliance, but very little explanation of what those concepts actually meant in practice or how somebody was supposed to navigate them as an investor.
When I entered college, I realized that this confusion was not unique to me. Many of my Muslim peers understood that they should be investing for the future, but very few of us actually understood how Islamic finance actually approaches investing in public markets. Even among people who actively invest, there is often a significant gap between understanding that a fund is considered Shariah-compliant and understanding why it is considered Shariah-compliant.
The deeper I looked into the subject, the more I realized that Islamic finance is attempting to answer a fairly interesting question. If somebody wants exposure to the productive capacity of businesses and the growth of the broader economy, can they participate in those opportunities while remaining consistent with a particular set of religious and ethical principles? It seems simple, but as I dug deeper, I quickly learned that the details can become surprisingly complex.
The Islamic Finance Problem Opportunity
What initially caught my attention was that many of the same challenges that make Islamic finance interesting from a religious perspective also make it interesting from a quantitative perspective. A conventional quantitative strategy can generally select from a very large universe of public companies. A Shariah-compliant strategy immediately operates under additional constraints. Certain industries are excluded outright and financial screens related to debt + other metrics become incredibly important. Therefore, the investable universe becomes smaller and more structured than in a non-sharia world.
Rather than viewing those constraints as limitations, I found myself wondering whether they might actually make for an interesting engineering problem.
At roughly the same time, I was spending much of my free time learning about quantitative investing. I had become fascinated by the idea that large amounts of market data could be transformed into systematic investment decisions through a combination of statistics, machine learning, portfolio construction, and risk management. What appealed to me was not necessarily the prospect of beating the market. It was the intellectual challenge of building something from the ground up and understanding how all of the moving pieces fit together.
Eventually, those two interests began to converge into a single question.
If somebody asked me to build a quantitative investment strategy that operated entirely within a Shariah-compliant universe, where would I even begin?
At the time, I had no formal training in quantitative finance. I was not studying computer science. I was not working at a hedge fund. Most of my academic life revolved around medicine, genomics, and hearing loss research. Nevertheless, I have always found that the fastest way for me to learn something is to try building it myself.
What Does “Halal Investing” Actually Mean?
One thing I think gets lost in discussions about Islamic finance is that many people assume it is primarily about avoiding certain companies. While that is certainly part of it, the reality is a bit more nuanced.
Most modern Shariah-compliant investment frameworks begin by excluding industries that are generally considered impermissible, such as alcohol, gambling, adult content, pork-related products, and conventional interest-based financial institutions. However, the screening process usually does not stop there. Many frameworks also evaluate financial characteristics such as debt levels and other balance sheet metrics to determine whether a company satisfies additional compliance criteria.
The result is that Islamic investing is not simply a list of approved and prohibited stocks. It is an entire framework for determining what kinds of businesses and financial structures are considered acceptable investments.
Fortunately, investors today do not have to do all of this screening themselves. Funds such as HLAL, SPUS, and others already perform this work and provide investors with access to portfolios of companies that satisfy these criteria.
My project was never intended to replace those funds. Instead, I became interested in understanding how one might systematically invest within a universe like that and what would happen if I tried building the infrastructure myself.
Building the Universe
The first challenge was determining what companies the strategy was even allowed to consider.
Most quantitative strategies begin with a large investment universe containing hundreds or thousands of stocks. For my project, I started by aggregating holdings from several halal-focused ETFs and then applying additional compliance filters. This ultimately produced a universe consisting primarily of liquid U.S. large-cap and mid-cap companies that satisfied the relevant screening criteria.
Teaching a Computer How to Evaluate Companies
Once I had a universe of companies, the next question became how to evaluate them.
Human investors often look at a mixture of factors when making decisions. They may examine recent stock performance, company fundamentals, earnings reports, industry trends, or even news coverage. Quantitative strategies attempt to do something similar, but in a systematic and repeatable way.
To accomplish this, I built a pipeline that collected several different categories of information. The system tracked historical stock prices and trading activity, incorporated basic company financial data, and analyzed financial news headlines using a natural language processing model called FinBERT, which is specifically designed for financial text.
The goal was not to predict exactly what any individual stock would do next. Predicting stock prices with high accuracy is extraordinarily difficult and probably impossible to do consistently. Instead, the objective was much simpler.
Given a large group of Shariah-compliant companies, could the system learn to rank them according to their relative attractiveness?
That distinction turned out to be important. Rather than trying to forecast the future with certainty, the model simply attempted to identify which companies appeared more attractive than others at a given point in time.
The Most Important Pitfall: Avoiding Fooling Yourself
One thing that surprised me while working on this project was how easy it is to accidentally convince yourself that a strategy works.
When I saw impressive investment results, I initially would assume the difficult part was finding a good model. In reality, one of the hardest challenges is ensuring that the model is not secretly cheating.
Imagine trying to predict tomorrow’s weather while accidentally looking at tomorrow’s forecast. Your predictions would look fantastic, but they would be meaningless.
A similar problem exists in quantitative finance. If future information accidentally leaks into a model during training, performance can appear dramatically better than it really is.
Because of this, a substantial portion of the project involved building safeguards to ensure that every decision was based only on information that would have been available at the time.
Turning Rankings Into a Portfolio
Once the model could rank companies, the next challenge was transforming those rankings into an actual portfolio.
If the model identified a company as attractive, how much capital should be allocated to it? How concentrated should the portfolio be? What happens if all of the highest-ranked companies happen to belong to the same sector?
These questions introduce an entirely different set of considerations. A good investment idea is not necessarily a good portfolio.
To address this, I built a portfolio construction framework that spread capital across approximately 150 companies while enforcing limits on both individual positions and sector-level exposure. The goal was to create a portfolio that remained diversified while still reflecting the model’s underlying views.
This was one of the aspects of the project that gave me the greatest appreciation for professional portfolio managers. Identifying opportunities is only part of the problem. Managing risk is a whole other side of the ballgame.
What Happened?
After building the data pipelines, training the models, constructing portfolios, and simulating trades over nearly a decade of historical data, I finally had a system that could be evaluated.
The final version of the strategy was tested from January 2016 through November 2025. The portfolio held approximately 150 stocks at a time, rebalanced roughly once per month, incorporated transaction costs, and included a volatility-targeting overlay designed to reduce risk during particularly turbulent market environments.
Over that period, the strategy generated a total return of approximately 262%, corresponding to an annualized return of roughly 14% per year. Annualized volatility was approximately 17%, resulting in a Sharpe ratio of about 0.85. The maximum drawdown, or peak-to-trough decline, was approximately 37%. While those numbers are certainly not extraordinary by hedge fund standards, they were encouraging to me because they emerged from a system that was built entirely from scratch and incorporated realistic trading assumptions rather than idealized backtests.
Perhaps more importantly, the strategy behaved in ways that were broadly consistent with how I expected a medium-horizon quantitative strategy to behave. Turnover remained relatively low, averaging only around 0.10% per day. The portfolio maintained diversified exposure across sectors, and many positions were held for extended periods of time, with a median holding period of roughly 960 trading days. This was not a system frantically trading in and out of stocks every few hours. Instead, it behaved more like a slow-moving process that gradually adjusted exposures as new information accumulated.
Detailed Methods
If you’re interested in the nitty gritty behind the technical implementation, including the data pipeline, feature engineering, machine learning architecture, portfolio construction framework, risk overlays, backtesting methodology, and performance diagnostics, I have also written a much more detailed technical paper available below:
Final Thoughts
When I started this project, I was primarily trying to answer a personal question about halal investing. Along the way, it became a vehicle for learning about machine learning, financial markets, portfolio construction, software engineering, and quantitative research.
Obviously, I’m sure that I’ve barely scratched the surface here. Undoubtedly, there are people who have spent decades studying these topics at a far deeper level than I have. What this project did give me, however, was a much greater appreciation for the amount of work that sits beneath the surface of every investment strategy that appears simple from the outside.
Ultimately, my drive to start this project began with a question that many Muslims encounter at some point in their lives: how do I participate in modern financial markets while remaining consistent with my values?
I certainly do not claim to have all the answers. But building Halal Alpha taught me far more about the question than I knew when I started.

