This paper introduces a trading algorithm that uses a mix of Fourier Transform analysis and GARCH modeling, combined with a confidence scoring system. The strategy works with one-minute data and has a special filter: it only makes a trade if its confidence score is above a certain level. By combining these different analysis methods, the strategy tries to find good trading opportunities and manage risk at the same time.
The Fast Fourier Transform (FFT) part of the strategy looks for repeating patterns in price data to help predict where prices might go next. The GARCH model predicts how much the price is likely to swing (volatility), which is important for figuring out risk and how big a trade should be. The confidence score brings together the signals from both models to judge the quality of a trade, making sure only the best ones are taken.
This paper explains the math behind the strategy, how it was built using QuantConnect, and how it performed in tests. It shows how some advanced math can be used to create a structured way to trade.
Financial markets are complicated. They don't always follow predictable patterns, and old-school technical analysis can miss what's really driving price changes. Because of this, traders have developed more advanced methods using math and statistics.
Our strategy tackles this by using two main tools: Fourier Transform analysis and GARCH modeling. The Fourier Transform breaks down price data to find hidden cycles. GARCH models, on the other hand, are good at understanding how volatility changes over time, since we know that periods of high volatility are often followed by more high volatility.
What makes our approach different is how it combines these tools into a single 'confidence score'. Instead of just trading on a simple signal, the strategy calculates a score based on a few things:
By setting a minimum for this score, the strategy avoids weaker trade setups and only focuses on the ones where everything lines up. The goal is to trade less often, but to make each trade count more, hopefully leading to better returns for the risk taken.
The strategy uses one-minute data, which is good for day trading things like major stock indexes, currencies, or futures. It follows a clear process:
The Fourier Transform is a math tool that breaks down a signal, like a price chart, into the different cycles that make it up. It lets us look at the market in terms of cycles instead of just time. This can help us spot repeating patterns that are hard to see just by looking at a chart.
The Discrete Fourier Transform (DFT) is defined as:
$$X[k] = \sum_{n=0}^{N-1} x[n] \cdot e^{-i2\pi kn/N}$$Where: \(x[n]\) is the input sequence (price data), \(X[k]\) is the output (frequency components), \(N\) is the number of data points, and \(k\) is the index for each frequency.
We use the Fast Fourier Transform (FFT) because it's a much quicker way to do the calculations.
When we use the Fourier Transform on price data, it shows us the main cycles happening in the market. These can be short patterns within a day or longer ones that last for weeks or months. By finding these cycles, we can try to predict where the price might go if the patterns continue. Our process is:
The GARCH model is a popular tool for financial data. It's good at handling two common things we see with market volatility:
The GARCH(p,q) model is defined as:
$$\sigma_t^2 = \omega + \sum_{i=1}^{p} \alpha_i \epsilon_{t-i}^2 + \sum_{j=1}^{q} \beta_j \sigma_{t-j}^2$$Where: \(\sigma_t^2\) is the volatility at time \(t\), \(\epsilon_t\) is the return, and \(\omega\), \(\alpha_i\), and \(\beta_j\) are parameters the model estimates.
In our strategy, we use a simple GARCH(1,1) model. It's usually good enough to get a handle on how volatility behaves for stock returns.
The GARCH model helps our trading strategy in a few ways:
The confidence score is the heart of our strategy. It combines the signals from the Fourier analysis and the GARCH model to create a single score for how good a trade looks. This score is between 0 and 100, where a higher score means we're more confident in the trade.
The confidence score is a weighted mix of a few factors:
$$\text{Confidence Score} = w_{\text{FFT}} \cdot \text{FFT Confidence} + w_{\text{GARCH}} \cdot \text{Volatility Confidence}$$Where the weights for the FFT and GARCH signals are typically 0.6 and 0.4, respectively. The confidence values are derived from the clarity of the Fourier signal and the stability of the volatility.
The strategy will only make a trade if the confidence score is above a set number (we use 70). This acts as a filter, so we only trade when everything looks right. This should hopefully lead to better results for the amount of risk we take.
Additionally, the position size is adjusted based on how high the confidence score is:
$$\text{Position Size} = \text{Base Size} \cdot (0.5 + 0.5 \cdot \frac{\text{Confidence} - \text{Threshold}}{100 - \text{Threshold}})$$This approach also lets us put more money into trades we feel more confident about, while still using a smaller size for trades that just barely meet the cut.
We built this strategy on QuantConnect, an online platform for building and testing trading algorithms. It's useful for a few reasons:
We built our code to follow the standard QuantConnect structure, using the main functions like Initialize() and OnData().
To make the strategy work, we had to build a few custom indicators in QuantConnect:
class FourierTransformIndicator:
def __init__(self, window_size=1024, num_components=10, forecast_periods=5):
# ... (implementation details)
def update(self, price):
# ... (implementation details)
class GARCHModelIndicator:
def __init__(self, window_size=2000, p=1, q=1, forecast_horizon=5):
# ... (implementation details)
def update(self, price):
# ... (implementation details)
class ConfidenceScorer:
def __init__(self, fft_weight=0.6, garch_weight=0.4, threshold=70):
# ... (implementation details)
def calculate_confidence(self, fft_indicator, garch_indicator):
# ... (implementation details)
How much we invest in a trade is a key part of the strategy and is tied directly to the confidence score. We start with a base position size, like 1% of the portfolio, and adjust it based on how high the score is.
The strategy also uses the volatility forecast from the GARCH model to set its stop-loss and take-profit levels automatically.
We tested the strategy using historical data to see how it would have performed in real market conditions. The tests were run on QuantConnect's backtesting platform.
We tested the strategy on SPY, the big S&P 500 ETF, because it's very liquid and gives a good sense of the overall US market. The test ran on data from all of 2023, which included a mix of different market types.
| Parameter | Value | Description |
|---|---|---|
| FFT Window Size | 1024 | Data points for FFT analysis |
| FFT Components | 10 | Number of dominant frequencies to use |
| GARCH Window Size | 2000 | Data points for GARCH model |
| Confidence Threshold | 70 | Minimum score for a trade |
| FFT Weight | 0.6 | Weight of FFT signal in confidence score |
| GARCH Weight | 0.4 | Weight of volatility in confidence score |
| Stop Loss Multiplier | 2.0 | Multiplier for volatility-based stop loss |
| Take Profit Multiplier | 3.0 | Multiplier for volatility-based take profit |
| Position Sizing Factor | 0.01 | Base position size as a percent of portfolio |
Given how the strategy is designed, here's what we'd expect to see from its performance:
In this paper, we've walked through a trading algorithm that combines Fourier analysis, GARCH volatility models, and a confidence score. It works on one-minute data and uses a special filter to only trade when its confidence is high.
The main parts of the strategy are:
We built the strategy in Python on the QuantConnect platform, which gave us the data, testing tools, and ability to trade live. We created custom indicators for each part of the system and brought them all together in the main algorithm.
The new idea here isn't the individual tools themselves, which are well-known, but how they're combined into a confidence score. This allows the strategy to look at trades in a more detailed way, instead of just getting a simple 'buy' or 'sell' signal.
As markets change, strategies that can adapt while still being smart about risk will be more important. The system we've described here is one example of how to build such a strategy, mixing solid math with real-world trading rules.
To be successful in algorithmic trading, it's not enough to just find patterns or predict volatility. The real challenge is putting those ideas together into a complete trading plan that balances risk and reward. This strategy, with its Fourier, GARCH, and confidence score components, is one attempt at solving that challenge and creating a structured way to trade the markets.