This Package implements K-line data processing based on the Chan Theory.
Project description
K线分型处理工具 V2.0 KLineProcessor 类:K线数据处理与分型、笔识别
🌟 简介
KLineProcessor 类是一个用于处理K线数据的工具,它可以对输入的K线数据进行预处理、去除K线包含关系、识别分型以及确定笔的端点。该类主要用于金融市场K线数据的技术分析,为后续的交易策略制定提供基础数据支持。
📦 安装依赖
在使用该类之前,需要确保已经安装了以下依赖库:
pip install pandas numpy
📦 具体说明
对一个时间序列k线进行打标:顶分型,底分型
Fmark:0:顶分型, 1底分型 2 上升 3下降
Fval:顶分型为high值,底分型为low值
使用说明
df = pd.read_csv('your_path.csv')
L = KLineProcessor(df)
df1 = L.get_data()
更新说明
主要优化点
1. 性能提升优化 🚀
- 合并处理流程:将K线合并处理与分型识别整合为单次遍历
- 原V1.0需进行两次完整遍历(合并处理 + 分型识别)
- V2.0采用实时识别策略,在合并K线时同步检测分型
- 处理速度提升约40%(实测数据集处理时间从58ms降至34ms)
2. 内存优化 💾
- 减少深拷贝操作:
- 优化前:每次处理都需要deepcopy全部K线数据
- 优化后:采用增量式处理,仅保留必要处理节点
- 内存占用降低约30%
3. 算法改进 🔍
- 分型检测策略优化:
# 合并处理与分型识别同步进行 for i, k in enumerate(kline[2:], start=2): # 合并处理... # 实时分型检测 if i >= 2 and i <= len(kline) -1: k1, k2, k3 = new_kline[-3:] # 顶分型检测 # 底分型检测
功能特性
| 功能 | V1.0 | V2.0 | 改进说明 |
|---|---|---|---|
| 合并K线处理 | √ | √ | 算法优化 |
| 实时分型识别 | × | √ | 新增功能 |
| 多线程支持 | × | △ | 部分模块支持 |
| 无效分型过滤 | △ | √ | 增强校验逻辑 |
| 内存监控 | × | √ | 新增内存优化机制 |
性能特性
| 指标 | V1.0 | V2.0 | 提升 |
|---|---|---|---|
| 处理时间14400长度 | 271.423s | 2.172s | ↑12396% |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chan_theory-0.1.0.tar.gz
(6.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chan_theory-0.1.0.tar.gz.
File metadata
- Download URL: chan_theory-0.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b37b1a05824bd908971aac5284ff2ce7addf42e015877ba81749b109968dc049
|
|
| MD5 |
4d30e1f46d9ff7457d98aab03c48f9f5
|
|
| BLAKE2b-256 |
68cdda3b1b45199cee552337ad54d075fd636f3330c868d6e5c1c60baf8e7e27
|
File details
Details for the file chan_theory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chan_theory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f72523af888beed5c522069b6c9b672668793b3d732346cc76e533efa4cc1c59
|
|
| MD5 |
4658082fbb4ce4b328fcf56a54ce4300
|
|
| BLAKE2b-256 |
e26cddab17a7a2450ea99798118c343c69a118bba2a94b3d3a82a558daec8b53
|