{"id":13834803,"url":"https://github.com/wukan1986/polars_ta","last_synced_at":"2025-08-10T08:12:33.326Z","repository":{"id":212078049,"uuid":"730653976","full_name":"wukan1986/polars_ta","owner":"wukan1986","description":"Technical Analysis Indicators for polars","archived":false,"fork":false,"pushed_at":"2025-08-02T17:13:15.000Z","size":338,"stargazers_count":183,"open_issues_count":6,"forks_count":44,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-08-02T19:34:06.413Z","etag":null,"topics":["expression","polars","ta","talib"],"latest_commit_sha":null,"homepage":"https://polars-ta.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wukan1986.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-12T11:44:52.000Z","updated_at":"2025-08-02T17:10:30.000Z","dependencies_parsed_at":"2024-01-21T13:25:19.798Z","dependency_job_id":"1af8dab5-20a7-49ed-9a9d-f9bed06ab7a0","html_url":"https://github.com/wukan1986/polars_ta","commit_stats":null,"previous_names":["wukan1986/polars_ta"],"tags_count":51,"template":false,"template_full_name":null,"purl":"pkg:github/wukan1986/polars_ta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wukan1986%2Fpolars_ta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wukan1986%2Fpolars_ta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wukan1986%2Fpolars_ta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wukan1986%2Fpolars_ta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wukan1986","download_url":"https://codeload.github.com/wukan1986/polars_ta/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wukan1986%2Fpolars_ta/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269693593,"owners_count":24460248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expression","polars","ta","talib"],"created_at":"2024-08-04T14:00:52.409Z","updated_at":"2025-08-10T08:12:33.297Z","avatar_url":"https://github.com/wukan1986.png","language":"Python","funding_links":[],"categories":["Libraries/Packages/Scripts"],"sub_categories":["Polars plugins"],"readme":"# polars_ta\n\nTechnical Indicator Operators Rewritten in `polars`.\n\nWe provide wrappers for some functions (like `TA-Lib`) that are not `pl.Expr` alike.\n\n## How to Install\n\n### Using `pip`\n\n```commandline\npip install -i https://pypi.org/simple --upgrade polars_ta\npip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade polars_ta  # Mirror in China\n```\n\n### Build from Source\n\n```commandline\ngit clone --depth=1 https://github.com/wukan1986/polars_ta.git\ncd polars_ta\npython -m build\ncd dist\npip install polars_ta-0.1.2-py3-none-any.whl\n```\n\n### How to Install TA-Lib\n\nNon-official `TA-Lib` wheels can be downloaded from `https://github.com/cgohlke/talib-build/releases`\n\n## Usage\n\nSee `examples` folder.\n\n```python\n# We need to modify the function name by prefixing `ts_` before using them in `expr_coodegen`\nfrom polars_ta.prefix.tdx import *\n# Import functions from `wq`\nfrom polars_ta.prefix.wq import *\n\n# Example\ndf = df.with_columns([\n    # Load from `wq`\n    *[ts_returns(CLOSE, i).alias(f'ROCP_{i:03d}') for i in (1, 3, 5, 10, 20, 60, 120)],\n    *[ts_mean(CLOSE, i).alias(f'SMA_{i:03d}') for i in (5, 10, 20, 60, 120)],\n    *[ts_std_dev(CLOSE, i).alias(f'STD_{i:03d}') for i in (5, 10, 20, 60, 120)],\n    *[ts_max(HIGH, i).alias(f'HHV_{i:03d}') for i in (5, 10, 20, 60, 120)],\n    *[ts_min(LOW, i).alias(f'LLV_{i:03d}') for i in (5, 10, 20, 60, 120)],\n\n    # Load from `tdx`\n    *[ts_RSI(CLOSE, i).alias(f'RSI_{i:03d}') for i in (6, 12, 24)],\n])\n```\n\nWhen both `min_samples` and `MIN_SAMPLES` are set, `min_samples` takes precedence. default value is `None`.\n\n```python\nimport polars_ta\n\n# Global settings. Priority Low\npolars_ta.MIN_SAMPLES = 1\n\n# High priority\nts_mean(CLOSE, 10, min_samples=1)\n```\n\n## How We Designed This\n\n1. We use `Expr` instead of `Series` to avoid using `Series` in the calculation. Functions are no longer methods of class.\n2. Use `wq` first. It mimics `WorldQuant Alpha` and strives to be consistent with them.\n3. Use `ta` otherwise. It is a `polars`-style version of `TA-Lib`. It tries to reuse functions from `wq`.\n4. Use `tdx` last. It also tries to import functions from `wq` and `ta`.\n5. We keep the same signature and parameters as the original `TA-Lib` in `talib`.\n6. If there is a naming conflict, we suggest calling `wq`, `ta`, `tdx`, `talib` in order. The higher the priority, the closer the implementation is to `Expr`.\n\n## Comparison of Our Indicators and Others\n\nSee [compare](compare.md)\n\n## Handling Null/NaN Values\n\nSee [nan_to_null](nan_to_null.md)\n\n## Debugging\n\n```commandline\ngit clone --depth=1 https://github.com/wukan1986/polars_ta.git\ncd polars_ta\npip install -e .\n```\n\nNotice:\nIf you have added some functions in `ta` or `tdx`, please run `prefix_ta.py` or `prefix_tdx.py` inside the `tools` folder to generate the corrected Python script (with the prefix added).\nThis is required to use in `expr_codegen`.\n\n## Reference\n\n- https://github.com/pola-rs/polars\n- https://github.com/TA-Lib/ta-lib\n- https://github.com/twopirllc/pandas-ta\n- https://github.com/bukosabino/ta\n- https://github.com/peerchemist/finta\n- https://github.com/wukan1986/ta_cn\n- https://support.worldquantbrain.com/hc/en-us/community/posts/20278408956439-从价量看技术指标总结-Technical-Indicator-\n- https://platform.worldquantbrain.com/learn/operators/operators\n\n# polars_ta\n\n基于`polars`的算子库。实现量化投研中常用的技术指标、数据处理等函数。对于不易翻译成`Expr`的库（如：`TA-Lib`）也提供了函数式调用的封装\n\n## 安装\n\n### 在线安装\n\n```commandline\npip install -i https://pypi.org/simple --upgrade polars_ta  # 官方源\npip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade polars_ta  # 国内镜像源\n```\n\n### 源码安装\n\n```commandline\ngit clone --depth=1 https://github.com/wukan1986/polars_ta.git\ncd polars_ta\npython -m build\ncd dist\npip install polars_ta-0.1.2-py3-none-any.whl\n```\n\n### TA-Lib安装\n\nWindows用户不会安装可从`https://github.com/cgohlke/talib-build/releases` 下载对应版本whl文件\n\n## 使用方法\n\n参考`examples`目录即可，例如：\n\n```python\n# 如果需要在`expr_codegen`中使用，需要有`ts_`等前权，这里导入提供了前缀\nfrom polars_ta.prefix.tdx import *\n# 导入wq公式\nfrom polars_ta.prefix.wq import *\n\n# 演示生成大量指标\ndf = df.with_columns([\n    # 从wq中导入指标\n    *[ts_returns(CLOSE, i).alias(f'ROCP_{i:03d}') for i in (1, 3, 5, 10, 20, 60, 120)],\n    *[ts_mean(CLOSE, i).alias(f'SMA_{i:03d}') for i in (5, 10, 20, 60, 120)],\n    *[ts_std_dev(CLOSE, i).alias(f'STD_{i:03d}') for i in (5, 10, 20, 60, 120)],\n    *[ts_max(HIGH, i).alias(f'HHV_{i:03d}') for i in (5, 10, 20, 60, 120)],\n    *[ts_min(LOW, i).alias(f'LLV_{i:03d}') for i in (5, 10, 20, 60, 120)],\n\n    # 从tdx中导入指标\n    *[ts_RSI(CLOSE, i).alias(f'RSI_{i:03d}') for i in (6, 12, 24)],\n])\n```\n\n当`min_samples`和`MIN_SAMPLES`都设置时，以`min_samples`为准，默认值为`None`\n\n```python\nimport polars_ta\n\n# 全局设置。优先级低\npolars_ta.MIN_SAMPLES = 1\n\n# 指定函数。优先级高\nts_mean(CLOSE, 10, min_samples=1)\n\n```\n\n## 设计原则\n\n1. 调用方法由`成员函数`换成`独立函数`。输入输出使用`Expr`，避免使用`Series`\n2. 优先实现`wq`公式，它仿`WorldQuant Alpha`公式，与官网尽量保持一致。如果部分功能实现在此更合适将放在此处\n3. 其次实现`ta`公式，它相当于`TA-Lib`的`polars`风格的版本。优先从`wq`中导入更名\n4. 最后实现`tdx`公式，它也是优先从`wq`和`ta`中导入\n5. `talib`的函数名与参数与原版`TA-Lib`完全一致\n6. 如果出现了命名冲突，建议调用优先级为`wq`、`ta`、`tdx`、`talib`。因为优先级越高，实现方案越接近于`Expr`\n\n## 指标区别\n\n请参考[compare](compare.md)\n\n## 空值处理\n\n请参考[nan_to_null](nan_to_null.md)\n\n## 开发调试\n\n```commandline\ngit clone --depth=1 https://github.com/wukan1986/polars_ta.git\ncd polars_ta\npip install -e .\n```\n\n注意：如果你在`ta`或`tdx`中添加了新的函数，请再运行`tools`下的`prefix_ta.py`或`prefix_tdx.py`，用于生成对应的前缀文件。前缀文件方便在`expr_codegen`中使用\n\n## 文档生成\n\n```commandline\npip install -r requirements-docs.txt\nmkdocs build\n```\n\n文档生成在`site`目录下，其中的`llms-full.txt`可以作为大语言模型的知识库导入。\n\n也可以通过以下链接导入：\nhttps://polars-ta.readthedocs.io/en/latest/llms-full.txt\n\n## 提示词\n由于`llms-full.txt`信息不适合做提示词，所以`tools/prompt.py`提供了生成更简洁算子清单的功能。\n\n用户也可以直接使用`prompt.txt`(欢迎提示词工程专家帮忙改进，做的更准确)\n\n## 参考\n\n- https://github.com/pola-rs/polars\n- https://github.com/TA-Lib/ta-lib\n- https://github.com/twopirllc/pandas-ta\n- https://github.com/bukosabino/ta\n- https://github.com/peerchemist/finta\n- https://github.com/wukan1986/ta_cn\n- https://support.worldquantbrain.com/hc/en-us/community/posts/20278408956439-从价量看技术指标总结-Technical-Indicator-\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwukan1986%2Fpolars_ta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwukan1986%2Fpolars_ta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwukan1986%2Fpolars_ta/lists"}