Home Blog

VIDEO: 7 Algorithmic Trading Strategies

In this article, we will explore seven algorithmic trading strategies, shedding light on their essential characteristics, advantages, and the diverse methodologies that traders employ to secure a competitive edge in the financial markets. Whether you are a seasoned investor or an aspiring trader, come along with us as we demystify the complexities of algorithmic trading strategies.

Tape Reading Trading Strategy – Can It Be Done? Rules And Backtest

Tape Reading Trading Strategy
Tape Reading Trading Strategy

With the emergence of personal computers and online trading via electronic communication networks (ECNs), you may think of tape reading as something ancient. While the term brings up memories of trading legends like Jesse Livermore, it is worth noting that, tape reading is still a part of the toolkit of day traders and scalpers in today’s markets. But what is the tape reading trading strategy?

The tape reading trading strategy is a method of trading that is based on studying the market data presented in Level II quotes in the Time and Sales window. In the past, this strategy involved reading old-style ticker tapes transmitted over telegraph lines, which provided traders with market data (ticker symbol, price, and volume) — that’s where it got its name from. The strategy is mostly used by day traders and scalpers to spot and take advantage of short-lived shifts in demand and supply.

In this post, we take a look at the tape reading trading strategy, and we’ll also include a backtest at the end of the article.

Related reading:

What does tape mean in trading?

In trading, tape refers to ticker tape, which describes the paper ribbon used in the late 19th and early 20th centuries for mechanically reporting and disseminating stock quotes and trades, made famous by the Jesse Livermore trading strategy.

Now present as an electronic representation of price quotes that appear in a linear fashion, providing investors with market information, ticker tape first appeared as a component of 19th-century ticker devices, which printed stock symbols and numeric data to convey information about trades and prices via telegraph wire.

The entries on the ticker tape include the stock symbol (which identifies the company whose stock has been traded), volume (the number of shares traded), the price per share at which the trade was executed, an up-or-down triangle indicating whether the price is higher or lower than the closing price of the previous trading day, and a second number indicating how much higher or lower the trade’s price was than the previous closing price.

Today’s electronic ticker tapes are color-coded, with green used to denote greater trade prices, red used to denote lower trading prices, and blue or white used to denote no change. Since 2001, trade prices are displayed in decimals rather than in fractions which were in use before then.

A more advanced form of the ticker tape in today’s market is the time and sales data, which provides a detailed account of a security’s or market’s trading activity. Although using the time and sales data is analogous to reading an old-fashioned ticker tape for an individual stock, the market data is now distributed as a real-time digital display that includes trade volume, price, direction, date, time, and exchange for each trade.

Most trading platforms have a well-labeled time and sales window, displaying real-time market data. The window shows a running table-format tally of trades for shares of a specific stock. Each of the primary components of time and sales, such as date/time, price/change, and volume, is organized in columns.

Rows of data are frequently color-coded to indicate whether the trade occurred on, within, or outside the bid or ask. Many trading platforms now allow investors to customize the display of time and sales data by adding price or volume filters, for example. Here is an example of a level 2 window:

Tape reading strategy

What is tape reading (definition)?

Tape reading is the practice of observing the Level II market data (prices and volumes) in real time to understand the shift in demand and supply and that in making trading decisions. It can help you to gauge overall market sentiment at any moment by monitoring supply and demand imbalances. Contrary to charts and indicators that are based on historical data, tape reading is a leading indicator.

In fact, tape reading is the oldest trading technique used by traders to analyze stock prices and volume. Traders, in the past, got such market data on ticker tapes, which displayed the ticker symbol, price, and volume.

With the rise of personal computers and electronic communication networks (ECNs), market data is now updated through computers, data feeds, and Level II quotes. Experienced short-term traders use such information to improve their trading decisions or even build a complete trading strategy around it.

Real-time tape reading will allow you to see what buyers and sellers are doing. It aids in your understanding of a chart pattern’s action. You can combine tape reading with price action trading and watch how chart patterns develop in real time. This provides a better understanding of the dynamics of supply and demand in a stock.

As an intraday trader, tape reading is a crucial skill to acquire because it enables you to see in real time where there is buying and selling occurring at the level. Acquiring this skill will increase your efficiency, risk/reward ratio, and ability to catch bigger moves while taking on the least amount of danger.

