functions package#

Submodules#

functions.detrend module#

Detrend models.

class functions.detrend.BSplinesDetrend(interval_length: int = 10, degree: int = 3)[source]#

Bases: BaseDetrend

fit(y: ndarray | DataFrame) None[source]#

Fit BSplines to price series

Parameters:

y (np.ndarray | pd.DataFrame) – Price series

class functions.detrend.BaseDetrend(method_name: str)[source]#

Bases: object

Base class for all detrend models.

fancy_plot(xticklabels: Index | None = None) None[source]#

Plot two graphs:

  1. the original data and its fitted trend curve;

  2. the detrended data

Parameters:

xticklabels (pd.core.indexes.base.Index | None, optional) – the date index of the imported financial data. Defaults to None.

predict(y: ndarray) ndarray[source]#

_summary_

Parameters:

y (np.ndarray) – 1 dimensional array of same length as y_original

Returns:

detrended values, 1 dimensional array of length len(y)

Return type:

np.ndarray

class functions.detrend.ExponentialMADetrend(alpha: float = 0.05)[source]#

Bases: BaseDetrend

fit(y: ndarray | DataFrame) ndarray[source]#

Returns fitted values with the exponential mobile average method

class functions.detrend.LinearMADetrend(window: int = 100)[source]#

Bases: BaseDetrend

fit(y: ndarray | DataFrame) ndarray[source]#

Returns fitted values with the linear mobile average method

class functions.detrend.LinearRegressionDetrend[source]#

Bases: BaseDetrend

fit(y: ndarray | DataFrame) ndarray[source]#

_summary_

Parameters:

y (np.ndarray) – time series 1 dimensional array

class functions.detrend.PolynomialRegressionDetrend(order: int = 3, n_segments: int = 5)[source]#

Bases: BaseDetrend

fit(y: ndarray | DataFrame) ndarray[source]#

_summary_

Parameters:

y (np.ndarray) – time series 1 dimensional array

functions.detrend_fancy_plot module#

functions.detrend_fancy_plot._fancy_plot(y_original: ndarray | DataFrame, y_fitted: ndarray, y_detrend: ndarray, fitted_parameters: dict, xticklabels: Index | None = None, method_name: str = '') None[source]#

Plot two graphs: the original data and its fitted trend curve; the detrended data

Parameters:

xticklabels (pd.core.indexes.base.Index | None, optional) – the date index of the imported financial data. Defaults to None.

functions.write_detrend_data module#

Module contents#