Skip to main content

Pure-numpy vectorised library of 300 candlestick and chart pattern detectors with no look-forward bias.

Project description

ta_patterns

Pure-NumPy, fully vectorised library of 300 technical-analysis pattern detectors106 candlestick patterns and 194 chart patterns (short-bar, double/multi, classic-geometric, harmonic, volume, busted). No TA-Lib dependency.

  • Version: 1.1.0
  • Python: ≥ 3.10
  • Dependencies: numpy (required); pandas (optional, for the DataFrame helpers)

Every detector returns a signed int8 array (+1 bullish / -1 bearish / 0 none) and is point-in-time safe — the value at bar i depends only on bars 0..i.

Project layout

.
├── pyproject.toml          # build metadata, deps, pytest config
├── README.md
├── mkdocs.yml              # docs site config
├── run_tests.py            # zero-dependency test runner (pytest fallback)
├── src/
│   └── ta_patterns/        # the package (src layout)
│       ├── __init__.py     # public candlestick API + re-exports
│       ├── _core.py        # shared numeric helpers
│       ├── scanner.py      # scan_all_patterns, net_score_all, batch_all, ...
│       ├── single.py two_bar.py three_bar.py multi_bar.py   # 106 candlesticks
│       └── chart_patterns/ # 194 chart patterns (own pivot engine + scanner)
│           ├── _core.py scanner.py
│           └── short.py double_multi.py classic.py harmonic.py
│               volume.py busted.py
├── tests/                  # pytest suite (also runnable via run_tests.py)
└── docs/                   # full documentation (mkdocs)

Why a chart_patterns/ sub-package? Candlestick detectors work bar-by-bar; chart detectors need a pivot/swing engine, their own scanner, and a separate _core. Keeping them as a sub-package isolates that machinery (and avoids two _core/scanner modules colliding). The two families are still scanned together via scan_all_patterns.

Install

pip install .                  # or: pip install -e ".[test,docs]"

Quickstart

import ta_patterns as tap

sig     = tap.hammer(o, h, l, c)                 # one pattern -> int8 array
signals = tap.scan_all_patterns(o, h, l, c, v=v) # all 300 -> {name: array}
score   = tap.net_score_all(o, h, l, c, v=v)     # net directional score
table   = tap.batch_all(o, h, l, c, v=v)         # wide pandas DataFrame

See docs/ for the full guide:

Tests

pytest               # preferred
python run_tests.py  # zero-dependency fallback

The suite enforces the library's guarantees across the whole catalog: output dtype/length/range, sign-vs-classification, no look-ahead, and textbook firing cases for every pattern family.

Design guarantees

  • No look-forward bias — bar i uses only bars 0..i; pivots use delayed confirmation.
  • Point-in-time at the close — a flag is set on the bar that completes the pattern.
  • Signed int8 output+1 / -1 / 0, always the input length.
  • NumPy / pandas friendly — Series inputs are accepted; the index is stripped automatically.

Notes

  • Elliott Wave patterns are intentionally not implemented — they require subjective multi-level wave labelling that does not reduce to a deterministic OHLC rule.
  • Five chart patterns are volume-based and run only when a volume array is supplied (295 from OHLC alone, 300 with volume).

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

ta_patterns-1.1.0.tar.gz (67.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ta_patterns-1.1.0-py3-none-any.whl (69.2 kB view details)

Uploaded Python 3

File details

Details for the file ta_patterns-1.1.0.tar.gz.

File metadata

  • Download URL: ta_patterns-1.1.0.tar.gz
  • Upload date:
  • Size: 67.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for ta_patterns-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2a73910d5bcf245dfbcc48b04ede1d6998096a7d720b6fdedd739f006d3db27e
MD5 adc2a04cc1bef71aa5575b7cb95440c1
BLAKE2b-256 fc49f8e72832b28aecd3c201c33c03f37433dfe41593913ebcbc1b3fa6bb1cb8

See more details on using hashes here.

File details

Details for the file ta_patterns-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ta_patterns-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 69.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for ta_patterns-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cfd64e93821431e576c5662f1d7ca11617f0404fe42f593ebb48538a624ea60
MD5 d2bf8b1a4cc6a600b40dc6ccb61db048
BLAKE2b-256 2429d235ff83f3d9ba60c25ef7dc453d9dac34354e67a730c4faf53484755912

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