SuperAPI AI Directory

chanlun

Data & analytics

View repository

Updated 10-15 22:13

About this skill

Chan Theory Pattern Recognition

Purpose

Price pattern recognition based onChan Zhong Shuo Chantheory. Chan Theory is a technical analysis method based entirely on price structure. Core pipeline:

原始K线 → 去包含处理 → 分型识别 → 笔检测 → 中枢构建 → 买卖点判定

Applicable to any market with OHLCV data (A-shares, cryptocurrencies, futures, etc.).

Core Concepts

Concept Description Detailed Documentation
Fractal (FX) Top fractal: the middle candlestick is the highest; bottom fractal: the middle candlestick is the lowest Fractal
Stroke (BI) A segment of price movement between adjacent top and bottom fractals, the smallest unit Stroke
Center (ZS) A price overlap area formed by at least 3 strokes, the core of a trend Center

Buy/Sell Point System

Buy/Sell Point Meaning Detailed Documentation
First Buy/First Sell The first reversal signal after a trend ends (divergence point) First Buy First Sell
Second Buy/Second Sell Confirmation signal when a pullback after a first buy/first sell does not break the bottom/top Second Buy Second Sell
Third Buy/Third Sell Signal when a pullback after the center moves up/down does not enter the previous center Third Buy Third Sell

Dependency Installation

pip install czsc requests pandas

Quick Start

from czsc import CZSC, RawBar, Freq
from datetime import datetime

# 准备 RawBar 列表(需按时间正序排列)
bars = [
    RawBar(symbol="BTC-USDT", id=0, dt=datetime(2026,1,1),
           freq=Freq.D, open=70000, close=71000,
           high=72000, low=69000, vol=1000, amount=71000000),
    # ... 更多K线
]

# 创建分析器,自动检测分型/笔/中枢
c = CZSC(bars)

# 访问结果
print(c.bi_list)    # 已完成的笔
print(c.bars_ubi)   # 未完成笔中的K线

Available Signal Functions (czsc.signals.cxt)

czsc has 43 built-in Chan Theory signal functions, the core ones are as follows:

Function Description Type
cxt_first_buy_V221126 First buy signal Buy/Sell Point
cxt_first_sell_V221126 First sell signal Buy/Sell Point
cxt_second_bs_V230320 Moving average assisted second buy second sell Buy/Sell Point
cxt_third_bs_V230318 Moving average assisted third buy third sell Buy/Sell Point
cxt_third_buy_V230228 Stroke third buy assistance Buy/Sell Point
cxt_double_zs_V230311 Two-center combination to determine BS1 Center
cxt_three_bi_V230618 Three-stroke pattern classification Pattern
cxt_five_bi_V230619 Five-stroke pattern classification Pattern
cxt_seven_bi_V230620 Seven-stroke pattern classification Pattern
cxt_nine_bi_V230621 Nine-stroke pattern classification Pattern
cxt_eleven_bi_V230622 Eleven-stroke pattern classification Pattern
cxt_bi_base_V230228 BI basic signal (direction/turning point) Basic
cxt_bi_end_V230312 MACD assisted stroke end Auxiliary
cxt_range_oscillation_V230620 Range-bound oscillation determination Auxiliary
cxt_zhong_shu_gong_zhen_V221221 Large and small level center resonance Center

Signal Conventions

  • Signal engine output:1=long,-1=short,0=observe
  • Long conditions: first buy signal or three-stroke upward consolidation divergence or five-stroke quasi-first-buy
  • Short conditions: first sell signal or three-stroke downward consolidation divergence or five-stroke quasi-first-sell
  • Pivot assistance: price near the lower bound of the pivot favors going long, near the upper bound favors going short

Data format

czsc accepts List[RawBar], each RawBar contains:

Field Type Description
symbol str Symbol code
id int Sequence number (starting from 0)
dt datetime Time
freq Freq Frequency:Freq.F1/F5/F15/F30/F60/D/W/M
open float Open price
close float Close price
high float High price
low float Low price
vol float Volume
amount float Turnover

Implementation

Uses the czsc library (v0.9.68+), implemented in pure Python (optional Rust acceleration backend). Supports incremental updates, suitable for real-time analysis.