mlfinlab.features.fft

Module implements Fast Fourier Transform (FFT) as presented by Marcos Lopez de Prado and Riccardo Rebonato in the following paper: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2422183

Module Contents

Classes

FFT

Fast Fourier Transform (FTT), transforms a function of time to a function

class FFT(time_series: pandas.DataFrame, min_alpha: float | None = 0.05)

Bases: mlfinlab.features.base_noise_reduction.NoiseReductionMethod

Fast Fourier Transform (FTT), transforms a function of time to a function of frequency. It approximates general functions as linear combinations of periodic functions.

Our FFT class implementation selects the most relevant frequencies on a noisy signal that minimize the Ljung-Box statistic on the sample’s residuals and by consequence extract a signal.

property min_alpha: float

Returns minimum alpha.

Returns:

(float) Probability value of obtaining statistical significance.

property dataframe: pandas.DataFrame

Returns dataframe with original time series and relevant signals generated by the noise reduction method.

Returns:

(pd.DataFrame) Pandas DataFrame with relevant signals.

property signal: numpy.array

Returns main signal generated from noise reduction method.

Returns:

(np.array) Main signal generated from noise reduction method.

__slots__ = ()
generate_signal() numpy.array

Generate signal by applying FFT fit.

Returns:

(np.array) Extracted signal.

get_selected_frequencies() numpy.array

Returns selected frequency values after generating signal.

Returns:

(np.array) Complex type array with with selected frequencies.

get_unused_frequencies() dict

Returns frequencies that were not selected.

All frequencies that were selected for signal generation will not be listed.

Returns:

(dict) Dictionary with unused frequencies.

get_critical_value() Tuple[float, float]

Returns value of Ljung-Box statistic associated with extracting our generated signal from the FFT fit.

Returns:

(Tuple[float, float]) The first value of the Tuple is the Ljung-Box test statistic, the second element is the p-value based on chi-square distribution.

set_min_alpha(min_alpha: float)

Set minimum alpha.

Parameters:

min_alpha – (float) Set minimum alpha to min_alpha.