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.1.tar.gz (69.9 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.1-py3-none-any.whl (71.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ta_patterns-1.1.1.tar.gz
  • Upload date:
  • Size: 69.9 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.1.tar.gz
Algorithm Hash digest
SHA256 f558c394e1d7325445fd3b1ae0aad34baaa75e0ba3155324a271229486061e5c
MD5 0525832d77f919f428475a34ec924aea
BLAKE2b-256 9ea9d7d5d0770e3faab465be9008a367ffe454c7f75f7b9146fda5813538261e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ta_patterns-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 71.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dbf5790f9947f90aa39346829a793703422edd1c1d6b4ae8f12a4f9fea41d99f
MD5 e1d6ca382a9e1868d4376ddfb408beb0
BLAKE2b-256 5a5b27728b077daeb0f7e7eee19723fcdb8fbb14b17e1e53d4a6602e1c82e36f

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