In partnership with

Does your car insurance cover what really matters?

Not all car insurance is created equal. Minimum liability coverage may keep you legal on the road, but it often won’t be enough to cover the full cost of an accident. Without proper limits, you could be left paying thousands out of pocket. The right policy ensures you and your finances are protected. Check out Money’s car insurance tool to get the coverage you actually need.

🚀 Your Algo Edge Just Leveled Up — Premium Plans Are Here!🚀

A year in, our Starter, Pro, and Elite Quant Plans are crushing it—members are live-trading bots and booking 1-on-1 wins. Now with annual + lifetime deals for max savings.

Every premium member gets: Full code from every article Private GitHub repos + templates 3–5 deep-dive paid articles/mo Early access + live strategy teardowns

Pick your edge:

  • Starter (€20/mo) → 1 paid article + public repos

  • Builder (€30/mo) → Full code + private repos (most popular)

  • Master (€50/mo) → Two 1-on-1 calls + custom bot built for you

Best deals: 📅 Annual: 2 months FREE 🔒 Lifetime: Own it forever + exclusive perks

First 50 annual/lifetime signups get a free 15-min audit. Don’t wait—the market won’t.

— AlgoEdge Insights Team

1. Introduction

Stocks rise and fall, creating patterns and movements that can feel as unpredictable as ocean waves. Yet, much like how scientists predict the movement of the waves by understanding the currents below, we too can decipher some of the patterns of the stock market with similar tools.

By tapping into the power of the Wavelet Transform, we look beneath the surface, seeking to uncover the deep currents that drive stock prices. This journey is not just about numbers and data; it’s about translating the abstract into the tangible, taking the seemingly erratic behavior of stocks and finding rhythm and reason.

Someone just spent $236,000,000 on a painting. Here’s why it matters for your wallet.

The WSJ just reported the highest price ever paid for modern art at auction.

While equities, gold, bitcoin hover near highs, the art market is showing signs of early recovery after one of the longest downturns since the 1990s.

Here’s where it gets interesting→

Each investing environment is unique, but after the dot com crash, contemporary and post-war art grew ~24% a year for a decade, and after 2008, it grew ~11% annually for 12 years.*

Overall, the segment has outpaced the S&P by 15 percent with near-zero correlation from 1995 to 2025.

Now, Masterworks lets you invest in shares of artworks featuring legends like Banksy, Basquiat, and Picasso. Since 2019, investors have deployed $1.25 billion across 500+ artworks.

Masterworks has sold 25 works with net annualized returns like 14.6%, 17.6%, and 17.8%.

Shares can sell quickly, but my subscribers skip the waitlist:

*Per Masterworks data. Investing involves risk. Past performance not indicative of future returns. Important Reg A disclosures: masterworks.com/cd

2. Wavelet Transform Theory

At its core, a wavelet is a brief oscillation that has its energy concentrated in time, ensuring it’s both short-lived and limited in duration. Imagine striking a drum: the sound produced is intense but fades quickly. This ephemeral characteristic of wavelets makes them immensely suitable to analyze financial signals that are non-stationary (i.e., their statistical properties change over time). Wavelet Transform is akin to providing a microscope to view the intricate details of stock data, capturing both its large trends and minute fluctuations.

2.1 Why Not Fourier Transform?

Many might think, why not just use the Fourier Transform, which is a very popular tool to analyze signals? Fourier Transform breaks down a signal into its constituent sinusoids. However, its Achilles’ heel is its inability to provide both time and frequency information simultaneously. While it can tell us the frequencies present, it’s often oblivious to when they occur. Unlike its Fourier counterpart, Wavelet Transform captures both the frequency and the time, providing a time-frequency representation of the signal.

The full end-to-end workflow is available in a Google Colab notebook, exclusively for paid subscribers of my newsletter. Paid subscribers also gain access to the complete article, including the full code snippet in the Google Colab notebook, which is accessible below the paywall at the end of the article. Subscribe now to unlock these benefits

2.2 The Essence of Wavelet Transform

Mathematically, the Wavelet Transform can be represented as:

