0
$\begingroup$

I have obtained daily close price stock data ( and transformed them to logarithmic returns series data) from a Stock Exchange between 2 financial years, and I wish to generate a power spectral density to study its behaviour.

I work on Python , I went to the documentation of Scipy.Signal.Welch : https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.welch.html#r34b375daf612-1

Under parameter documentation it is written : fs: float, optional Sampling frequency of the x time series. Defaults to 1.0

I can not figure a way out to find a sampling frequency for the daily frequency financial time series data which I have. (my time series data is daily date indexed i.e. 12/1/2023 is the date and corresponding close price value is attached.)

Also if possible could the experts on this forum explain the parameters mentioned in documentation mean : window , nperseg, noverlap and what should be their recommended settings values for daily frequency financial time series data and returns series data.

$\endgroup$

1 Answer 1

0
$\begingroup$

Since your data is the daily fluctuations your sampling rate would be 1 sample/day assuming you are working with contiguous trading days. It really doesn't matter what rate you use, it just normalizes the frequency axis in the resulting power spectral density (PSD): The PSD extends to $\pm 0.5 f_s$ where $f_s$ is the sampling rate in any units you choose. So if you let it proceed with the default of $f_s=1$ (which is consistent with a normalized sampling rate of 1 sample per cycle) then the PSD horizontal axis will extend from -0.5 to +0.5 for a two-sided spectrum, or 0 to +0.5 for a one-sided spectrum (since for real data the negative side would be redundant so needn't be shown).

As for the terms window, nperseg and noverlap, please refer to this post which details the benefit of using the Welch method over a single FFT for computing a power spectral density (the primary benefit of using Welch in the first place is to provide a power spectral density estimate with less noise in the resulting estimates of the power density at each frequency location). The window length sets the resolution bandwidth used for the measurement: a longer window has tighter resolution bandwidth but then results in less blocks to average for reducing the noise. For complete details on this and the effect of overlap which those parameters set, read this paper by fred harris.

I've also found the Allan Deviation an interesting tool for analyzing financial prices, and with that confirmed in many cases that the closing daily price was a random walk process once the linear growth trend was removed. (If we flipped a coin at the end of each day and stepped left or right based on that result, it would also be a random walk process specifically).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.