Your ability to interpret tapes is your competitive advantage over many other traders who believe technical analysis is the only thing they need to know. Reading the tape has several benefits, including bringing consistency to your trading, being a leading indicator, allowing you to spot buyers and sellers in real time, reducing trading risk, and putting you in more plays than the charts reveal. Analyzing the bid, offer, size, volume, and prints is the final step in reading the tape. With the right skills, you may be able to predict how a stock is going to move in the short term by reading the tape.

Tape reading was used by the legendary Jesse Livermore to achieve enormous trading success. Livermore started learning tape reading skills in 1891 at the age of 14 while he was working in a bucket shop (retail broker). He would go on to make hundreds of millions of dollars (over a billion dollars) in today’s market with those skills. Sadly, though, he ended his life with a bullet in his head after committing suicide after using too much leverage. He was a boom-and-bust speculator.

Does tape reading still work?

Although tape reading was phased out in the 1960s, it is still being used by today’s electronic traders, especially short-term traders, such as scalpers and day traders. Tape reading provides a lot of information about volume flow in the market, giving a clearer understanding of the market environment and the participants’ behavior. It can give more context about the market especially when it is used in combination with chart analysis. Some scalpers even use it to know when to buy and sell a stock. That said, tape reading is a very difficult art to master. Very few succeed.

Although there is a split between tape readers and chartists — traders who analyze data from the order book and others who look at charts and employ indicators to get trading signals — many traders try to combine both strategies.

The advantage of using tape reading is that it provides you with real-time intraday data that shows demand and supply shifts. This is extremely useful for making short-term price predictions. Tape reading can help improve efficiency when combined with price action trading strategies. It accomplishes this by confirming or rejecting the chart pattern breakouts on an intraday basis. As a result, it can be used to supplement a price action trading strategy.

Many advanced day traders enjoy tape reading because it helps them identify unethical trading practices. Order cancellation, price manipulation, and other techniques are frequently used by high-frequency trading firms, algorithmic traders, and others. Modern tape reading techniques based on an electronic order book make it possible to spot these market manipulations because, apart from the typical information present in the “old-school” ticker tapes, electronic order books also include information on unexecuted orders. Non-executed orders are frequently canceled on purpose, implying that they may be a market manipulation tactic.

Given the enormous amount of information that modern tape reading provides, helping day traders to get a glimpse of the way other market participants feel about particular instruments, showing market manipulation, and allowing for better prediction of prices, it is safe to say that tape reading still works.

Tape reading indicator

A tape reading indicator is a tool that can help display order flow on a trading platform.

For trading platforms that do not come with the time and sales window, such as the MetaTrader 4 platform used for CFD trading, a tape reading indicator can be used to show the real-time order flow in the underlying market. The indicator takes information on real orders on commodities and indexes from the exchange, such as the Chicago Mercantile Exchange (CME), and displays it on the MT4 platform chart. By default, the deals with the main trade contract are displayed with the contract with the highest Open Interest, according to which the forex price is formed.

Also, some platforms that come with an electronic tape window provide some indicators for analyzing market data. For example, the trading and analytical ATAS platform has a large set of unique and useful indicators, such as OI Analyzer, Cluster Search, Imbalances, and Speed of Tape, which can be used to analyze the data from its Smart Tape.

The Speed of Tape indicator, as the name implies, shows the speed of the Smart Tape data and highlights bars in the chart, which had changes in the Tape by the specified criteria.

The indicator calculates the speed by:

  • number of trades
  • volume of trades
  • delta
  • number of buys
  • number of sells

Since time is always calculated in seconds, it means that a trader may use the Speed of Tape to see the highlighted bars, in which the number of trades/delta/volumes exceeded the specified value for a certain number of seconds. One major advantage of the Speed of Tape indicator is that it ‘tracks’ the tape in real time so that a trader doesn’t miss important periods of high activity even if he goes away from the terminal.

What are some popular tape-reading software?

Tape reading software helps a trader “easily” spot the shifts in order flow displayed on the electronic tape or time and sales window. There are many tape-reading software out there, but these are some of the popular ones:

  • Jigsaw: You can simplify your tape reading trading strategy with Jigsaw. It helps you learn faster and trade smarter with simple, repeatable trading methods based on real-world professional Order Flow trading techniques.
  • OrderFlowDashPro/AlphaReveal: This can offer the best insight into the order flow, depth, limit order, and buy and sell program activity possible. If you are attempting to day trade futures with traditional Time & Sales and DOM (or even first-generation order flow software), you stand a better chance with the total illumination AlphaReveal provides.

How to Interpret the Time and Sales Window

