Vanilla numpy implementation of zigzag indicator.
Project description
npzigzag
This is a simple numpy implementation of a zigzag indicator. It's only dependencies are pandas and numpy.
Usage
pip install npzigzag
from npzigzag import core as zz
This package has one method:
core.zigzag(X, pc, include_first = True)
Parameters:
- X: pd.Series or np.ndarray or list
- Main data to compute the indicator on.
- pc: float
- Percentage change treshold. This indicates the minimum jump the timeseries has to make before a pivot is recognized in the zigzag indicator.
- include_first: bool
- Indicates wether or not to add the first observation of X as a pivot point,
Returns:
- pivot_indices: np.ndarray if X is np.ndarray or list, pd.Int64Index if X is pd.Series
- Array with indices of zigzag pivot points.
Example:
from npzigzag import core as zz
import numpy as np
X = np.cumprod(1 + np.random.randn(100)/100)
zz_pivots = zz.zigzag(X,0.02, False)
plt.plot(X, '--')
plt.plot(zz_pivots, X[zz_pivots])
plt.scatter(zz_pivots, X[zz_pivots])
Ouputs:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
npzigzag-0.3.tar.gz
(2.9 kB
view hashes)