Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:TA Lib Ta lib python Pattern Group API

From Leeroopedia


Knowledge Sources
Domains Technical_Analysis, Pattern_Recognition
Last Updated 2026-02-09 22:00 GMT

Overview

Concrete tool for retrieving the list of all 61 pattern recognition function names via get_function_groups()['Pattern Recognition'] for batch scanning.

Description

The __function_groups__ dict in talib/__init__.py contains a Pattern Recognition key mapping to a list of all 61 CDL function names. Combined with getattr(talib, name) or the Abstract API, this enables dynamic invocation of all pattern functions.

Usage

Use this when building a comprehensive pattern scanner that checks all 61 candlestick patterns.

Code Reference

Source Location

  • Repository: ta-lib-python
  • File: talib/__init__.py
  • Lines: L238-300 (Pattern Recognition group in __function_groups__), L340-345 (get_function_groups)

Signature

# Access pattern recognition functions
patterns = talib.get_function_groups()['Pattern Recognition']
# Returns list of 61 names: ['CDL2CROWS', 'CDL3BLACKCROWS', ..., 'CDLXSIDEGAP3METHODS']

# Dynamic invocation
for name in patterns:
    func = getattr(talib, name)
    result = func(open_prices, high_prices, low_prices, close_prices)

Import

import talib

I/O Contract

Inputs

Name Type Required Description
(none) Registry lookup, no parameters needed

Outputs

Name Type Description
pattern_names list[str] List of 61 CDL function names

Usage Examples

Scan All Patterns

import numpy as np
import talib

# Generate OHLC data
n = 200
close = np.cumsum(np.random.randn(n) * 0.5) + 100
open_p = close + np.random.randn(n) * 0.3
high = np.maximum(open_p, close) + np.abs(np.random.randn(n) * 0.5)
low = np.minimum(open_p, close) - np.abs(np.random.randn(n) * 0.5)

# Scan all 61 patterns
patterns = talib.get_function_groups()['Pattern Recognition']
detected = {}
for name in patterns:
    result = getattr(talib, name)(open_p, high, low, close)
    occurrences = np.count_nonzero(result)
    if occurrences > 0:
        detected[name] = occurrences

print(f"Detected {len(detected)} pattern types:")
for name, count in sorted(detected.items(), key=lambda x: -x[1]):
    print(f"  {name}: {count} occurrences")

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment