Skip to content

Python library to perform fractional differentiation of time-series, a la "Advances in Financial Machine Learning" by M. Prado.

License

Notifications You must be signed in to change notification settings

zjmyue/fracdiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fracdiff

version Build Status codecov dl LICENSE

Fractional differentiation of time-series.

spx

Installation

$ pip install fracdiff

Features

  • Perform fractional differentiation of time-series
  • Scikit-learn-like API

What is fractional differentiation?

See M. L. Prado, "Advances in Financial Machine Learning".

How to use

Open In Colab

Fractional differentiation

A transformer class Fracdiff performs fractional differentiation by its method transform. The following example gives 0.5th differentiation of S&P 500.

from fracdiff import Fracdiff

spx = ...  # Fetch 1d array of S&P 500 historical price

fracdiff = Fracdiff(0.5)
spx_diff = fracdiff.transform(spx)

The result looks like this:

spx

Differentiation while preserving memory

A transformer class StationaryFracdiff finds the minumum order of fractional differentiation that makes time-series stationary.

from fracdiff import StationaryFracdiff

nky = ...  # Fetch 1d array of Nikkei 225 historical price

statfracdiff = StationaryFracdiff()
statfracdiff.fit(nky)

statfracdiff.order_
# 0.23

Differentiated time-series with this order is obtained by subsequently applying transform method. This series is interpreted as a stationary time-series keeping the maximum memory of the original time-series.

nky_diff = statfracdiff.transform(nky)  # same with Fracdiff(0.23).transform(nky)

The method fit_transform carries out fit and transform at once.

nky_diff = statfracdiff.fit_transform(nky)

The result looks like this:

nky

Other examples are provided here.

Example solutions of exercises in Section 5 of "Advances in Financial Machine Learning" are provided here.

References

About

Python library to perform fractional differentiation of time-series, a la "Advances in Financial Machine Learning" by M. Prado.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published