Skip to main content

chan-lun

缠论(缠中说禅理论)量化核心库 —— 分型 / 笔 / 线段 / 中枢 / 背驰 / 三类买卖点, 外加日线信号 → 30 分钟级别的跨级别共振确认(区间套)。

纯 Python 实现,不依赖任何行情接口:输入标准化 bar 序列,输出结构对象与信号。 只依赖 numpy(背驰计算)与 pandas(bars 归一化辅助)。

  • 发行名:chan-lun-core(PyPI 上 chan 已被占用, chan-lun 与现有 chanlun 冲突, 故加 -core 后缀)
  • import 名:chan
  • 许可证:MIT

安装

从 PyPI 安装(打 v* tag 后 CI 自动发布):

pip install chan-lun-core

从 GitHub Release 安装(同样由 CI 自动构建):

pip install https://github.com/lushi78778/chan-lun/releases/download/v0.1.4/chan_lun_core-0.1.4-py3-none-any.whl

或源码安装:

pip install git+https://github.com/lushi78778/chan-lun.git

要求 Python >= 3.6、numpy >= 1.14、pandas >= 0.23 (与聚宽研究环境 3.6.7 / numpy 1.14.6 / pandas 0.23.4 对齐,新版同样兼容)。

数据约定

所有模块的输入/输出都是纯 Python 结构(list of dict / 简单对象), 与数据来源无关:

# 标准 bar: 按时间升序的 dict 列表
bars = [
    {"dt": ..., "open": ..., "high": ..., "low": ..., "close": ..., "volume": ...},
    ...
]

chan.bars.normalize_bars 负责把聚宽 get_price/get_bars 等返回的 DataFrame 转成标准 bar 序列(列名可配置)。

模块与流水线

模块 功能 主要入口
chan.bars 行情归一化 normalize_bars, bars_to_df
chan.fx 包含处理 + 分型 remove_includes, find_fxs
chan.bi 笔识别 find_bis, chan_fx_bi
chan.xd 线段(特征序列两种标准) find_xds, chan_bis_xds
chan.zs 中枢与走势类型 find_zs, classify_trend
chan.bc 背驰(MACD 辅助) macd_series, find_trend_bc, find_pan_bc
chan.bs 三类买卖点 find_buy_points, find_sell_points
chan.cross30 30m 跨级别共振确认 confirm_buy3_30m, confirm_sell3_30m

最小示例(完整管线):

from chan.bars import normalize_bars
from chan.bi import chan_fx_bi
from chan.xd import chan_bis_xds
from chan.zs import find_zs
from chan.bc import macd_series, find_trend_bc
from chan.bs import find_buy_points

bars = normalize_bars(df)          # df -> 标准 bar 列表
bis = chan_fx_bi(bars)             # 分型 -> 笔
xds = chan_bis_xds(bars)           # 笔 -> 线段
zss = find_zs(xds)                 # 线段 -> 中枢
dif, dea, hist = macd_series(bars) # MACD
bc = find_trend_bc(bis, zss, bars) # 趋势背驰
buys = find_buy_points(bis, zss)   # 三类买点

跨级别确认(日线三买 → 30 分钟底背驰 + 守中枢上沿):

from chan.cross30 import confirm_buy3_30m

r = confirm_buy3_30m(bars30, zd=zg_of_day_zs, zg=zg_of_day_zs, signal_dt=...)
# r["status"] in {"confirmed", "weak", "no_exhaustion", "broke", "stale", "no_data"}

兼容性

  • Python 3.6+ 语法(无 walrus / dataclasses / f-string 自描述等 3.7+ 特性)
  • pandas 0.23+ API(无 to_numpy / to_markdown 等新 API)

免责声明

本库仅用于研究与学习,输出不构成任何投资建议。

许可证

MIT,见 LICENSE。

Metadata

Release files for chan-lun-core 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chan-lun-core 0.1.4
File Size Uploaded
chan_lun_core-0.1.4.tar.gz 29.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chan-lun-core 0.1.4
File Interpreter ABI Platform
chan_lun_core-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 54.1 kB

Release files / chan_lun_core-0.1.4.tar.gz

Download URL chan_lun_core-0.1.4.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
be4243a50df25cdb64f9b48615e4034f1314b45980313ff6f72666d4bb6af006
BLAKE2b-256 checksum
How to use checksums
017921f1bb0750f9ab920255ca7de0dfb1f47e3342b2a860acafc3a8230ebb8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / chan_lun_core-0.1.4-py3-none-any.whl

Download URL chan_lun_core-0.1.4-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a728bf7358e36824085fa719bf1949aa98c6c0587681f6308fccd2ea557ddf1f
BLAKE2b-256 checksum
How to use checksums
6fa6750526eca54dba47797f530c75bcd00706cc08cebc9e351f8e47a5430ac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

1.0.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.5

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

This release

0.1.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page