24ae90d4e2  

Code_Python  
LICENSE  
README.md  
Result_Examples.pdf 
README.md
Signal Filtering and Generation of Synthetic TimeSeries
Reference

John F. Ehlers, "Cycle Analytics for Traders: Advanced Technical Trading Concepts".

D. Prichard and J. Theiler, "Generating surrogate data for time series with several simultaneously measured variables".

H. Vinod and J. LopezdeLacalle, "Maximum entropy bootstrap for time series: the meboot R package".
Characteristics
 The code has been written and tested in Python 3.7.7.
 Implementation of several digital signal filters and functions for the generation of synthetic (surrogate) timeseries.
 Filters (filters.py):
 Generic Generic filter.
 SMA Simple moving average.
 EMA Exponential moving average.
 WMA Weighted moving average.
 MSMA Modified simple moving average.
 MLSQ Modified leastsquares quadratic.
 ButterOrig Butterworth original filter.
 ButterMod Butterworth modified filter.
 SuperSmooth Supersmoother filter.
 GaussLow Gauss low pass filter.
 GaussHigh Gauss high pass filter.
 BandPass Bandpass filter.
 BandStop Bandstop filter.
 ZEMA1 Zerolag EMA (type 1).
 ZEMA2 Zerolag EMA (type 2).
 InstTrend Instantaneous trendline.
 SincFilter Sinc function filter.
 Decycler Decycler filter.
 DecyclerOsc Decycle oscillator.
 ABG Alphabetagamma filter.
 Kalman Onedimensional steadystate Kalman filter.
 Synthetic timeseries (synthetic.py):
 synthetic_wave Generates multisine wave given periods, amplitudes, and phases.
 synthetic_sampling Generates surrogates using randomizedsampling (bootstrap) with or without replacement.
 synthetic_FFT Generates surrogates using the phaserandomized Fouriertransform algorithm.
 synthetic_MEboot Generates surrogates using the maximum entropy bootstrap algorithm.
 File filters.py includes also functions to plot the filter signal, frequency response, and group delay.
 File synthetic.py includes also functions to differentiate, integrate, normalize, and scale the discrete timeseries.
 Usage: python test.py example.
Main Parameters
example
Name of the example to run (Filters, Kalman, FFT_boot, ME_boot, Response).
data_file
File with the dataset (csv format). The extension is added automatically.
X
Dataset to filter/timeseries (input). It must be a 1D array, i.e. of shape (:, )
, (:, 1)
, or (1, :)
.
b
Transfer response coefficients (numerator).
a
Transfer response coefficients (denominator).
Y
Filtered dataset (output).
X_synt
Surrogate/synthetic generated timeseries (output).
n_reps
Number of surrogates/synthetic timeseries to generate.
Examples
There are five examples (all of them use the dataset in spx.csv). The results are shown here.

Filter Example showing filtering using an EMA, a Butterworth modified filter, and a type 2 Zerolag EMA.

Kalman Example showing filtering using the three types of Kalman filter (alpha, alphabeta, and alphabetagamma).

FFT_boot Example showing the generation of surrogates timeseries using the Fouriertransform algorithm and discrete differences.

ME_boot Example showing the generation of surrogates timeseries using the maximum entropy bootstrap algorithm and discrete differences.

Response Example showing the frequency response and lag/group delay for a bandpass filter.