Skip to content

Latest commit

 

History

History
91 lines (56 loc) · 2.65 KB

README.md

File metadata and controls

91 lines (56 loc) · 2.65 KB

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