fft for financial time series

Hi
I'm trying to apply fft() to the spectrum analysis of a financial time series with 2608 (10 years) data with daily frequency... Can anyone suggest me how can I calculate freq and Pyy vectors from fft()?
Regards Marco

 Accepted Answer

Wayne King
Wayne King on 29 Jun 2012
Edited: Wayne King on 29 Jun 2012
Below is an example.
t = 0:2607;
% just an example
% put a sine wave with a period of 120 days and add noise
x = cos(2*pi/120*t)+randn(size(t));
xdft = fft(x);
% because the length is even take the first N/2+1 points
xdft = xdft(1:length(x)/2+1);
Pyy = 1/length(x)*abs(xdft).^2;
% create frequency vector
df = 1/2608;
% frequencies in cycles/day
freq = 0:df:1/2;
plot(freq,10*log10(Pyy));
xlabel('cycles/day'); ylabel('dB/cycle/day');
% find maximum value
[maxval,index] = max(abs(xdft));
% frequency corresponding to maximum value
freq(index)

3 Comments

Hi Wayne King, thanks a lot for your help
bye, Marco
How can you be certain that aliasing has not occurred?
...and why run an fft on financial data - that most certainly isn't even remotely stationary.

Sign in to comment.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!