Tape reading can be very confusing if you don’t know how to interpret the data. It requires quite a bit of practice to get used to understanding the true meaning behind what you are seeing. Reading the tape is situation-specific, unlike in technical analysis where indicators tell you about oversold or overbought levels. Tape reading is about how a stock is trading on a specific day and at a specific price point. Since every stock is different, tape reading requires you to train your eyes to adapt to the situation of the stock you are trading.

Basically, tape reading involves monitoring both price and volume data in the order flow to spot imbalances in demand and supply. Here are the key things to look for:

  • Order sizes: You can tell if there is conviction behind the price action you are witnessing by looking at the amount of orders that are coming through. You would want to see the balance of order flow tips in the direction you want to trade. This is more of a visual signal that your eye becomes accustomed to recognizing with practice.
  • Order speed: Another important aspect of tape reading is the speed of the orders. The magnitude of the orders typically increases when stocks break through support or resistance levels, and the tape typically begins to accelerate. This shows you that there is interest in the stock at this price, rather than just a few retail traders buying or selling at that point.
  • Order condition: The order condition describes which side of the bid/ask spread the deal was completed on. We want to see lots of orders being filled at the ask price when we go long a stock. In contrast, we want to see orders being filled at bid when we go short. This tells us how eager traders are to buy or sell the stock.

Is price action the same as tape reading?

Some might consider tape reading as simply reading the price action but it is more than that. A skilled tape reader doesn’t just check whether the price is rising or falling, he uses volume information to gauge the strength of that move and can even use volume changes to anticipate imminent price changes. So, tape reading is more of studying the market action, rather than just the price action alone.

However, you don’t buy or short a stock because you see the tape speeding up a bit; you must consider support and resistance levels and also combine the data from the tape with price pattern formations. In that case, it is good to combine what the tape is showing you with what the price action is showing on the chart. With the help of tape reading, you can tell when a breakout from a chart pattern is more likely to work and when it is more likely to be a false breakout.

What is Level 2 in day trading?

For exchange-traded assets, such as stocks, Level II is essentially the order book. Orders are placed through a variety of market makers and other market participants. Level II provides you with a thorough understanding of the pricing action by presenting a ranked list of the best bid and ask prices from each of these participants.

If you are a day trader, knowing exactly who has an interest in a stock can be extremely useful. It can help you to gauge the strength of a price move.

How do I learn to read the tape in trading?

You read the tape by studying the order flow, which includes the limit buy and sell orders coming into the market and the executed orders. The order sizes and the manner in which the orders are taken out can tell you where the momentum lies — with the buyers or the sellers.

If the buyers are dominating, it means there is more demand than supply, so the price is likely to go up. On the other hand, if there is more supply than demand, the price is likely to drop.

How do you analyze ticker tape?

You analyze ticker tape by studying the market data it displays, which includes the stock symbol, volume (the number of shares traded), the price per share at which the trade was executed, and whether it closed higher and by which amount.

Tape reading tips

Here are a few tips:

  • Size filter: In most modern platforms that offer T&S, you can change settings to filter order sizes. Without setting the size to a reasonable amount, the tape will be moving much too fast and will be clogged with tiny orders.
  • Combine with chart pattern setups: It is best to use both tape reading and chart analysis. You can use chart reading to identify setups and tape reading for confirmation and entries/exits.

Tape reading example

Let’s say you are a scalper who is skilled in tape reading, and from a stock’s order book, you notice that there are large limit sell orders at a certain price level. This may indicate that the stock will experience significant resistance at these levels, so you may plan to close your long position at that level and book your profit.

Tape reading strategy backtest

The art of tape reading has changed a lot over the last decade. The New York Stock Exchange specialist system was a haven for tape readers, but the specialist was replaced with market makers, and the market makers are not so easy to read as a specialist. We were partially tape readers ourselves from 2001 until 2009 (on NYSE stocks), but it got increasingly more difficult after 2009.

The reason that a market maker is trickier to read is simple: the electronic order book is another beast and much more difficult to find tradable patterns in compared to a single specialist. As a matter of fact, we believe it’s getting increasingly difficult to do tape reading, and it’s very much a futile exercise. Tape reading is a little bit like scalping – please read our take on scalping:

The chances you’ll make it as a tape reader are slim. Short-term trading is close to a zero-sum game, and thus most lose.

Backtesting a tape reading strategy is very difficult. Not only is it difficult to jot down the specific trading rules and setups, but you also need a lot of good data to backtest on. It takes a lot of time and most likely becomes a waste of time.

