Metadata-Version: 2.4
Name: chan-lun-core
Version: 0.1.4
Summary: 缠论(缠中说禅理论)量化核心库: 分型/笔/线段/中枢/背驰/买卖点 + 30 分钟跨级别共振确认, 纯 Python 实现, 仅依赖 numpy/pandas
Author: Chan Contributors
License: MIT License
        
        Copyright (c) 2026 Chan Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/lushi78778/chan-lun
Project-URL: Repository, https://github.com/lushi78778/chan-lun
Keywords: chan,chanlun,缠论,缠中说禅,technical-analysis,quant,stock,kline,trading
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.14
Requires-Dist: pandas>=0.23
Dynamic: license-file

# chan-lun

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

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

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

## 安装

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

```bash
pip install chan-lun-core
```

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

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

或源码安装:

```bash
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 / 简单对象),
与数据来源无关:

```python
# 标准 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` |

最小示例(完整管线):

```python
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 分钟底背驰 + 守中枢上沿):

```python
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](LICENSE)。