Where:

  • W is the result of our comparison, giving us a measure of similarity.

  • (t) represents our stock data.

  • ψ (t) is the chosen wavelet pattern.

In essence, we’re moving our wavelet ψ across the stock data f(t), looking for places where they align well. This gives us the wavelet coefficients W(b) which tell us how strongly the stock data matches the wavelet at each point in time. Put simply, the better the match at any given point, the higher the value of W.

In the presented visualizations, we see the mechanism of the Wavelet Transform as applied to time series data, such as stock prices. On the left, we see a vivid portrayal of the Continuous Wavelet Transform (CWT) applied to stock data. Each frame of the animation displays wavelet coefficients at a different scale, capturing patterns that exist at varying time durations. Wider wavelets detect longer-term trends, while narrower ones focus on short-term fluctuations.

Beside it, on the right, is a depiction of how a wavelet, in this case, a Ricker wavelet, traverses through the stock signal. As the wavelet slides across, it gets multiplied point-by-point with the stock data, and the resultant values are summed up to produce a single coefficient. This ‘correlation’ is plotted below, with the red dot marking the current coefficient value as the wavelet moves. High peaks in the correlation plot indicate locations where the wavelet aligns well with the stock data, capturing specific patterns. In essence, this process is a systematic approach to unearth local patterns within vast time series data, offering a granular perspective that Fourier Transform might miss.

3. Python Implementation

We’ll now delve into the Python implementation of the Wavelet Transform for deriving buy/sell signals from stock data which is what might be of interest to traders and Data Scientist. The code employs the Continuous Wavelet Transform to extract features that can indicate potential buy or sell moments in the stock’s historical data.

3.1 Setting up the Environment

Ensure you have the required Python libraries. If not, they can be installed via pip:

pip install numpy pandas matplotlib yfinance scipy

3.2 Fetching the Stock Data

Using the yfinance library, we can easily fetch stock data for analysis:

import yfinance as yf

ticker = "SIE.DE"
stock_data = yf.download(ticker, start="2018-01-01", end="2023-12-30")

3.3 Applying the Continuous Wavelet Transform (CWT)

The scipy library provides the required functions to compute the CWT using the Ricker wavelet:

from scipy import signal

widths = np.arange(1, 15)
cwt_result = signal.cwt(stock_data['Close'].values, signal.ricker, widths)

3.4 Extracting Buy and Sell Signals

From the computed CWT, positive and negative coefficients can be extracted, indicating upward and downward movements in stock price, respectively.

Copycwt_positive = np.where(cwt_result > 0, cwt_result, 0)
cwt_negative = np.where(cwt_result < 0, cwt_result, 0)
buy_signal = pd.Series(np.sum(cwt_positive, axis=0), index=stock_data.index)
sell_signal = pd.Series(-np.sum(cwt_negative, axis=0), index=stock_data.index)

3.5 Identifying Signal Crossovers

Crossovers between buy and sell signals can potentially indicate trading opportunities.

Copycross_above = (buy_signal >= sell_signal) & (buy_signal.shift(1) < sell_signal.shift(1))
cross_below = (buy_signal <= sell_signal) & (buy_signal.shift(1) > sell_signal.shift(1))

3.6 Visualization

A visual representation can provide a clearer perspective on the buy/sell moments against the stock’s historical data:

import matplotlib.pyplot as plt

plt.figure(figsize=(30, 6))
plt.plot(stock_data.index, stock_data['Close'], label='Close Prices', alpha=0.5)
plt.scatter(stock_data.index[cross_above], stock_data['Close'][cross_above], label='Buy Signal', marker='^', color='g')
plt.scatter(stock_data.index[cross_below], stock_data['Close'][cross_below], label='Sell Signal', marker='v', color='r')
plt.title(f'{ticker} Historical Close Prices with Wavelet Transform Buy and Sell Signals')
plt.legend()
plt.show()

3.7 Complete Python Code

Putting all the code together we get…

logo

Subscribe to our premium content to read the rest.

Become a paying subscriber to get access to this post and other subscriber-only content.

Upgrade

Keep Reading