We believe you stand a much better chance if you save for the long term or backtest swing trading strategies. For example, we offer plenty of trading strategies that have been live for several years.

To show you one example of such a strategy, we show you the results of strategy #81 which is a seasonal trading strategy for stocks:

Tape reading strategy example

The backtest is performed on S&P 500 (SPY) and the 412 trades return on average 0.75% per trade. The annual return is 10.3% which is better than buy and hold despite being invested just 15% of the time and having a “small” drawdown of 23%!

We believe traders would perform better with such a quantitative trading strategy.

Asian Trading Strategies – How To Trade Asian Markets – Rules, Backtest, Returns

asia trading strategy
asia trading strategy

With the world getting increasingly connected online, it is now easier to diversify your investment portfolio into other economies. Asia is home to tens of thousands of investment opportunities; you can choose to invest in anything from safe large-cap stocks in Singapore to high-growth frontier market stocks in Vietnam. But what are Asian trading strategies?

There are different ways to invest in the Asian financial markets. You can invest in exchange-traded funds (ETFs) or directly trade the stocks via international brokers like Interactive Brokers. You can also invest through American Depository Receipts, which trade on the OTC markets and can easily be bought via your broker.

In this post, we take a look at Asian trading strategies, and at the end of the article, we provide you with some backtests.

Related reading:

How can you trade Asian markets?

Here are the four common ways you can trade the Asian markets:

  1. Exchange-traded funds (ETFs): The easiest way to invest in the Asian market is to buy ETFs that track the various markets in Asia, and there are many Asian index ETFs you can invest in. Investing in such index funds offers the advantages of broad diversification at a lower cost than you might otherwise be able to achieve by attempting to build the positions directly.
  2. Depository Receipts: You can buy their depository receipts of Asian stocks in your country of residence. A depositary receipt (DR) is a certificate issued by a bank that represents shares in a foreign company that is traded on a domestic stock exchange. It allows you to hold equity in foreign countries and provides an alternative to trading on an international market. The American depositary receipts (ADRs) trade on the OTC market and can be bought via your broker.
  3. Directly trading the stocks: While purchasing stocks on foreign exchanges is more difficult than purchasing ADRs, there are online brokerages that allow you to buy and sell securities directly on select international markets. One broker that offers access to most stock exchanges around the world is Interactive Brokers. If you are not a client of the broker, you should inquire with your broker about direct access to Asian stocks. That said, investing in single stocks is risky. Most stocks end up practically worthless and you need to know what you are doing.
  4. Asian stock CFDs: While this is not often recommended, you can trade Asian stock CFDs via a CFD broker, such as IG, eToro, and so on. If your interest is just to gain from price movements rather than owning the underlying stocks, this might be a good option. It is best used for short-term trading and speculation, not investing, as it does not offer you the ability to own the asset. We don’t recommend trading or investing in CFDs. We prefer to invest directly in stocks or ETFs (the latter the most).

Asian ETFs

These are some Asian ETFs that trade on US exchanges:

  1. iShares MSCI Emerging Markets Min Vol Factor ETF (EEMV): EEMV gives investors access to stocks in many of the fastest-growing economies in the world by providing exposure to emerging market equities. Because the underlying index includes stocks that have historically displayed low volatility relative to the general market, EEMV may be good for long-term holding.
  2. iShares MSCI South Korea ETF (EWY): EWY provides targeted exposure to the South Korean economy. It is the most liquid and well-liked way to gain exposure to the South Korean economy. Given its specific concentration, EWY is best suited for investors who wish to adjust their exposure to international equities or plan for short-term trading in the market.
  3. iShares MSCI India ETF (INDA): INDA offers exposure to Indian equity markets, which makes it good for investors looking to access the Indian market, an emerging market with tremendous growth potential. Considerable India exposure is a part of many broad-based emerging markets ETFs, but INDA focuses more on large-cap stocks, with just about 70 components in total and a heavy allocation to the top ten holdings.
  4. Vanguard FTSE Pacific ETF (VPL): VPL offers a low-cost option for accessing advanced Asia Pacific economies. It consists almost entirely of developed market exposure, with Japan accounting for most of the portfolio and Australia also making up a significant chunk. The ETF is certainly useful as a short-term trading vehicle for those seeking exposure to advanced Asian economies. While it can potentially be used as a core holding in a longer-term portfolio, it should be noted that VPL offers no exposure to emerging Asian economies. Later in the article we backtest this ETF.
  5. iShares MSCI Taiwan ETF (EWT): EWT offers exposure to Taiwanese equities, and is the most liquid and most popular option for achieving exposure to the quasi-developed economy of Taiwan. You can use it for short-term trading or add it to your long-term portfolio. All major market in Asia has its own ETF.

