- 新增 MkDocs + Material 文档站(19 页):入门、CLI、场景示例、FAQ、 Contributing、Changelog、API 参考(mkdocstrings 自动渲染)、内部原理 (架构 / 协议 / 三池路由 / 缓存) - 新增 docs/llms.txt:面向 LLM 的结构化摘要(枚举取值、方法速查、常见陷阱) - 新增 scripts/check_docs.py:校验文档与 api.py 公开方法清单是否漂移 - 新增根 CHANGELOG.md 作为版本记录唯一来源,docs/changelog.md 用 snippet 引入 - 新增 .github/workflows/docs.yml:push main 自动构建并部署 GitHub Pages - 修正文档口径:TdxData 公开方法 53 个(51 数据方法 + start/close); API_REFERENCE 版本号 v0.3.2 -> v0.4.0 - pyproject.toml 新增 docs 依赖组;.gitignore 忽略 site/
1.3 KiB
1.3 KiB
技术指标
纯函数实现,不依赖 pandas / numpy,输入 list[float] 输出 list[float](或元组),
可直接在任意序列上用。也被 TdxData.get_stock_kline_with_indicators() 内部调用。
from pytdxdata import indicator
快速示例
closes = [b.close for b in bars]
macd_line, signal, hist = indicator.macd(closes)
rsi14 = indicator.rsi(closes, period=14)
upper, mid, lower = indicator.boll(closes, period=20, mult=2.0)
指标计算前端数据不足时,结果用 None 占位,长度与输入一致——不会截断,
方便直接和 K 线按下标对齐。
API
::: pytdxdata.indicator options: members_order: source show_root_heading: false show_root_toc_entry: false filters: - "!^_"
与 get_stock_kline_with_indicators 的关系
服务端侧的指标请求走 MAC 通道(get_stock_kline_with_indicators,服务端算好返回);
本地侧的指标走本模块。两者不互相依赖:
| 方式 | 位置 | 适用 |
|---|---|---|
get_stock_kline_with_indicators(...) |
服务端计算 | 想少传数据、服务端算子齐全时 |
pytdxdata.indicator.* |
本地计算 | 需要自定义参数、离线复算、和其他数据源混算 |