Skip to main content

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:

Plot

Project details


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 details)

Uploaded Source

File details

Details for the file npzigzag-0.3.tar.gz.

File metadata

  • Download URL: npzigzag-0.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

File hashes

Hashes for npzigzag-0.3.tar.gz
Algorithm Hash digest
SHA256 1eff9688b9a068e45d34fcad815adfd202fd1ac225b55a8b25a5231038350a1c
MD5 d21f27a9c2165d7ce0344ac7a63f14a9
BLAKE2b-256 44db2b2200e7179e88d86c27e00ad607e3f7220961cafb4d6fbe6d01cbcebc13

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page