How many Asian markets can you trade?

On the Asian continent, there are over 35 distinct stock exchanges, providing investors with more options than in any other region of the world. However, access to some of the exchanges is often limited, especially the exchanges in mainland China. The easiest market to access in the Asian region is the Japanese market. Even Warren Buffett and Berkshire Hathaway have invested in Japanese stocks. After the crash in the late 1980s, Japanese stocks were valued cheaply after the year 2000.

In fact, almost any major brokerage firm in the United States or Europe can execute international trades on the Tokyo Stock Exchange (TSE). This is why Japanese stocks are so popular globally. Hong Kong, Singapore, and South Korea are other Asian markets that are easy to access. You may gain access to the Shanghai and Shenzhen exchanges via the Hong Kong Stock Connect. Interactive Brokers allows most retail traders access to these markets.

What are the biggest Asian markets?

Asia is home to some of the biggest financial markets, including the following:

  • Hong Kong Stock Exchange (HKX): Hong Kong is a global city with an important stock exchange that serves as China’s financial gateway to the rest of the world. There are over 2,500 publicly traded companies on the HKX, with a combined market capitalization of USD 6 trillion.
  • Tokyo Stock Exchange (TSE): The Tokyo Stock Exchange is consistently ranked among the world’s largest, with over 2,000 publicly traded companies with combined market capitalizations exceeding $5 trillion.
  • Singapore Stock Exchange (SGX): The Singapore Exchange (SGX) is Southeast Asia’s largest stock exchange. It currently has 776 companies listed and a market capitalization of nearly $800 billion. Not bad for a city-state with a population of approximately six million people.
  • Shanghai Stock Exchange (SHE): More than 2,000 companies are listed on the Shanghai Stock Exchange (SHE), the world’s third-largest stock exchange with a total market capitalization of more than $7 trillion.
  • Korea Exchange (KRX): The Korean stock exchange, which has a market capitalization of more than two trillion US dollars, is home to over 3,000 companies.

When are Asian markets open?

Asian stock exchanges open Monday through Friday from around 9:00 am Local Time (GMT+9:00), except on days that are national holidays. Each nation keeps its own holiday calendar.

When is the Asian trading session (GMT)?

Since the Asian region has multiple big stock exchanges, the exact trading hours will depend on the exchanges you are interested in. The Japanese and South Korean markets are the first to open at 12:00 am GMT, and the session lasts till around 10:00 am GMT when the Indian market closes.

Can you trade Asian pairs (forex)?

Yes, you can trade the currencies of Asian countries against the USD or EUR. For example, you can trade EUR/JPY, USD/JPY, USD/SGD, USD/HKD, USD/KRW, or USD/INR.

Asian trading strategies backtest

How do you trade Asian markets?

We’ll show you one example in this section of the article. We backtest a specific setup with strict trading rules and backtest it.

We backtest the ETF with the ticker code VPL. This ETF has the current exposure as of today:

Asian trading strategy - VPL

As you can see, it has no emerging market exposure.

The first backtest is trading strategy #1, which we have behind a paywall. If we employ those trading rules on VPL, we get the following equity curve:

Asian trading strategies

There are 124 trades, with an average of 0.68% per trade. Even though you are invested just 9% of the time, you beat buy and hold (including dividends): 4.4 vs. 4.3%. Due to the low exposure, max drawdown is only 20% vs. 55% for buy and hold.

Asian trading strategy #2

Let’s make a second backtest: we employ the exact same trading rules as we do in strategy #81 Tuesday trading strategy:

Asian trading strategy

This strategy, which works very well for US stocks, works equally well for Asian stocks: the average gain per trade is 0.89% (98 trades). Even though you are invested less than 5% of the time, you make 4.5% annually, on par with buy and hold.

Please keep in mind that VPL trades US hours. The results might be very different if you use the same strategy on assets trading local time (Asian local time).

Do You Like Backtesting And Want To Write?

want to Backtest
want to Backtest

We are looking for more people that know how to backtest strategies and how to write. The former is more important than the latter!

