Fourier Transforms in Trading¶
Difficulty beginner
Overview¶
Fourier analysis decomposes signals into frequency components, enabling noise filtering, cycle detection, and feature extraction in financial time series.
Discrete Fourier Transform (DFT)¶
Definition¶
where:
x_ntime-domain samples (n=0..N-1) ·X_kcomplex frequency-domain coefficients ·Nsample count ·e^{-2πikn/N}Nth root of unity · the inverse uses+iand is normalized by 1/N. does: maps N time samples into N complex frequency bins and back. The discrete machinery that lets every spectral analysis run on finite, sampled price series.
Fast Fourier Transform (FFT)¶
Efficient O(N log N) algorithm for computing DFT — versus O(N²) for the naive sum. Cooley-Tukey radix-2 is the standard implementation when N is a power of two; for arbitrary N use Bluestein or mixed-radix variants. Every numerical FFT call (NumPy, FFTW, MATLAB) returns coefficients in the same order: DC, positive frequencies, then negative frequencies wrapping around.
Power Spectrum¶
Definition¶
where:
X(f)complex Fourier coefficient at frequency f ·|X(f)|²squared magnitude ·Nsample count for normalization. does: the power spectral density — energy carried by each frequency. Peaks flag dominant cycles; broad flat spectra are consistent with white noise.
Wavelet Transform¶
Advantages over Fourier¶
- Time-frequency localization (Fourier loses time information)
- Multi-resolution analysis
- Better for non-stationary signals
Practical Considerations¶
Windowing¶
FFT assumes periodic signal. Apply window function to reduce spectral leakage — multiply the series by a Hann, Hamming, or Blackman taper before transforming. The taper drives the signal to zero at both ends so the implicit wrap-around in the FFT doesn't create a discontinuity that leaks energy across every frequency bin.
Short-Time Fourier Transform (STFT)¶
For time-varying frequency content, slide a windowed FFT across the series in overlapping chunks. Each chunk yields a local spectrum, producing a 2D time-frequency surface (the spectrogram). Trade-off: short windows give good time resolution but poor frequency resolution; long windows give the opposite. Wavelets generalize this trade-off by varying window length with frequency.
Limitations¶
| Limitation | Issue | Solution |
|---|---|---|
| Non-stationarity | Frequencies change over time | Use STFT or wavelets |
| Edge effects | Artifacts at boundaries | Window, zero-pad |
| Noise | Financial data is noisy | Threshold, filter |
| Interpretation | Spectral peaks may not be meaningful | Validate out-of-sample |
Key Formulas Reference¶
DFT: X_k = Σ x_n e^{-2πikn/N}
Power: P(f) = |X(f)|²/N
Inverse: x_n = (1/N) Σ X_k e^{2πikn/N}
Frequency: f = 1/T (cycles per unit time)
Period: T = 1/f
Next Steps¶
- Formulas Reference — Comprehensive formula collection
- Time Series Analysis — Complementary techniques
- Custom Indicators — Spectral indicators