If you believe this is something for you, please send us a sample/example where you explain a random edge (the edge is not important).

We agree on payment.

Contact Us Here

The Markets Sold Off And Closed At The Lows, Here Is What Has Happened Following That Pattern

For this backtest, we use the IBS indicator that measures where the asset’s close in relation to the price action that week (not day!). This has proven to be a good indicator for stocks because it’s a mean reversion indicator.

We want to find out the following: The markets sold off and closed at the lows, here is what has happened following that pattern.

The formula of IBS is like this:


A low reading indicates a weak ending of the week (or day, month, or whatever time frame you are looking at), and a high reading informs us about a strong end of the week. It oscillates from 1 to 0.

The Markets Sold Off And Closed At The Lows, Here Is What Has Happened Following That Pattern

Let’s backtest the following trading rules:

  • The IBS indicator ends at 0.1 or lower, and
  • We sell after N weeks (1 to 5 weeks).

For S&P 500 (SPY), we get the following table:

The Markets Sold Off And Closed At The Lows, Here Is What Has Happened Following That Pattern

The first column indicates how many weeks we hold. Row 5 gives us the result if we own SPY for 5 weeks after the IBS indicator ended at 0.1 or lower. The average gain over the next 5 weeks is an impressive 1.85%. As you can see, the results are positive for all weeks.

If we exit after 5 weeks the equity curve looks like this:

The Markets Sold Off And Closed At The Lows, (stocks - S&P 500)

What about other assets?

Let’s do the same backtest for bonds (TLT):

The Markets Sold Off And Closed At The Lows (bonds)

The results are pretty good for bonds as well, but it’s a lot more erratic.

Let’s do the same backtest for gold (GLD):

The Markets Sold Off And Closed At The Lows (gold)

Even for gold, the results are positive. However. It’s quite erratic and not tradable, in our opinion.

The Biggest Challenge Traders Face When Backtesting Trading Strategies (Reader Poll)

We believe backtesting is crucial to have consistent success in trading. It makes you disciplined because it forces you to write down specific trading rules. This way, you can see if your strategy has a positive expectancy. We suspect most traders don’t have a positive expectancy because they use anecdotal evidence and focus more on the winners than the losers.

What is the biggest challenge traders face when backtesting trading strategies?

To find out, we conducted a survey on Twitter where we asked what our readers believe is their biggest challenge when backtesting trading strategies. This was the result of our poll/survey:

Perhaps a little surprising, the biggest obstacle is to apply the backtest (or convert) the backtest results to live trading. We assume that this is more a technical issue than a failure to perform live as indicated in the backtest.

Let’s remind you about the challenges of backtesting:

  • Data quality and availability: The quality and availability of historical data are essential for backtesting. Garbage in equals garbage out. Poor data quality can lead to false signals and VERY misleading results.
  • Overfitting or curve-fitting: Overfitting is a common problem in backtesting, where the strategy is optimized too closely to the historical data. This can lead to the strategy performing well in backtesting but underperforming in live trading.
  • Survivorship bias: Survivorship bias is the tendency only to consider the winners and ignore the losers. This can lead to an overestimation of the strategy’s performance.
  • Look-ahead bias: Look-ahead bias is when the trader uses information that was not available at the time of the trade to make decisions about the strategy. This can lead to an inflated performance in backtesting.
  • Backtesting is not a perfect predictor of future performance: No matter how carefully backtested, a trading strategy may not perform well in live trading. This is because market conditions are constantly changing, and many factors cannot be perfectly controlled for in backtesting.
  • Backtesting is a time-consuming process: Backtesting a trading strategy can be time-consuming, especially if the trader is testing multiple strategies or using complex trading algorithms. However, if you don’t want to backtest, we recommend buying some ETFs or mutual funds and ignoring trading.

We remind you that we have a long backtesting guide that might be useful for you.

Best Python Libraries For Algorithmic Trading (Examples)

Libraries are an essential part of Python that makes programming faster and easier for developers. These two qualities are especially relevant in Algorithmic Trading.

That’s why, in this article, we will explore some of the best algorithmic trading libraries in Python, including those to download data, manipulate data, perform technical analysis, and backtest trading strategies.

What is a Python library?

Think of a Python library as a box of tools that contains different sets of ready-made code. This code can be used over and over again in various programs.

This makes it easier and more convenient for programmers because they don’t have to write the same code multiple times for different programs. 

Python libraries are really important, especially in areas like Machine Learning, Data Science, and Algorithmic Trading.

Python Libraries for Downloading Stock Data

The most popular library to download data is yfinance. This library allows users to download the historical data of any stock or ETF from the Yahoo Finance website for free. Additionally, it includes fundamental data such as income statements, trading multiples, and dividends, among others.

It was developed by Ran Aroussi after the official API was taken down on May 15, 2017. If you want to learn more about the functionalities and how to use it check out our article called how to download data for your trading strategy from Yahoo!Finance with Python.

The Pandas Data-Reader library is another famous resource used to download data. It provides functions that extract data from various Internet sources, including Yahoo!Finance, the Federal Reserve Economic Data (FRED), Fama/French data, etc. We have previously covered how to build a trading strategy from FRED data in Python. The linked article shows you an example of how to download data from the FRED website.

We decided to focus on free resources, but keep in mind there are also premium APIs, such as Alpha Vantage and Quandl.

Python Libraries for Data Manipulation and Plotting

Pandas is probably the most popular library in Python (in general). It is a free tool for Python that many people use for data manipulation and analysis. It’s made on top of another library called Numpy, which provides help when dealing with numerical tables and time series. 

Pandas lets you bring in data from different types of files like comma-separated values, JSON, Parquet, SQL databases, and Microsoft Excel. With Pandas, you can also do things like putting data together, changing its shape, picking out specific parts, and making the data neater and more organized. It is kind of the Excel of Python.

This is, for example, a pandas data frame of the SPY historical data from Yahoo Finance:

Best Python Libraries For Algorithmic Trading

Another crucial aspect of data is its visualization, and that’s where Matplotlib enters the game. Matplotlib is a basic plotting library in Python. It allows you to create different charts, including line, scatter, 3-D, and polar plots, among others. For example, the following chart was created using matplotlib and the data frame mentioned above. It shows the daily adjusted close for the SPY since 1993:

Python library example

Python Libraries for Technical Analysis

TA-Lib, short for Technical Analysis Library, stands as an open-source toolkit widely employed for conducting technical analysis of financial data. The library offers over 150 technical indicators and trading functions to recognize trends, gauge momentum, and evaluate the comprehensive market strength and direction.

Another almost identical option is Pandas TA. The library was built on Pandas and Numpy and works similarly to TA-Lib.

Python Libraries for Backtesting

Lastly, we have to mention Python’s specific libraries for backtesting. Although performing a backtest using just pandas is possible, these libraries sometimes provide a deeper analysis of the strategy.

One of the most well-known is Backtrader. Backtrader is an open-source library used for backtesting, strategy visualization, and trading. The library provides many features that facilitate the backtesting process, having specific single lines of code for special functions.

Zipline is another Python library that supports both backtesting and live trading. Although Quantopian, zipline developers, went out of business, thanks to the power of open-source, the library keeps running without problems.

Best Python Libraries for Algorithmic Trading – Conclusion

To sum up, today you learned about the most popular Python libraries for algorithmic trading out there. Although there are hundreds of them, the ones we showed you today are more than enough to start your quant journey backtesting trading strategies.

The Market Opens The Week Lower, Here Is How That Has Played Out (Historically)

The stock market tends to revert to its average price over time. This means that if stock prices move too far above or below their average, they are more likely to move back towards the average in the future. This is because many forces are at work in the market, including buyers and sellers, and these forces tend to balance out over time.

Let’s backtest the following hypothesis: The market opens the week lower, here is how that has played out historically.

When the stock market opens lower on a Monday, we might be tempted to believe it is more likely to close higher on Friday because of mean reversion and long-term tailwind. This is because mean reversion might happen over a week, as investors take profits from stocks that have moved too high and buy stocks that have moved too low.

Obviously, it is essential to note that mean reversion is not a guarantee. The stock market is also influenced by long-term factors, such as economic growth and corporate earnings.

Mean reversion trading strategies can be used to profit from the tendency of stock prices to revert to their mean. These strategies typically involve buying stocks that have fallen below their mean and selling stocks that have risen above their mean.

It is vital to backtest mean reversion trading strategies before using them in live trading. This means testing the strategies on historical data to see how they would have performed.

The Market Opens The Week Lower, Here Is How That Has Played Out (Historically)

Let’s backtest, and we make the following trading rules:

  • Today is Monday,
  • Today’s open is lower than yesterday’s close (normally a Friday, a Thursday if Friday was a non-trading day),
  • If the first two bullet points are true, then buy the open.
  • Sell at the close on Friday (the end of the week) or after 5 trading days.
The Market Opens The Week Lower, Here Is How That Has Played Out (Historically)

The average gain is 0.23%, which is 15% better than any random week.

Worth noting is that only 31% of Mondays open down. You are invested only 31% of the time, thus, the risk-adjusted return is 12.6%, substantially higher than buy and hold.

We changed the trading rules and added the most used trend filter which is the 200-day moving average trend filter (Friday’s close must be above the filter).

We get the following equity curve:

If Monday opens higher, what is the return the rest of the week?

The average gain is 0.22%, but we avoid the worst drawdowns: max is just 15%.

The Market Is Starting The Week Higher, Here Is How That Has Played Out Historically

The stock market has a habit of mean reversion, which means that stock prices tend to return to their average price over time. This is because there are many forces at work in the market, including both buyers and sellers, and these forces tend to balance out over time.

Let’s look at the following scenario: The market is starting the week higher, here is how that has played out historically.

If the week opens higher, will stocks be prone to mean reversion and go lower during the week, despite the long-term tailwind?

However, mean reversion does not happen instantly. It can take days, weeks, or even months for a stock price to revert to its mean. This is why you need to backtest, but mean reversion trading strategies have worked well for stocks over the last three decades.

The Market Is Starting The Week Higher, Here Is How That Has Played Out Historically

Let’s make the following trading rules for S&P 500 (SPY):

  • Today is Monday,
  • Today’s open is higher than yesterday’s close (normally a Friday, a Thursday if Friday was a non-trading day),
  • If the first two bullet points are true, then buy the open.
  • Sell at the close on Friday (the end of the week) or after 5 trading days.

This is very simple to backtest. Here’s the equity curve:

The Market Is Starting The Week Higher, Here Is How That Has Played Out Historically

The average gain is 0.16%, which is less than any random week. The chart shows us that the bull market from 2010 makes it a profitable strategy, perhaps fueled by quantitative easing. However, even in 2022, when the stock market fell, this was a profitable strategy (8% for the year).

What Has Happened The Day AFTER OPEX Day (Options Expiration)? (Backtest)


OPEX, or options expiration, is the day on which stock options contracts expire. Stock options give the holder the right, but not the obligation, to buy or sell a certain number of shares of a stock at a certain price by a certain date. If an option is not exercised by the expiration date, it becomes worthless. You might wonder: What has happened the day AFTER OPEX dayoptions expiration day?

If you want to dig deeper, please read our article, OPEX week anomaly and effect.

OPEX day typically falls on the third Friday of each month in the United States. On OPEX day, options contracts have a lot of trading activity as traders close out their positions or exercise their options. This can lead to increased volatility in the stock market, especially in the stocks that have the most options contracts expiring.

There are a few reasons why OPEX day matters for stocks:

  • Increased volatility: As mentioned above, OPEX day can lead to increased volatility in the stock market. This is because traders are closing out their positions or exercising their options, which can lead to a lot of buying and selling activity. It’s no myth, volatility of the OPEX and quadruple witching days is higher.
  • Pin risk: Pin risk is the risk that a stock price will close at its strike price on OPEX day. This can happen when there are a large number of options contracts expiring at the same strike price. Pin risk can lead to increased volatility and make it difficult for traders to execute their orders. You can read more about OPEX day pin risk here.
  • Gamma squeeze: A gamma squeeze is a situation in which market makers are forced to buy or sell a stock to hedge their exposure to options contracts. This can happen when there is a lot of buying or selling activity in options contracts. Gamma squeezes can lead to sharp movements in stock prices.

Overall, OPEX day is an important event for the stock market. It can lead to increased volatility, pin risk, and gamma squeezes.

What Has Happened The Day After OPEX Day?

Let’s backtest and make the following trading rules:

  • We go long S&P 500 (SPY) at the close of OPEX day.
  • We sell at the close of the day after OPEX day (normally a Monday)

The equity curve for SPY is not very appealing:

What Has Happened The Day After OPEX Day (Options Expiration)?

The average gain is zero, significantly lower than any random day (0.04%).

What about bonds (TLT)?

What Has Happened The Day After OPEX Day

The average gain is a negative 0.03% (any random day is +0.02%).

You might want to consider becoming a Silver member to get the code (and lots of other code and strategies).

If you want the code for OPEX day, you might want to consider becoming a Silver member and get access to lots of code and strategies.

Social Media - Quantified Strategies


Best Picks