Showing preview only (470K chars total). Download the full file or copy to clipboard to get everything.
Repository: wukan1986/polars_ta
Branch: main
Commit: f3097d5ac93d
Files: 150
Total size: 392.1 KB
Directory structure:
gitextract_uz7e5vob/
├── .github/
│ └── workflows/
│ └── python-publish.yml
├── .gitignore
├── .readthedocs.yaml
├── LICENSE
├── README.md
├── compare.md
├── deprecated/
│ ├── demo_ta1.py
│ ├── demo_ta2.py
│ ├── helper.py
│ ├── pandas_.py
│ └── wrapper.py
├── docs/
│ ├── index.md
│ ├── ta/
│ │ ├── index.md
│ │ ├── momentum.md
│ │ ├── operators.md
│ │ ├── overlap.md
│ │ ├── price.md
│ │ ├── statistic.md
│ │ ├── transform.md
│ │ ├── volatility.md
│ │ └── volume.md
│ ├── talib/
│ │ └── index.md
│ ├── tdx/
│ │ ├── arithmetic.md
│ │ ├── choice.md
│ │ ├── energy.md
│ │ ├── logical.md
│ │ ├── moving_average.md
│ │ ├── over_bought_over_sold.md
│ │ ├── pattern.md
│ │ ├── pattern_feature.md
│ │ ├── pressure_support.md
│ │ ├── reference.md
│ │ ├── statistic.md
│ │ ├── times.md
│ │ ├── trend.md
│ │ ├── trend_feature.md
│ │ └── volume.md
│ └── wq/
│ ├── arithmetic.md
│ ├── cross_sectional.md
│ ├── half_life.md
│ ├── logical.md
│ ├── preprocess.md
│ ├── time_series.md
│ ├── transformational.md
│ └── vector.md
├── examples/
│ ├── alpha101.py
│ └── demo_ta3.py
├── mkdocs.yml
├── nan_to_null.md
├── point_in_time.md
├── polars_ta/
│ ├── __init__.py
│ ├── _version.py
│ ├── candles/
│ │ ├── __init__.py
│ │ ├── cdl1.py
│ │ ├── cdl1_limit.py
│ │ └── cdl2.py
│ ├── labels/
│ │ ├── __init__.py
│ │ ├── _nb.py
│ │ └── future.py
│ ├── noise.py
│ ├── performance/
│ │ ├── __init__.py
│ │ ├── drawdown.py
│ │ └── returns.py
│ ├── prefix/
│ │ ├── __init__.py
│ │ ├── cdl.py
│ │ ├── labels.py
│ │ ├── reports.py
│ │ ├── ta.py
│ │ ├── talib.py
│ │ ├── tdx.py
│ │ ├── vec.py
│ │ └── wq.py
│ ├── reports/
│ │ ├── __init__.py
│ │ └── cicc.py
│ ├── ta/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── momentum.py
│ │ ├── operators.py
│ │ ├── overlap.py
│ │ ├── price.py
│ │ ├── statistic.py
│ │ ├── transform.py
│ │ ├── volatility.py
│ │ └── volume.py
│ ├── talib/
│ │ ├── README.md
│ │ └── __init__.py
│ ├── tdx/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── _chip.py
│ │ ├── _nb.py
│ │ ├── _slow.py
│ │ ├── arithmetic.py
│ │ ├── choice.py
│ │ ├── energy.py
│ │ ├── logical.py
│ │ ├── moving_average.py
│ │ ├── over_bought_over_sold.py
│ │ ├── pattern.py
│ │ ├── pattern_feature.py
│ │ ├── pressure_support.py
│ │ ├── reference.py
│ │ ├── statistic.py
│ │ ├── times.py
│ │ ├── trend.py
│ │ ├── trend_feature.py
│ │ └── volume.py
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── factor.py
│ │ ├── functions.py
│ │ ├── numba_.py
│ │ ├── pit.py
│ │ └── withs.py
│ └── wq/
│ ├── __init__.py
│ ├── _nb.py
│ ├── _slow.py
│ ├── arithmetic.py
│ ├── cross_sectional.py
│ ├── half_life.py
│ ├── logical.py
│ ├── preprocess.py
│ ├── time_series.py
│ ├── transformational.py
│ └── vector.py
├── prompt.txt
├── pyproject.toml
├── requirements-docs.txt
├── requirements.txt
├── setup.py
├── tests/
│ ├── numba_test.py
│ ├── pit_test.py
│ ├── ta/
│ │ ├── test_momentum.py
│ │ ├── test_operators.py
│ │ ├── test_overlap.py
│ │ ├── test_statistic.py
│ │ ├── test_volatility.py
│ │ └── test_volume.py
│ ├── tdx/
│ │ ├── chip_test.py
│ │ ├── test_reference.py
│ │ └── test_statistic.py
│ └── wq/
│ ├── test_arithmetic.py
│ └── test_time_series.py
├── thinking_about_TA.md
└── tools/
├── README.md
├── codegen_talib.py
├── prefix.py
├── prefix_ta.py
├── prefix_talib.py
├── prefix_tdx.py
├── prefix_vec.py
└── prompt.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/python-publish.yml
================================================
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
================================================
FILE: .readthedocs.yaml
================================================
# Read the Docs configuration file for MkDocs projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
mkdocs:
configuration: mkdocs.yml
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements-docs.txt
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2023 wukan
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.
================================================
FILE: README.md
================================================
# polars_ta
Technical Indicator Operators Rewritten in `polars`.
We provide wrappers for some functions (like `TA-Lib`) that are not `pl.Expr` alike.
## How to Install
### Using `pip`
```commandline
pip install -i https://pypi.org/simple --upgrade polars_ta
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade polars_ta # Mirror in China
```
### Build from Source
```commandline
git clone --depth=1 https://github.com/wukan1986/polars_ta.git
cd polars_ta
python -m build
cd dist
pip install polars_ta-0.1.2-py3-none-any.whl
```
### How to Install TA-Lib
Non-official `TA-Lib` wheels can be downloaded from `https://github.com/cgohlke/talib-build/releases`
## Usage
See `examples` folder.
```python
# We need to modify the function name by prefixing `ts_` before using them in `expr_coodegen`
from polars_ta.prefix.tdx import *
# Import functions from `wq`
from polars_ta.prefix.wq import *
# Example
df = df.with_columns([
# Load from `wq`
*[ts_returns(CLOSE, i).alias(f'ROCP_{i:03d}') for i in (1, 3, 5, 10, 20, 60, 120)],
*[ts_mean(CLOSE, i).alias(f'SMA_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_std_dev(CLOSE, i).alias(f'STD_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_max(HIGH, i).alias(f'HHV_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_min(LOW, i).alias(f'LLV_{i:03d}') for i in (5, 10, 20, 60, 120)],
# Load from `tdx`
*[ts_RSI(CLOSE, i).alias(f'RSI_{i:03d}') for i in (6, 12, 24)],
])
```
When both `min_samples` and `MIN_SAMPLES` are set, `min_samples` takes precedence. default value is `None`.
```python
import polars_ta
# Global settings. Priority Low
polars_ta.MIN_SAMPLES = 1
# High priority
ts_mean(CLOSE, 10, min_samples=1)
```
## How We Designed This
1. We use `Expr` instead of `Series` to avoid using `Series` in the calculation. Functions are no longer methods of class.
2. Use `wq` first. It mimics `WorldQuant Alpha` and strives to be consistent with them.
3. Use `ta` otherwise. It is a `polars`-style version of `TA-Lib`. It tries to reuse functions from `wq`.
4. Use `tdx` last. It also tries to import functions from `wq` and `ta`.
5. We keep the same signature and parameters as the original `TA-Lib` in `talib`.
6. 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`.
## Comparison of Our Indicators and Others
See [compare](compare.md)
## Handling Null/NaN Values
See [nan_to_null](nan_to_null.md)
## Debugging
```commandline
git clone --depth=1 https://github.com/wukan1986/polars_ta.git
cd polars_ta
pip install -e .
```
Notice:
If 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).
This is required to use in `expr_codegen`.
## Reference
- https://github.com/pola-rs/polars
- https://github.com/TA-Lib/ta-lib
- https://github.com/twopirllc/pandas-ta
- https://github.com/bukosabino/ta
- https://github.com/peerchemist/finta
- https://github.com/wukan1986/ta_cn
- https://support.worldquantbrain.com/hc/en-us/community/posts/20278408956439-从价量看技术指标总结-Technical-Indicator-
- https://platform.worldquantbrain.com/learn/operators/operators
# polars_ta
基于`polars`的算子库。实现量化投研中常用的技术指标、数据处理等函数。对于不易翻译成`Expr`的库(如:`TA-Lib`)也提供了函数式调用的封装
## 安装
### 在线安装
```commandline
pip install -i https://pypi.org/simple --upgrade polars_ta # 官方源
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade polars_ta # 国内镜像源
```
### 源码安装
```commandline
git clone --depth=1 https://github.com/wukan1986/polars_ta.git
cd polars_ta
python -m build
cd dist
pip install polars_ta-0.1.2-py3-none-any.whl
```
### TA-Lib安装
Windows用户不会安装可从`https://github.com/cgohlke/talib-build/releases` 下载对应版本whl文件
## 使用方法
参考`examples`目录即可,例如:
```python
# 如果需要在`expr_codegen`中使用,需要有`ts_`等前权,这里导入提供了前缀
from polars_ta.prefix.tdx import *
# 导入wq公式
from polars_ta.prefix.wq import *
# 演示生成大量指标
df = df.with_columns([
# 从wq中导入指标
*[ts_returns(CLOSE, i).alias(f'ROCP_{i:03d}') for i in (1, 3, 5, 10, 20, 60, 120)],
*[ts_mean(CLOSE, i).alias(f'SMA_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_std_dev(CLOSE, i).alias(f'STD_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_max(HIGH, i).alias(f'HHV_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_min(LOW, i).alias(f'LLV_{i:03d}') for i in (5, 10, 20, 60, 120)],
# 从tdx中导入指标
*[ts_RSI(CLOSE, i).alias(f'RSI_{i:03d}') for i in (6, 12, 24)],
])
```
当`min_samples`和`MIN_SAMPLES`都设置时,以`min_samples`为准,默认值为`None`
```python
import polars_ta
# 全局设置。优先级低
polars_ta.MIN_SAMPLES = 1
# 指定函数。优先级高
ts_mean(CLOSE, 10, min_samples=1)
```
## 设计原则
1. 调用方法由`成员函数`换成`独立函数`。输入输出使用`Expr`,避免使用`Series`
2. 优先实现`wq`公式,它仿`WorldQuant Alpha`公式,与官网尽量保持一致。如果部分功能实现在此更合适将放在此处
3. 其次实现`ta`公式,它相当于`TA-Lib`的`polars`风格的版本。优先从`wq`中导入更名
4. 最后实现`tdx`公式,它也是优先从`wq`和`ta`中导入
5. `talib`的函数名与参数与原版`TA-Lib`完全一致
6. 如果出现了命名冲突,建议调用优先级为`wq`、`ta`、`tdx`、`talib`。因为优先级越高,实现方案越接近于`Expr`
## 指标区别
请参考[compare](compare.md)
## 空值处理
请参考[nan_to_null](nan_to_null.md)
## 开发调试
```commandline
git clone --depth=1 https://github.com/wukan1986/polars_ta.git
cd polars_ta
pip install -e .
```
注意:如果你在`ta`或`tdx`中添加了新的函数,请再运行`tools`下的`prefix_ta.py`或`prefix_tdx.py`,用于生成对应的前缀文件。前缀文件方便在`expr_codegen`中使用
## 文档生成
```commandline
pip install -r requirements-docs.txt
mkdocs build
```
文档生成在`site`目录下,其中的`llms-full.txt`可以作为大语言模型的知识库导入。
也可以通过以下链接导入:
https://polars-ta.readthedocs.io/en/latest/llms-full.txt
## 提示词
由于`llms-full.txt`信息不适合做提示词,所以`tools/prompt.py`提供了生成更简洁算子清单的功能。
用户也可以直接使用`prompt.txt`(欢迎提示词工程专家帮忙改进,做的更准确)
## 参考
- https://github.com/pola-rs/polars
- https://github.com/TA-Lib/ta-lib
- https://github.com/twopirllc/pandas-ta
- https://github.com/bukosabino/ta
- https://github.com/peerchemist/finta
- https://github.com/wukan1986/ta_cn
- https://support.worldquantbrain.com/hc/en-us/community/posts/20278408956439-从价量看技术指标总结-Technical-Indicator-
================================================
FILE: compare.md
================================================
# Differences in Indicators
## 1. EMA alike indicators
### 1.1 EMA
1. EMA(CLOSE, 10), `talib.set_compatibility(0)` is the default, and is equivalent to`EXPMEMA`
- The first not nan value starts as `talib.SMA(CLOSE, 10)`
2. EMA(CLOSE, 10), `talib.set_compatibility(1)`
- The first not nan value starts as `CLOSE`
Since the logic of `EMA` calculation has changed in `TA-Lib`'s `compatibility mode 0`, it is complex and inefficient to implement it using expressions.
We only implement `compatibility mode 1`.
It just so happens that the Chinese stock software only implements `compatibility mode 1`.
You can compare the full data with `TA-Lib` for unit testing.
Indicators affected by `EMA` include `MACD, DEMA, TEMA, TRIX, T3`, etc.
### 1.2 Chinese Version of SMA(X, N, M)
In essence, it is `RMA compatibility mode 0`, that is,
the first valid value is the moving average. And then the difference is `alpha`
1. `SMA(X, N, M) = X.ema_mean(alpha=M/N)`
2. `RMA(X, N) = X.ema_mean(alpha=1/N) = SMA(X, N, 1)`
3. `EMA(x, N) = X.ema_mean(alpha=2/(N+1)) = X.ema_mean(span=N)`
Refer to: [ewm_mean](https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.ewm_mean.html#polars.Expr.ewm_mean)
In this case, we use `RMA compatibility mode 1`.
There exists error in switching between the two modes.
So please provide enough length of data.
The data in the later part can be used for unit testing.
Indicators affected by `SMA` include `ATR, RSI`, etc.
### 1.3 Moving Sum
Some indicators including `ADX` require the first value as a `SUM` rather than `SMA`. We will implement them later by `ema_mean(alpha=1/N)`
## 2. MAX/MIN
1. In package `wq`, `max_/min_` are cross-sectional operators, `ts_max/ts_min` are time series indicators
2. In `talib`, `MAX/MIN` are time series indicators, without cross-sectional operators.
3. In `ta`, to mimic `talib`, `MAX/MIN` are time series indicators, without cross-sectional operators.
4. In `tdx`, `MAX/MIN` are cross-sectional operators, `HHV/LLV` are time series indicators.
# 指标区别
## 1. EMA系列
### 1.1 EMA指标
1. EMA(CLOSE, 10),`talib.set_compatibility(0)`,此为默认设置,等价于`EXPMEMA`
- 第一个有效值为`talib.SMA(CLOSE, 10)`
2. EMA(CLOSE, 10),`talib.set_compatibility(1)`
- 第一个有效值为`CLOSE`
由于`TA-Lib`的`兼容模式0`在`EMA`计算时逻辑发生了变动,用表达式实现起来复杂、计算效率低。
所以本库只实现`兼容模式1`。正好国内股票软件其实也只实现了`兼容模式1`。可以全量数据与`TA-Lib`进行单元测试比较
因`EMA`受影响的指标有`MACD, DEMA, TEMA, TRIX, T3`等。
### 1.2 中国版SMA(X, N, M)
本质上是国外的`RMA 兼容模式0`,即第一个有效值为移动平均,然后就是`alpha`区别
1. `SMA(X, N, M) = X.ema_mean(alpha=M/N)`
2. `RMA(X, N) = X.ema_mean(alpha=1/N) = SMA(X, N, 1)`
3. `EMA(x, N) = X.ema_mean(alpha=2/(N+1)) = X.ema_mean(span=N)`
换算关系可参考: [ewm_mean](https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.ewm_mean.html#polars.Expr.ewm_mean)
遇到这种情况,本项目还是用`RMA 兼容模式1`来代替,数据误差由大到小,所以请预先提供一定长度的数据。后面一段的数据可以单元测试
受影响的的指标有`ATR, RSI`等
### 1.3 移动求和
`ADX`等一类的指标第一个有效值算法为`SUM`,而不是`SMA`,之后使用`ema_mean(alpha=1/N)`。此类暂不实现
## 2. MAX/MIN等指标
1. 在`wq`中,`max_/min_`横向算子,`ts_max/ts_min`时序指标
2. 在`talib`中, `MAX/MIN`时序指标,没有横向算子
3. 在`ta`中,由于要模仿`talib`,所以有`MAX/MIN`时序指标,也没有横向算子
4. 在`tdx`中,`MAX/MIN`横向算子,`HHV/LLV`时序指标
================================================
FILE: deprecated/demo_ta1.py
================================================
"""
Thisis how polars implements calling third-party packages
以下是polars提供的实现调用第三方库的方案
expr.ta.func
"""
import polars as pl
from polars_ta.utils.helper import TaLibHelper # noqa
df = pl.DataFrame(
{
"A": [5, None, 3, 2, 1],
"B": [5, 4, None, 2, 1],
"C": [5, 4, 3, 2, 1],
}
)
df = df.with_columns([
# single input single ouput, no need to handle null/nan values
# 一输入一输出,不需处理空值
pl.col('A').ta.COS().alias('COS'),
# single input, multi output
# 一输入多输出
pl.col('A').ta.BBANDS(timeperiod=2, skip_nan=True, schema=['upperband', 'middleband', 'lowerband']).alias('BBANDS'),
# multi input, single output
# 多输入一输出
pl.struct(['A', 'B', 'C']).ta.ATR(timeperiod=2, skip_nan=True).alias('ATR'),
# multi input, multi output
# 多输入多输出
pl.struct(['A', 'B']).ta.AROON(timeperiod=2, skip_nan=True, schema=('aroondown', 'aroonup'), schema_format='XX_{}_YY').alias('AROON'),
# multi input, single output
# 多输入一输出
pl.struct(['A', 'B']).ta.AROON(timeperiod=2, skip_nan=True, output_idx=1).alias('aroonup1'),
# call third-party packages
# 调用另一库
pl.col('A').bn.move_rank(window=2, skip_nan=False).alias('move_rank'),
])
print(df)
df = df.unnest('BBANDS', 'AROON')
print(df)
================================================
FILE: deprecated/demo_ta2.py
================================================
"""
This is how we wrap upon polars's code
以下是polars提供的方案基础上封装的方案
func(expr)
"""
import polars as pl
from polars_ta.utils.wrapper import init
df = pl.DataFrame(
{
"A": [5, None, 3, 2, 1],
"B": [5, 4, None, 2, 1],
"C": [5, 4, 3, 2, 1],
}
)
# register to global variables. You may directly use them.
# IDE might give warnings about not defined.
# 已经注册到全局,可直接使用。但IDE中没有智能提示
init(to_globals=True, name_format='{}')
df = df.with_columns([
# single input single ouput, no need to handle null/nan values
# 一输入一输出,不需处理空值
COS(pl.col('A')).alias('COS'),
# multi input, single output
# 多输入一输出
ATR(pl.struct(['A', 'B', 'C']), timeperiod=2).alias('ATR1'),
ATR(pl.col('A'), pl.col('B'), pl.col('C'), 2, skip_nan=True).alias('ATR2'),
# single input, multi output, add prefix to the column names passing to `BBANDS`
# 一输入多输出,可通过prefix为多输出添加前缀
BBANDS(pl.col('A'), timeperiod=2, skip_nan=True, schema_format='bbands_{}').alias('BBANDS'),
# multi input multi output, set column name directly by `schema`
# 多输入多输出。可通过schema直接添加
AROON(pl.struct(['A', 'B']), timeperiod=2, skip_nan=True, schema=('aroondown', 'aroonup')).alias('AROON'),
])
print(df)
df = df.unnest('BBANDS', 'AROON')
print(df)
# another way of calling init
# 另一种调用方法
t = init(to_globals=False, name_format='ts_{}')
df = df.with_columns([
# single input single ouput, no need to handle null/nan values
# 一输入一输出,不需处理空值
t.ts_COS(pl.col('A')).alias('ts_COS'),
])
print(df)
================================================
FILE: deprecated/helper.py
================================================
"""
We follow the spirit of
https://github.com/pola-rs/polars/issues/9261
and adjusted it to fit our needs. The usage is as follows
expr.ta.func(..., skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False)
skip_nan: bool
reduces speed
output_idx: int
select a single column when outputing multiple columns
schema: list or tuple
assign column names for multiple output columns
schema_format: str
assign data types for multiple output columns
nan_to_null: bool
replace all nan to null when outputing
以下是在github issues中 @cmdlineluser 提供的 注册命名空间 方案
https://github.com/pola-rs/polars/issues/9261
本人做了一定的调整。使用方法如下
expr.ta.func(..., skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False)
skip_nan: bool
是否跳过空值。可以处理停牌无数据的问题,但会降低运行速度
output_idx: int
多列输出时,选择只输出其中一列
schema: list or tuple
返回为多列时,会组装成struct,可以提前设置子列的名字
schema_format: str
为子列名指定格式
nan_to_null: bool
返回值是否改成null
其它参数按**位置参数**和**命名参数**输入皆可
"""
import numpy as np
from polars import Expr, Float64, DataFrame, api
from polars import Series, Struct
def func_wrap_mn(func, cols,
*args,
skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False,
**kwargs):
"""multiple input multiple output, compatible with single input single output
多输入多输出,兼容一输入一输出
Parameters
----------
func
cols
args
skip_nan
output_idx
schema
schema_format
nan_to_null
kwargs
Returns
-------
Series
"""
if cols.dtype.base_type() == Struct:
# struct(['A', 'B']).ta.AROON
_cols = [cols.struct[field] for field in cols.dtype.to_schema()]
else:
# col('A').ta.BBANDS
_cols = [cols]
if skip_nan:
_cols = [c.cast(Float64).to_numpy() for c in _cols]
_cols = np.vstack(_cols)
# move nan to head
idx1 = (~np.isnan(_cols).any(axis=0)).argsort(kind='stable')
# restore nan
idx2 = idx1.argsort(kind='stable')
_cols = [_cols[i, idx1] for i in range(len(_cols))]
result = func(*_cols, *args, **kwargs)
if isinstance(result, tuple):
result = tuple([_[idx2] for _ in result])
else:
result = result[idx2]
else:
result = func(*_cols, *args, **kwargs)
if isinstance(result, tuple):
if output_idx is None:
# struct(['A').ta.BBANDS
# you need alias outside, finally unnest
if schema is None:
schema = [f'column_{i}' for i in range(len(result))]
schema = [schema_format.format(name) for name in schema]
# nan_to_null is not effective for struct
# nan_to_null 对struct中的nan无效
return DataFrame(result, schema=schema, nan_to_null=nan_to_null).to_struct('')
# output only one column
if 0 <= output_idx < len(result):
return Series(result[output_idx], nan_to_null=nan_to_null)
elif not isinstance(result, Series):
# col('A').bn.move_rank
return Series(result, nan_to_null=nan_to_null)
else:
# col('A').ta.COS
if nan_to_null:
return result.fill_nan(None)
else:
return result
def func_wrap_11(func, cols,
*args,
skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False,
**kwargs):
"""single input single output is faster than multiple input multiple output
一输入,一输出。处理速度能更快一些"""
_cols = cols
if skip_nan:
_cols = _cols.cast(Float64).to_numpy()
# move nan to head
idx1 = (~np.isnan(_cols)).argsort(kind='stable')
# restore nan
idx2 = idx1.argsort(kind='stable')
_cols = _cols[idx1]
result = func(_cols, *args, **kwargs)
result = result[idx2]
else:
result = func(_cols, *args, **kwargs)
if isinstance(result, Series):
if nan_to_null:
return result.fill_nan(None)
else:
return result
else:
return Series(result, nan_to_null=nan_to_null)
class FuncHelper:
def __init__(self, expr: Expr, lib=None, wrap=None) -> None:
"""initialization
Parameters
----------
expr
lib:
third-party packages required
wrap:
wrapper for third-party packages
初始化
Parameters
----------
expr
lib:
需要调用的第三方库
wrap:
对第三方库的封装方法
"""
object.__setattr__(self, '_expr', expr)
object.__setattr__(self, '_lib', lib)
object.__setattr__(self, '_wrap', wrap)
def __getattribute__(self, name: str):
_expr: Expr = object.__getattribute__(self, '_expr')
_lib = object.__getattribute__(self, '_lib')
_wrap = object.__getattribute__(self, '_wrap')
_func = getattr(_lib, name)
return (
lambda *args, skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False, **kwargs:
_expr.map_batches(
lambda cols: _wrap(_func, cols,
*args,
skip_nan=skip_nan, output_idx=output_idx, schema=schema, schema_format=schema_format, nan_to_null=nan_to_null,
**kwargs)
)
)
@api.register_expr_namespace('ta')
class TaLibHelper(FuncHelper):
def __init__(self, expr: Expr) -> None:
import talib as ta
super().__init__(expr, ta, func_wrap_mn)
@api.register_expr_namespace('bn')
class BottleneckHelper(FuncHelper):
def __init__(self, expr: Expr) -> None:
import bottleneck as bn
super().__init__(expr, bn, func_wrap_11)
================================================
FILE: deprecated/pandas_.py
================================================
from functools import lru_cache
from typing import Tuple
import numpy as np
from numba import jit
from pandas._libs.window.aggregations import roll_kurt as _roll_kurt
from pandas._libs.window.aggregations import roll_rank as _roll_rank
from polars import Series
"""
When converting float32 to float64 before computing. Either use
x.cast(Float64).to_numpy()
or
x.to_numpy().astype(float)
The second one is faster
在计算前需要将float32转成float64,有以下两种方法
x.cast(Float64).to_numpy()
x.to_numpy().astype(float)
第二种方法更快
"""
@lru_cache
@jit(nopython=True, nogil=True, fastmath=True, cache=True)
def get_window_bounds(
num_values: int = 0,
window_size: int = 10,
) -> Tuple[np.ndarray, np.ndarray]:
end = np.arange(1, num_values + 1, dtype=np.int64)
start = end - window_size
start = np.clip(start, 0, num_values)
return start, end
def roll_rank(x: Series, d: int, minp: int, pct: bool = True, method: str = 'average', ascending: bool = True):
start, end = get_window_bounds(len(x), d)
"""
https://github.com/pandas-dev/pandas/blob/main/pandas/_libs/window/aggregations.pyx#L1281
def roll_rank(const float64_t[:] values, ndarray[int64_t] start,
ndarray[int64_t] end, int64_t minp, bint percentile,
str method, bint ascending) -> np.ndarray:
O(N log(window)) implementation using skip list
"""
ret = _roll_rank(x.to_numpy().astype(float), start, end, minp, pct, method, ascending)
return Series(ret, nan_to_null=True)
def roll_kurt(x, d: int, minp: int):
start, end = get_window_bounds(len(x), d)
"""
https://github.com/pandas-dev/pandas/blob/main/pandas/_libs/window/aggregations.pyx#L803
def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
ndarray[int64_t] end, int64_t minp) -> np.ndarray:
"""
ret = _roll_kurt(x.to_numpy().astype(float), start, end, minp)
return Series(ret, nan_to_null=True)
================================================
FILE: deprecated/wrapper.py
================================================
"""
Another wrapper for raised github issue
before:
expr.ta.func(..., skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False)
now:
func(expr, ..., skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False)
This wrapper allows the prefix expression to be easily used in genetic algorithm tools
此处是对github issues上提出的 注册命名空间 方案的再封装
之前的使用方法为
expr.ta.func(..., skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False)
封装后方法为
func(expr, ..., skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False)
此种封装方法的优点是前缀表达式方便输入到遗传算法工具包中使用
"""
from functools import wraps
import talib as _talib
from polars import Expr
from polars import struct
from talib import abstract as _abstract
from polars_ta.utils.helper import TaLibHelper
_ = TaLibHelper
def ta_func(func, func_name, input_names, output_names,
*args,
skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False,
**kwargs):
"""
Parameters
----------
func
func_name
input_names: list of str
函数输入名
output_names: list of str
函数输出名
args
位置参数
skip_nan
output_idx
schema
schema_format
nan_to_null
kwargs
命名参数
Returns
-------
"""
exprs = [arg for arg in args if isinstance(arg, Expr)]
param = [arg for arg in args if not isinstance(arg, Expr)]
if len(exprs) == 1:
ef = getattr(exprs[0].ta, func_name)
else:
ef = getattr(struct(*exprs).ta, func_name)
return ef(*param,
skip_nan=skip_nan, output_idx=output_idx, schema=schema, schema_format=schema_format, nan_to_null=nan_to_null,
**kwargs)
def ta_decorator(func, func_name, input_names, output_names):
@wraps(func)
def decorated(*args,
skip_nan=False, output_idx=None, schema=None, schema_format='{}', nan_to_null=False,
**kwargs):
return ta_func(func, func_name, input_names, output_names,
*args,
skip_nan=skip_nan, output_idx=output_idx, schema=schema, schema_format=schema_format, nan_to_null=nan_to_null,
**kwargs)
return decorated
def init(to_globals=False, name_format='{}'):
"""初始化环境
Parameters
----------
to_globals: bool
是否注册到全局变量中
name_format: str
函数名格式
Returns
-------
class
对象实例,可调用其内的方法
"""
class TA_LIB:
pass
lib = TA_LIB()
for i, func_name in enumerate(_talib.get_functions()):
"""talib遍历"""
_ta_func = getattr(_talib, func_name)
info = _abstract.Function(func_name).info
output_names = info['output_names']
input_names = info['input_names']
# 创建函数
f = ta_decorator(_ta_func, func_name, input_names, output_names)
name = name_format.format(func_name)
setattr(lib, name, f)
if to_globals:
from inspect import currentframe
frame = currentframe().f_back
frame.f_globals[name] = f
return lib
================================================
FILE: docs/index.md
================================================
# polars_ta
尽量接近`WorldQuant Alpha101`风格函数,但部分又做了一定的调整
例如:
1. x.abs().log()
- 可利用`IDE`的自动补全,输入方便
- 默认是一个输入,多输入要通过参数列表。输入不统一
2. log(abs_(x))
- 都是通过参数列表,输入统一
- 一层套一层,正好对应表达式树,直接可用于遗传规划
- `abs`与`python`内置函数冲突,使用`abs_`代替,同样还有`and_`、`int_`、`max_`等
## References
- https://platform.worldquantbrain.com/learn/operators/operators
- https://github.com/TA-Lib/ta-lib
================================================
FILE: docs/ta/index.md
================================================
用`polars`函数模仿`TA-Lib`的函数
================================================
FILE: docs/ta/momentum.md
================================================
::: polars_ta.ta.momentum
================================================
FILE: docs/ta/operators.md
================================================
::: polars_ta.ta.operators
================================================
FILE: docs/ta/overlap.md
================================================
::: polars_ta.ta.overlap
================================================
FILE: docs/ta/price.md
================================================
::: polars_ta.ta.price
================================================
FILE: docs/ta/statistic.md
================================================
::: polars_ta.ta.statistic
================================================
FILE: docs/ta/transform.md
================================================
::: polars_ta.ta.transform
================================================
FILE: docs/ta/volatility.md
================================================
::: polars_ta.ta.volatility
================================================
FILE: docs/ta/volume.md
================================================
::: polars_ta.ta.volume
================================================
FILE: docs/talib/index.md
================================================
直接调用`TA-Lib`, 多输出时返回`struct`, 可以使用`.struct[0]`取到对应字段的`Series`.
::: polars_ta.talib
================================================
FILE: docs/tdx/arithmetic.md
================================================
::: polars_ta.tdx.arithmetic
================================================
FILE: docs/tdx/choice.md
================================================
::: polars_ta.tdx.choice
================================================
FILE: docs/tdx/energy.md
================================================
::: polars_ta.tdx.energy
================================================
FILE: docs/tdx/logical.md
================================================
::: polars_ta.tdx.logical
================================================
FILE: docs/tdx/moving_average.md
================================================
::: polars_ta.tdx.moving_average
================================================
FILE: docs/tdx/over_bought_over_sold.md
================================================
::: polars_ta.tdx.over_bought_over_sold
================================================
FILE: docs/tdx/pattern.md
================================================
::: polars_ta.tdx.pattern
================================================
FILE: docs/tdx/pattern_feature.md
================================================
::: polars_ta.tdx.pattern_feature
================================================
FILE: docs/tdx/pressure_support.md
================================================
::: polars_ta.tdx.pressure_support
================================================
FILE: docs/tdx/reference.md
================================================
::: polars_ta.tdx.reference
================================================
FILE: docs/tdx/statistic.md
================================================
::: polars_ta.tdx.statistic
================================================
FILE: docs/tdx/times.md
================================================
::: polars_ta.tdx.times
================================================
FILE: docs/tdx/trend.md
================================================
::: polars_ta.tdx.trend
================================================
FILE: docs/tdx/trend_feature.md
================================================
::: polars_ta.tdx.trend_feature
================================================
FILE: docs/tdx/volume.md
================================================
::: polars_ta.tdx.volume
================================================
FILE: docs/wq/arithmetic.md
================================================
::: polars_ta.wq.arithmetic
================================================
FILE: docs/wq/cross_sectional.md
================================================
::: polars_ta.wq.cross_sectional
================================================
FILE: docs/wq/half_life.md
================================================
::: polars_ta.wq.half_life
================================================
FILE: docs/wq/logical.md
================================================
::: polars_ta.wq.logical
================================================
FILE: docs/wq/preprocess.md
================================================
::: polars_ta.wq.preprocess
================================================
FILE: docs/wq/time_series.md
================================================
::: polars_ta.wq.time_series
================================================
FILE: docs/wq/transformational.md
================================================
::: polars_ta.wq.transformational
================================================
FILE: docs/wq/vector.md
================================================
::: polars_ta.wq.vector
================================================
FILE: examples/alpha101.py
================================================
from datetime import datetime
import pandas as pd
import polars as pl
from polars_ta.prefix.tdx import *
from polars_ta.prefix.wq import *
# definition of your features
# 因子定义
OPEN, HIGH, LOW, CLOSE, VOLUME, AMOUNT, = pl.col('OPEN'), pl.col('HIGH'), pl.col('LOW'), pl.col('CLOSE'), pl.col('VOLUME'), pl.col('AMOUNT'),
RETURNS, VWAP, CAP, = pl.col('RETURNS'), pl.col('VWAP'), pl.col('CAP'),
ADV5, ADV10, ADV15, ADV20, ADV30, ADV40, ADV50, ADV60, ADV81, ADV120, ADV150, ADV180, = (
pl.col('ADV5'), pl.col('ADV10'), pl.col('ADV15'), pl.col('ADV20'),
pl.col('ADV30'), pl.col('ADV40'), pl.col('ADV50'), pl.col('ADV60'),
pl.col('ADV81'), pl.col('ADV120'), pl.col('ADV150'), pl.col('ADV180'),)
SECTOR, INDUSTRY, SUBINDUSTRY, = pl.col('SECTOR'), pl.col('INDUSTRY'), pl.col('SUBINDUSTRY'),
# you can only call column-alike factor directly. Since ts_, cs_ and gp_ etc. need to be used with group_by, please use expr_codegen project for more complex formula
# 列因子才可以直接调用,而ts_、cs_和gp_等公式需要套用group_by,复杂公式请使用expr_codegen项目
alpha_041 = (((HIGH * LOW) ** 0.5) - VWAP)
alpha_054 = ((-1 * ((LOW - CLOSE) * (OPEN ** 5))) / ((LOW - HIGH) * (CLOSE ** 5)))
alpha_101 = ((CLOSE - OPEN) / ((HIGH - LOW) + 0.001))
# simulate 5000 stocks for 10 years
# 模拟5000支股票10年
ASSET_COUNT = 5000
DATE_COUNT = 250 * 10
DATE = pd.date_range(datetime(2020, 1, 1), periods=DATE_COUNT).repeat(ASSET_COUNT)
ASSET = [f'A{i:04d}' for i in range(ASSET_COUNT)] * DATE_COUNT
# your test data. multi-asset multi-feature
# 测试数据。多资产多特征
df = pl.DataFrame(
{
'date': DATE,
'asset': ASSET,
"OPEN": np.random.rand(DATE_COUNT * ASSET_COUNT),
"HIGH": np.random.rand(DATE_COUNT * ASSET_COUNT),
"LOW": np.random.rand(DATE_COUNT * ASSET_COUNT),
"CLOSE": np.random.rand(DATE_COUNT * ASSET_COUNT),
"VWAP": np.random.rand(DATE_COUNT * ASSET_COUNT),
"FILTER": np.tri(DATE_COUNT, ASSET_COUNT, k=-2).reshape(-1),
}
)
# filter out some data. test if it will raise error when the length is not enough
# 每行数据量不同,测试是否会因为长度不足报错
df = df.filter(pl.col("FILTER") == 1)
# some simple features defined in Alpha101. They don't contain groupby in time-series or cross-section
# 部分Alpha101计算。不涉及时序和横截面,可直接计算
df = df.with_columns(
alpha_041=alpha_041,
alpha_054=alpha_054,
alpha_101=alpha_101,
)
def func_ts_date(df: pl.DataFrame) -> pl.DataFrame:
# ensure sorted before computing time-series features
# 时序指标计算前一定要保证有序
df = df.sort(by=['date'])
# Example of generating features
# 演示生成大量指标
df = df.with_columns([
# load from sub-package `wq`
# 从wq中导入指标
*[ts_returns(CLOSE, i).alias(f'ROCP_{i:03d}') for i in (1, 3, 5, 10, 20, 60, 120)],
*[ts_mean(CLOSE, i).alias(f'SMA_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_std_dev(CLOSE, i).alias(f'STD_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_max(HIGH, i).alias(f'HHV_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_min(LOW, i).alias(f'LLV_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_rank(CLOSE, i).alias(f'RANK_{i:03d}') for i in (5, 10, 20, 60, 120)],
*[ts_arg_max(HIGH, i).alias(f'HHVBAR_{i:03d}') for i in (5, 10, 20, 60, 120)],
# load from sub-package `tdx`
# 从tdx中导入指标
*[ts_RSI(CLOSE, i).alias(f'RSI_{i:03d}') for i in (6, 12, 24)],
])
return df
# ensure grouped before applying to multi-asset data
# 多资产需要先按资产分组
df = df.group_by('asset').map_groups(func_ts_date)
print(df)
================================================
FILE: examples/demo_ta3.py
================================================
"""
This is how we wrap upon polars's code
以下是polars提供的方案基础上封装的方案
func(expr)
"""
import polars as pl
from polars_ta.talib import *
df = pl.DataFrame(
{
"A": [5, None, 3, 2, 1],
"B": [5, 4, None, 2, 1],
"C": [5, 4, 3, 2, 1],
}
)
df = df.with_columns([
# single input single ouput, no need to handle null/nan values
# # 一输入一输出,不需处理空值
COS(pl.col('A')).alias('COS'),
# 多输入一输出
ATR(pl.col('A'), pl.col('B'), pl.col('C'), 2).alias('ATR2'),
# 原为一输入多输出,通过ret_idx指定一输出
BBANDS(pl.col('A'), timeperiod=2).alias('BBANDS'),
# 原为多输入多输出,通过ret_idx指定一输出
AROON('A', 'B', timeperiod=2).alias('AROON'),
])
print(df)
================================================
FILE: mkdocs.yml
================================================
site_name: polars_ta API References
site_url: https://polars-ta.readthedocs.io/en/latest/
nav:
- Home: index.md
- polars_ta.wq:
- wq/arithmetic.md
- wq/cross_sectional.md
- wq/logical.md
- wq/preprocess.md
- wq/time_series.md
- wq/transformational.md
- wq/vector.md
- polars_ta.ta:
- ta/index.md
- ta/momentum.md
- ta/operators.md
- ta/overlap.md
- ta/price.md
- ta/statistic.md
- ta/transform.md
- ta/volatility.md
- ta/volume.md
- polars_ta.tdx:
- tdx/arithmetic.md
- tdx/choice.md
- tdx/energy.md
- tdx/logical.md
- tdx/moving_average.md
- tdx/over_bought_over_sold.md
- tdx/pattern.md
- tdx/pattern_feature.md
- tdx/pressure_support.md
- tdx/reference.md
- tdx/statistic.md
- tdx/trend.md
- tdx/trend_feature.md
- tdx/volume.md
- polars_ta.talib: talib/index.md
theme:
name: material
features:
- navigation.tracking
- navigation.instant
- navigation.tabs
- navigation.tabs.sticky
- navigation.footer
- navigation.indexes
- content.tabs.link
- content.code.copy
strict: true
plugins:
- search
- mkdocstrings:
default_handler: python
handlers:
python:
paths: [ . ]
options:
summary: true
show_root_heading: true
show_if_no_docstring: true
show_source: false
show_signature_annotations: true
docstring_style: numpy
- llmstxt:
full_output: llms-full.txt
sections:
Usage documentation:
- index.md
- wq/*.md
- ta/*.md
- tdx/*.md
- talib/*.md
================================================
FILE: nan_to_null.md
================================================
# nan_to_null
It is important to handle nan and null values correctly. In many cases, null values may occur. Such as:
1. Stock suspension, data missing, etc.
2. Calculation exceptions, such as division by 0, log non-positive, etc.
## Null (None in Python) and NaN are different!
```python
None == None # True # (It should be `None is None`)
np.nan == np.nan # False
```
But in `pandas/numpy` many do not distinguish between `None` and `np.nan`, so you should always use `is_null/is_nan` functions to be safe.
1. In `pandas` 1.x, the representation of null values is:
- floating point uses `nan`,
- string uses `None`,
- time uses `pd.NaT`,
- integer has no null value representation, it can be converted to a floating-point number.
2. In `pandas` 2.x, the backend can use `Arrow`. It has two storage areas, one is the original data, and the other is the validity bitmap array, which marks whether it is `null`, so there is no data type restriction.
3. In `polars`, the backend is `Arrow`.
With a bitmap array, counting `null` values is faster than traversing the original array.
## `polars`
1. Most functions adapt to `null` but not `nan`, the best way should be using `fill_nan(None)` first.
2. To adapt to third-party packages, such as `TA-Lib`, when calling `to_numpy`, `null` will be automatically converted to `nan`, and the return value should be `pl.Series(, nan_to_null=True)`.
3. For the case of `null/nan` appearing in the middle, there is currently no good way to handle it.
## Reference
1. https://docs.pola.rs/user-guide/expressions/missing-data/#null-and-nan-values
2. https://pandas.pydata.org/docs/user_guide/missing_data.html
# nan_to_null
空值的处理是一件非常头疼的事性。多种情况下可能会出现空值。如:
1. 股票停牌、数据缺失 等
2. 计算异常,如:除0,log非正数 等
## None与NaN区别大不同
比较结果不同
```python
None == None # True # 注意None is None才是规范的写法
np.nan == np.nan # False
```
但在`pandas/numpy`中将`None`当成`np.nan`使用,这类容易混淆的地方,一定要使用`is_null/is_nan`函数才稳妥
1. 在pandas 1.x版本中,空值表示方法有:浮点用`nan`,字符串用`None`,时间用`pd.NaT`,整型没有空值表示方法,只能转成浮点
2. 在pandas 2.x版本中,后端可用`Arrow`。它有两块存储区域,一块还是原数据,另一块则是有效性位图数组,由它标记是否为`null`, 所以没有数据类型限制
3. 在polars中后端是`Arrow`
有位图数组,所以统计`null`数量肯定比遍历原数组要快
## polars
1. 大部分函数只适配了`null`,所以对于`nan`,最合适的处理方法是`fill_nan(None)`后再处理
2. 需要调用第三方函数时,以`TA-Lib`为例,`to_numpy`时会自动`null`转`nan`,返回值需`pl.Series(, nan_to_null=True)`
3. 对于中段出现`null/nan`的情况,目前还没有很好的处理方法
# 参考
1. https://docs.pola.rs/user-guide/expressions/missing-data/#null-and-nan-values
2. https://pandas.pydata.org/docs/user_guide/missing_data.html
================================================
FILE: point_in_time.md
================================================
# Point In Time
Essentially it is due to the fix of historical erroneous data. Sometimes we even need to fix the historical market data.
1. Market data:date\asset\features\[update_time]
2. Financial statement data:date\asset\features\update_time
`date`: time of the report,
`update_time`: time of the release
## Update of Financial Statement Data
There are two ways to download the data.
1. Download by `date`, just specify the 4 report periods of each year. But if the historical report period is changed in the new record, and the user cannot know which report period it is, the entire data needs to be downloaded.
2. Download by `update_time`, which can perfectly solve the above problem. But the release date is not fixed, and holidays may also occur. Downloading by day is inefficient, so it needs to be downloaded period by period.
## Storage of Financial Statement Data
Since the data is downloaded by `update_time`, it should be also stored by `update_time`, which is convenient for reading and updating.
## Storage of Historical Market Data
In market data, we do not need to distinguish the `date` and `update_time`.
Two ways to modify market data:
1. Similar to financial statement data, only add without modifying.
- Stored by day, is the record appended to an extra file or added to the file of that day?
- Because the storage is ordered by `update_time`, it should be added to the extra last file.
2. Directly modify the original data. In market data, the `update_time` is generally omitted, so the update method is more often to replace the old data.
## Dealing with data from PIT
1. The data update time may be on weekends. But the ideal way is to handle it the same as market data, so the `date` needs to be moved to Friday, and the `update_time` remains the same as the real time.
2. The PIT processing is divided into three steps.
- filter out the corresponding time of the DF,
- calculate the various time series indicators on each DF separately (or not),
- take the latest part of each DF for merging.
After this, the time series calculation cannot be executed again, because it will introduce future data.
# Point In Time
本质上是因发现历史数据有问题,需要进行修改而产生的。我们使用的行情数据其实也会有修改需求。所以是否能将其一起讨论呢?
1. 行情数据:date\asset\features\[update_time]
2. 财务数据:date\asset\features\update_time
date表示报告期、update_time表示公布日期
## 财务数据的更新
1. 按报告期date下载,只要指定每年的4个报告期即可下载。但新记录中如果改了历史报告期。而用户又无法知道是哪个报告期,得全下
2. 按公布日update_time下载,能完美的解决上面的问题。但公布日不固定、节假日也会发生,按日下载又效率低,所以得按时间段下载
## 财务数据的存储
由于已经选定用update_time来下载数据,所以存储时也按update_time来分文件名,这样也方便读取和更新
## 行情数据的更新与存储
行情数据中,date其本质就是报告期,又因更新时间等于报告期,所以被省略了,同股票date一般也不会重复,如有重复,必有update_time字段做区分,否则数据有误。
行情数据有两种修改方法:
1. 仿财务数据,只添加不修改。(其实财务数据发布后在第二天交易开始前发生了更新可以直接修改)
- 按日分文件存储,记录是添加到最后一个文件中,还是添加到那天的文件呢?
- 因为存储是按update_time有序,所以应当添加到最后
2. 直接修改原数据。在行情数据由于一般省略了update_time,所以更新方式也更多是覆盖
## PIT数据的处理
1. 数据更新时间可能是周末。但理想方式是与行情一样处理,所以date需要移动到周五,update_time保持真实时间
2. PIT处理分三步,第一步过滤出对应时间的DF、第二步在每个DF上分别计算各时序指标(也可不算),第三步取每个DF中最新部分进行合并
不能在第三步后再执行时序计算了,因为这会引入未来数据
================================================
FILE: polars_ta/__init__.py
================================================
from typing import Optional
from ._version import __version__
# 默认最小误差值
TA_EPSILON: float = 1e-8
# 默认最小样本数量
MIN_SAMPLES: Optional[int] = None
================================================
FILE: polars_ta/_version.py
================================================
__version__ = "0.5.17"
================================================
FILE: polars_ta/candles/__init__.py
================================================
from polars_ta.candles.cdl1 import * # noqa
from polars_ta.candles.cdl1_limit import * # noqa
from polars_ta.candles.cdl2 import * # noqa
================================================
FILE: polars_ta/candles/cdl1.py
================================================
"""
In this file we use
open_: Expr, high: Expr, low: Expr, close: Expr
for all parameters
to ensure the similar function signatures when calling them
本文件中参数全用
open_: Expr, high: Expr, low: Expr, close: Expr
统一的好处是在使用时不用考虑函数调用区别
"""
from polars import Expr
from polars import max_horizontal, min_horizontal
from polars_ta import TA_EPSILON
# https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_utility.h#L327
def real_body(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""实体"""
return (close - open_).abs()
def upper_shadow(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""上影"""
return high - max_horizontal(open_, close)
def lower_shadow(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""下影"""
return min_horizontal(open_, close) - low
def high_low_range(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""总长"""
return high - low
def upper_body(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""实体上沿"""
return max_horizontal(open_, close)
def lower_body(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""实体下沿"""
return min_horizontal(open_, close)
def shadows(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""阴影"""
return high_low_range(open_, high, low, close) - real_body(open_, high, low, close)
def efficiency_ratio(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""
abs(close-open) / (2 * (high-low) - abs(close-open) + TA_EPSILON)
K线内的市场效率。两个总长减去一个实体长就是路程
比较粗略的计算市场效率的方法。丢失了部分路程信息,所以结果会偏大
"""
displacement = real_body(open_, high, low, close)
distance = 2 * high_low_range(open_, high, low, close) - displacement
return displacement / (distance + TA_EPSILON)
# ====================================
def candle_color(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""K线颜色"""
return close >= open_
def four_price_doji(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""一字"""
return low >= (high - TA_EPSILON)
def doji(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""十字(含一字、T字)"""
return (open_ - close).abs() <= TA_EPSILON
def dragonfly(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""正T字"""
return doji(open_, high, low, close) & (low < close - TA_EPSILON)
def gravestone(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""倒T字"""
return doji(open_, high, low, close) & (high > close + TA_EPSILON)
# def candle_range(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
# return real_body(open_, high, low, close)
# return high_low_range(open_, high, low, close)
# return shadows(open_, high, low, close)
#
#
# def candle_average(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
# """平均值"""
# return high_low_range(open_, high, low, close)
================================================
FILE: polars_ta/candles/cdl1_limit.py
================================================
"""
In this file we use
open_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr
open_: Expr, high: Expr, low: Expr, close: Expr, low_limit: Expr
for all parameters
to ensure the similar function signatures when calling them
本文件中参数全用
open_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr
open_: Expr, high: Expr, low: Expr, close: Expr, low_limit: Expr
统一的好处是在使用时不用考虑函数调用区别
"""
from polars import Expr
from polars_ta import TA_EPSILON
from polars_ta.candles.cdl1 import four_price_doji, dragonfly, gravestone
def limit_up(price: Expr, high_limit: Expr) -> Expr:
"""
unified handles for
reached `high_limit` at `open_`
reached `high_limit` at `close`
reached `high_limit` at `high` but `close` < `high_limit` (at least once reached `high_limit` in this day)
开盘 涨停
收盘 涨停
最高 曾涨停
"""
return price >= high_limit - TA_EPSILON
def limit_up_at_open(open_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr) -> Expr:
"""
reached `high_limit` at `open_`
开盘 涨停
"""
return limit_up(open_, high_limit)
def limit_up_at_close(open_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr) -> Expr:
"""
reached `high_limit` at `close`
收盘 涨停
"""
return limit_up(close, high_limit)
def limit_up_at_high(open_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr) -> Expr:
"""
reached `high_limit` at `high` but `close` < `high_limit` (at least once reached `high_limit` in this day)
曾涨停
"""
return limit_up(high, high_limit) & ~limit_up(close, high_limit)
def limit_up_four_price_doji(open_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr) -> Expr:
"""
`low` = `high` = `open_` = `close` = `high_limit`
一字涨停
"""
return four_price_doji(open_, high, low, close) & limit_up(close, high_limit)
def limit_up_dragonfly(open_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr) -> Expr:
"""
`low` < `high` = `open_` = `close` = `high_limit`
T字涨停"""
return limit_up(close, high_limit) & dragonfly(open_, high, low, close)
# ======================================
def limit_down(price: Expr, low_limit: Expr) -> Expr:
"""
unified handles for
reached `low_limit` at `open_`
reached `low_limit` at `close`
reached `low_limit` at `high` but `close` > `low_limit` (at least once reached `low_limit` in this day)
开盘 跌停
收盘 跌停
最低 曾跌停
"""
return price <= low_limit + TA_EPSILON
def limit_down_at_open(open_: Expr, high: Expr, low: Expr, close: Expr, low_limit: Expr) -> Expr:
"""
reached `low_limit` at `open_`
开盘 跌停
"""
return limit_down(open_, low_limit)
def limit_down_at_close(open_: Expr, high: Expr, low: Expr, close: Expr, low_limit: Expr) -> Expr:
"""
reached `low_limit` at `close`
收盘 跌停
"""
return limit_down(close, low_limit)
def limit_down_at_high(open_: Expr, high: Expr, low: Expr, close: Expr, low_limit: Expr) -> Expr:
"""
reached `low_limit` at `high` but `close` > `low_limit` (at least once reached `low_limit` in this day)
曾跌停
"""
return limit_down(low, low_limit) & ~limit_down(close, low_limit)
def limit_down_four_price_doji(open_: Expr, high: Expr, low: Expr, close: Expr, low_limit: Expr) -> Expr:
"""
`low` = `high` = `open_` = `close` = `low_limit`
一字跌停
"""
return four_price_doji(open_, high, low, close) & limit_down(close, low_limit)
def limit_down_gravestone(open_: Expr, high: Expr, low: Expr, close: Expr, low_limit: Expr) -> Expr:
"""
`high` > `low` = `open_` = `close` = `low_limit`
T字跌停
"""
return limit_down(open_, low_limit) & gravestone(open_, high, low, close)
================================================
FILE: polars_ta/candles/cdl2.py
================================================
"""
In this file we use
open_: Expr, high: Expr, low: Expr, close: Expr
for all parameters
to ensure the similar function signatures when calling them
本文件中参数全用
open_: Expr, high: Expr, low: Expr, close: Expr
统一的好处是在使用时不用考虑函数调用区别
"""
from polars import Expr
from polars_ta.candles.cdl1 import lower_body, upper_body
# https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_utility.h#L360
def ts_gap_up(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""跳空高开"""
return low > high.shift(1)
def ts_gap_down(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""跳空低开"""
return high < low.shift(1)
def ts_real_body_gap_up(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""实体跳空高开"""
return lower_body(open_, high, low, close) > upper_body(open_, high, low, close).shift(1)
def ts_real_body_gap_down(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""实体跳空低开"""
return upper_body(open_, high, low, close) < lower_body(open_, high, low, close).shift(1)
================================================
FILE: polars_ta/labels/__init__.py
================================================
from polars_ta.labels.future import * # noqa
================================================
FILE: polars_ta/labels/_nb.py
================================================
import numpy as np
from numba import jit
from numpy import full
@jit(nopython=True, nogil=True, cache=True)
def _triple_barrier(close: np.ndarray, high: np.ndarray, low: np.ndarray, window: int, take_profit: float, stop_loss: float) -> np.ndarray:
"""三重障碍打标法"""
out = full(close.shape[0], np.nan, dtype=np.float64)
for i in range(close.shape[0] - window + 1):
entry_price = close[i]
if np.isnan(entry_price):
# out[i] = 0
continue
upper_barrier = entry_price * (1 + take_profit)
lower_barrier = entry_price * (1 - stop_loss)
for j in range(i + 1, i + window):
hit_upper = high[j] >= upper_barrier
hit_lower = low[j] <= lower_barrier
if hit_upper and hit_lower:
# TODO 同一天无法知道是先触发止损还是先触发止盈
# 1. 假定离收盘价远的先触发
if high[j] - close[j] > close[j] - low[j]:
out[i] = 1 # 最高价更远,触发止盈
else:
out[i] = -1 # 最低价更远,触发止损
# out[i] = -1 # 2. 简化处理认为先触发止损
break
if hit_upper:
out[i] = 1 # 止盈
break
if hit_lower:
out[i] = -1 # 止损
break
else:
# out[i] = 0 # 1. 时间到了触发平仓
out[i] = np.sign(close[j] / entry_price - 1) # 2. 时间到了触发平仓
return out
================================================
FILE: polars_ta/labels/future.py
================================================
"""
由于标签的定义比较灵活,所以以下代码主要用于参考
Notes
-----
标签都是未来数据,在机器学习中,只能用于`y`,不能用于`X`。
References
----------
https://mp.weixin.qq.com/s/XtgYezFsslOfW-QyIMr0VA
https://github.com/Rachnog/Advanced-Deep-Trading/blob/master/bars-labels-diff/Labeling.ipynb
"""
from polars import Expr, struct, Float64
from polars_ta.labels._nb import _triple_barrier
from polars_ta.utils.numba_ import batches_i2_o1, struct_to_numpy
from polars_ta.wq import cut, ts_delay, ts_log_diff, log
def ts_log_return(close: Expr, n: int = 5) -> Expr:
"""将未来数据当成卖出价后移到买入价位置,计算对数收益率
Examples
--------
```python
df = pl.DataFrame({
'a': [None, 10, 11, 12, 9, 12, 13],
}).with_columns(
out1=ts_log_return(pl.col('a'), 3),
out2=_ts_log_return(pl.col('a'), 3),
)
shape: (7, 3)
┌──────┬───────────┬───────────┐
│ a ┆ out1 ┆ out2 │
│ --- ┆ --- ┆ --- │
│ i64 ┆ f64 ┆ f64 │
╞══════╪═══════════╪═══════════╡
│ null ┆ null ┆ null │
│ 10 ┆ -0.105361 ┆ -0.105361 │
│ 11 ┆ 0.087011 ┆ 0.087011 │
│ 12 ┆ 0.080043 ┆ 0.080043 │
│ 9 ┆ null ┆ null │
│ 12 ┆ null ┆ null │
│ 13 ┆ null ┆ null │
└──────┴───────────┴───────────┘
```
"""
# return (close.shift(-n) / close).log()
return log(ts_delay(close, -n) / close)
def _ts_log_return(close: Expr, n: int = 5) -> Expr:
"""计算对数收益率,但将结果后移
如果打标签方式复杂,这种最终结果后移的方法更方便
"""
# return (close / close.shift(n)).log().shift(-n)
return ts_delay(ts_log_diff(close, n), -n)
def ts_simple_return(close: Expr, n: int = 5, threshold: float = 0.0, *more_threshold) -> Expr:
"""简单收益率标签。支持二分类、三分类等。对收益率使用`cut`进行分类
Parameters
----------
close
n:int
未来n天
threshold:float
收益率阈值,小于该值为0,大于等于该值为1
more_threshold:float
更多的阈值,用于三分类等。小于该值为1,大于等于该值为2,以此类推
Returns
-------
Expr
标签列, 类型为UInt32, 取值为0, 1, 2, ...
Examples
--------
```python
df = pl.DataFrame({
'a': [None, 10., 9.99, 9., 10., 11., 11.],
}).with_columns(
out1=label_simple_return(pl.col('a'), 1, 0),
out2=label_simple_return(pl.col('a'), 1, -0.001, 0.001),
)
shape: (7, 3)
┌──────┬──────┬──────┐
│ a ┆ out1 ┆ out2 │
│ --- ┆ --- ┆ --- │
│ f64 ┆ u32 ┆ u32 │
╞══════╪══════╪══════╡
│ null ┆ null ┆ null │
│ 10.0 ┆ 0 ┆ 0 │
│ 9.99 ┆ 0 ┆ 0 │
│ 9.0 ┆ 1 ┆ 2 │
│ 10.0 ┆ 1 ┆ 2 │
│ 11.0 ┆ 0 ┆ 1 │
│ 11.0 ┆ null ┆ null │
└──────┴──────┴──────┘
"""
return cut(close.pct_change(n).shift(-n), threshold, *more_threshold)
def ts_triple_barrier(close: Expr, high: Expr, low: Expr, d: int = 5, take_profit: float = 0.1, stop_loss: float = 0.05) -> Expr:
"""三重障碍打标法
Parameters
----------
close:Expr
收盘价
high:Expr
最高价
low:Expr
最低价
d:int
时间窗口
take_profit:float
止盈比例
stop_loss:float
止损比例
Returns
-------
Expr
标签列。取值为-1止损, 1止盈,0时间到期
Notes
-----
1. `high`, `low`在粗略情况下可用`close`代替
2. 时间到期时,根据盈亏返回不同的标签
Examples
--------
```python
df = pl.DataFrame({
"close": [np.nan, 1, 1, 1.0],
"high": [np.nan, 1, 1.1, 1],
"low": [np.nan, 1, 1, 0.95],
}).with_columns(
out=ts_triple_barrier(pl.col("close"), pl.col("high"), pl.col("low"), 2, 0.1, 0.05)
)
shape: (4, 4)
┌───────┬──────┬──────┬──────┐
│ close ┆ high ┆ low ┆ out │
│ --- ┆ --- ┆ --- ┆ --- │
│ f64 ┆ f64 ┆ f64 ┆ f64 │
╞═══════╪══════╪══════╪══════╡
│ NaN ┆ NaN ┆ NaN ┆ null │
│ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │
│ 1.0 ┆ 1.1 ┆ 1.0 ┆ -1.0 │
│ 1.0 ┆ 1.0 ┆ 0.95 ┆ null │
└───────┴──────┴──────┴──────┘
```
"""
return struct(f0=close, f1=high, f2=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3), _triple_barrier, d, take_profit, stop_loss), return_dtype=Float64)
================================================
FILE: polars_ta/noise.py
================================================
"""
The following comes from Trading Systems and Methods, Chapter 1, Measuring Noise
We do not provide ATR and STD here.
ATR与STD也是一种度量波动的方法,这里不再提供
以下方法来自于Trading Systems and Methods, Chapter 1, Measuring Noise
References
----------
https://zhuanlan.zhihu.com/p/544744582
"""
import numpy as np
from polars import Expr
def ts_efficiency_ratio(close: Expr, timeperiod: int = 14) -> Expr:
"""效率系数。值越大,噪音越小。最大值为1,最小值为0
本质上是位移除以路程
"""
t1 = close.diff(timeperiod).abs()
t2 = close.diff(1).abs().rolling_sum(timeperiod)
return t1 / t2
def ts_price_density(high: Expr, low: Expr, timeperiod: int = 14) -> Expr:
"""价格密度。值越大,噪音越大
如果K线高低相连,上涨为1,下跌也为1
如果K线高低平行,值大于1,最大为timeperiod
"""
t1 = (high - low).rolling_sum(timeperiod)
t2 = high.rolling_max(timeperiod) - low.rolling_min(timeperiod)
return t1 / t2
def ts_fractal_dimension(high: Expr, low: Expr, close: Expr, timeperiod: int = 14) -> Expr:
"""分形维度。值越大,噪音越大"""
n1 = (1 / timeperiod) ** 2
n2 = np.log(2)
n3 = np.log(2 * timeperiod)
t1 = high.rolling_max(timeperiod) - low.rolling_min(timeperiod)
t2 = close.diff(1)
L = (n1 + t2 / t1).sqrt().rolling_sum(timeperiod)
return 1 + (L.log() + n2) / n3
================================================
FILE: polars_ta/performance/__init__.py
================================================
================================================
FILE: polars_ta/performance/drawdown.py
================================================
from polars import Expr
def ts_max_drawdown(close: Expr) -> Expr:
"""最大回撤"""
return close - close.cum_max()
def ts_max_drawdown_rate(close: Expr) -> Expr:
"""最大回撤率"""
return close / close.cum_max() - 1
================================================
FILE: polars_ta/performance/returns.py
================================================
from polars import Expr
from polars_ta.wq.arithmetic import log1p, expm1
def ts_cum_return(close: Expr) -> Expr:
"""
cumulative return
累计收益
"""
return close / close.drop_nulls().first()
def simple_to_log_return(x: Expr) -> Expr:
"""简单收益率 转 对数收益率"""
return log1p(x)
def log_to_simple_return(x: Expr) -> Expr:
"""对数收益率 转 简单收益率"""
return expm1(x)
================================================
FILE: polars_ta/prefix/__init__.py
================================================
================================================
FILE: polars_ta/prefix/cdl.py
================================================
from polars_ta.candles import * # noqa
================================================
FILE: polars_ta/prefix/labels.py
================================================
from polars_ta.labels import * # noqa
================================================
FILE: polars_ta/prefix/reports.py
================================================
from polars_ta.reports import * # noqa
================================================
FILE: polars_ta/prefix/ta.py
================================================
# this code is auto generated by tools/prefix_ta.py
from polars_ta.ta.momentum import APO as ts_APO # noqa
from polars_ta.ta.momentum import AROON as ts_AROON # noqa
from polars_ta.ta.momentum import MACD as ts_MACD # noqa
from polars_ta.ta.momentum import MOM as ts_MOM # noqa
from polars_ta.ta.momentum import PPO as ts_PPO # noqa
from polars_ta.ta.momentum import ROC as ts_ROC # noqa
from polars_ta.ta.momentum import ROCP as ts_ROCP # noqa
from polars_ta.ta.momentum import ROCR as ts_ROCR # noqa
from polars_ta.ta.momentum import ROCR100 as ts_ROCR100 # noqa
from polars_ta.ta.momentum import RSI as ts_RSI # noqa
from polars_ta.ta.momentum import RSV as ts_RSV # noqa
from polars_ta.ta.momentum import STOCHF as ts_STOCHF # noqa
from polars_ta.ta.momentum import TRIX as ts_TRIX # noqa
from polars_ta.ta.momentum import WILLR as ts_WILLR # noqa
from polars_ta.ta.operators import ADD # noqa
from polars_ta.ta.operators import DIV # noqa
from polars_ta.ta.operators import MAX as ts_MAX # noqa
from polars_ta.ta.operators import MAXINDEX as ts_MAXINDEX # noqa
from polars_ta.ta.operators import MIN as ts_MIN # noqa
from polars_ta.ta.operators import MININDEX as ts_MININDEX # noqa
from polars_ta.ta.operators import MUL # noqa
from polars_ta.ta.operators import SUB # noqa
from polars_ta.ta.operators import SUM as ts_SUM # noqa
from polars_ta.ta.overlap import BBANDS # noqa
from polars_ta.ta.overlap import DEMA as ts_DEMA # noqa
from polars_ta.ta.overlap import EMA as ts_EMA # noqa
from polars_ta.ta.overlap import KAMA as ts_KAMA # noqa
from polars_ta.ta.overlap import MIDPOINT as ts_MIDPOINT # noqa
from polars_ta.ta.overlap import MIDPRICE as ts_MIDPRICE # noqa
from polars_ta.ta.overlap import RMA as ts_RMA # noqa
from polars_ta.ta.overlap import SMA as ts_SMA # noqa
from polars_ta.ta.overlap import TEMA as ts_TEMA # noqa
from polars_ta.ta.overlap import TRIMA as ts_TRIMA # noqa
from polars_ta.ta.overlap import WMA as ts_WMA # noqa
from polars_ta.ta.price import AVGPRICE # noqa
from polars_ta.ta.price import MEDPRICE # noqa
from polars_ta.ta.price import TYPPRICE # noqa
from polars_ta.ta.price import WCLPRICE # noqa
from polars_ta.ta.statistic import BETA as ts_BETA # noqa
from polars_ta.ta.statistic import CORREL as ts_CORREL # noqa
from polars_ta.ta.statistic import LINEARREG as ts_LINEARREG # noqa
from polars_ta.ta.statistic import LINEARREG_ANGLE as ts_LINEARREG_ANGLE # noqa
from polars_ta.ta.statistic import LINEARREG_INTERCEPT as ts_LINEARREG_INTERCEPT # noqa
from polars_ta.ta.statistic import LINEARREG_SLOPE as ts_LINEARREG_SLOPE # noqa
from polars_ta.ta.statistic import STDDEV as ts_STDDEV # noqa
from polars_ta.ta.statistic import TSF as ts_TSF # noqa
from polars_ta.ta.statistic import VAR as ts_VAR # noqa
from polars_ta.ta.transform import ACOS # noqa
from polars_ta.ta.transform import ASIN # noqa
from polars_ta.ta.transform import ATAN # noqa
from polars_ta.ta.transform import CEIL # noqa
from polars_ta.ta.transform import COS # noqa
from polars_ta.ta.transform import COSH # noqa
from polars_ta.ta.transform import EXP # noqa
from polars_ta.ta.transform import FLOOR # noqa
from polars_ta.ta.transform import LN # noqa
from polars_ta.ta.transform import LOG10 # noqa
from polars_ta.ta.transform import SIN # noqa
from polars_ta.ta.transform import SINH # noqa
from polars_ta.ta.transform import SQRT # noqa
from polars_ta.ta.transform import TAN # noqa
from polars_ta.ta.transform import TANH # noqa
from polars_ta.ta.volatility import ATR as ts_ATR # noqa
from polars_ta.ta.volatility import NATR as ts_NATR # noqa
from polars_ta.ta.volatility import TRANGE as ts_TRANGE # noqa
from polars_ta.ta.volume import AD as ts_AD # noqa
from polars_ta.ta.volume import ADOSC as ts_ADOSC # noqa
from polars_ta.ta.volume import OBV as ts_OBV # noqa
================================================
FILE: polars_ta/prefix/talib.py
================================================
# this code is auto generated by tools/prefix_talib.py
from polars_ta.talib import HT_DCPERIOD as ts_HT_DCPERIOD # noqa
from polars_ta.talib import HT_DCPHASE as ts_HT_DCPHASE # noqa
from polars_ta.talib import HT_PHASOR as ts_HT_PHASOR # noqa
from polars_ta.talib import HT_SINE as ts_HT_SINE # noqa
from polars_ta.talib import HT_TRENDMODE as ts_HT_TRENDMODE # noqa
from polars_ta.talib import ADD # noqa
from polars_ta.talib import DIV # noqa
from polars_ta.talib import MAX # noqa
from polars_ta.talib import MAXINDEX # noqa
from polars_ta.talib import MIN # noqa
from polars_ta.talib import MININDEX # noqa
from polars_ta.talib import MINMAX # noqa
from polars_ta.talib import MINMAXINDEX # noqa
from polars_ta.talib import MULT # noqa
from polars_ta.talib import SUB # noqa
from polars_ta.talib import SUM # noqa
from polars_ta.talib import ACOS # noqa
from polars_ta.talib import ASIN # noqa
from polars_ta.talib import ATAN # noqa
from polars_ta.talib import CEIL # noqa
from polars_ta.talib import COS # noqa
from polars_ta.talib import COSH # noqa
from polars_ta.talib import EXP # noqa
from polars_ta.talib import FLOOR # noqa
from polars_ta.talib import LN # noqa
from polars_ta.talib import LOG10 # noqa
from polars_ta.talib import SIN # noqa
from polars_ta.talib import SINH # noqa
from polars_ta.talib import SQRT # noqa
from polars_ta.talib import TAN # noqa
from polars_ta.talib import TANH # noqa
from polars_ta.talib import ADX as ts_ADX # noqa
from polars_ta.talib import ADXR as ts_ADXR # noqa
from polars_ta.talib import APO as ts_APO # noqa
from polars_ta.talib import AROON as ts_AROON # noqa
from polars_ta.talib import AROONOSC as ts_AROONOSC # noqa
from polars_ta.talib import BOP as ts_BOP # noqa
from polars_ta.talib import CCI as ts_CCI # noqa
from polars_ta.talib import CMO as ts_CMO # noqa
from polars_ta.talib import DX as ts_DX # noqa
from polars_ta.talib import MACD as ts_MACD # noqa
from polars_ta.talib import MACDEXT as ts_MACDEXT # noqa
from polars_ta.talib import MACDFIX as ts_MACDFIX # noqa
from polars_ta.talib import MFI as ts_MFI # noqa
from polars_ta.talib import MINUS_DI as ts_MINUS_DI # noqa
from polars_ta.talib import MINUS_DM as ts_MINUS_DM # noqa
from polars_ta.talib import MOM as ts_MOM # noqa
from polars_ta.talib import PLUS_DI as ts_PLUS_DI # noqa
from polars_ta.talib import PLUS_DM as ts_PLUS_DM # noqa
from polars_ta.talib import PPO as ts_PPO # noqa
from polars_ta.talib import ROC as ts_ROC # noqa
from polars_ta.talib import ROCP as ts_ROCP # noqa
from polars_ta.talib import ROCR as ts_ROCR # noqa
from polars_ta.talib import ROCR100 as ts_ROCR100 # noqa
from polars_ta.talib import RSI as ts_RSI # noqa
from polars_ta.talib import STOCH as ts_STOCH # noqa
from polars_ta.talib import STOCHF as ts_STOCHF # noqa
from polars_ta.talib import STOCHRSI as ts_STOCHRSI # noqa
from polars_ta.talib import TRIX as ts_TRIX # noqa
from polars_ta.talib import ULTOSC as ts_ULTOSC # noqa
from polars_ta.talib import WILLR as ts_WILLR # noqa
from polars_ta.talib import BBANDS as ts_BBANDS # noqa
from polars_ta.talib import DEMA as ts_DEMA # noqa
from polars_ta.talib import EMA as ts_EMA # noqa
from polars_ta.talib import HT_TRENDLINE as ts_HT_TRENDLINE # noqa
from polars_ta.talib import KAMA as ts_KAMA # noqa
from polars_ta.talib import MA as ts_MA # noqa
from polars_ta.talib import MAMA as ts_MAMA # noqa
from polars_ta.talib import MAVP as ts_MAVP # noqa
from polars_ta.talib import MIDPOINT as ts_MIDPOINT # noqa
from polars_ta.talib import MIDPRICE as ts_MIDPRICE # noqa
from polars_ta.talib import SAR as ts_SAR # noqa
from polars_ta.talib import SAREXT as ts_SAREXT # noqa
from polars_ta.talib import SMA as ts_SMA # noqa
from polars_ta.talib import T3 as ts_T3 # noqa
from polars_ta.talib import TEMA as ts_TEMA # noqa
from polars_ta.talib import TRIMA as ts_TRIMA # noqa
from polars_ta.talib import WMA as ts_WMA # noqa
from polars_ta.talib import CDL2CROWS as ts_CDL2CROWS # noqa
from polars_ta.talib import CDL3BLACKCROWS as ts_CDL3BLACKCROWS # noqa
from polars_ta.talib import CDL3INSIDE as ts_CDL3INSIDE # noqa
from polars_ta.talib import CDL3LINESTRIKE as ts_CDL3LINESTRIKE # noqa
from polars_ta.talib import CDL3OUTSIDE as ts_CDL3OUTSIDE # noqa
from polars_ta.talib import CDL3STARSINSOUTH as ts_CDL3STARSINSOUTH # noqa
from polars_ta.talib import CDL3WHITESOLDIERS as ts_CDL3WHITESOLDIERS # noqa
from polars_ta.talib import CDLABANDONEDBABY as ts_CDLABANDONEDBABY # noqa
from polars_ta.talib import CDLADVANCEBLOCK as ts_CDLADVANCEBLOCK # noqa
from polars_ta.talib import CDLBELTHOLD as ts_CDLBELTHOLD # noqa
from polars_ta.talib import CDLBREAKAWAY as ts_CDLBREAKAWAY # noqa
from polars_ta.talib import CDLCLOSINGMARUBOZU as ts_CDLCLOSINGMARUBOZU # noqa
from polars_ta.talib import CDLCONCEALBABYSWALL as ts_CDLCONCEALBABYSWALL # noqa
from polars_ta.talib import CDLCOUNTERATTACK as ts_CDLCOUNTERATTACK # noqa
from polars_ta.talib import CDLDARKCLOUDCOVER as ts_CDLDARKCLOUDCOVER # noqa
from polars_ta.talib import CDLDOJI as ts_CDLDOJI # noqa
from polars_ta.talib import CDLDOJISTAR as ts_CDLDOJISTAR # noqa
from polars_ta.talib import CDLDRAGONFLYDOJI as ts_CDLDRAGONFLYDOJI # noqa
from polars_ta.talib import CDLENGULFING as ts_CDLENGULFING # noqa
from polars_ta.talib import CDLEVENINGDOJISTAR as ts_CDLEVENINGDOJISTAR # noqa
from polars_ta.talib import CDLEVENINGSTAR as ts_CDLEVENINGSTAR # noqa
from polars_ta.talib import CDLGAPSIDESIDEWHITE as ts_CDLGAPSIDESIDEWHITE # noqa
from polars_ta.talib import CDLGRAVESTONEDOJI as ts_CDLGRAVESTONEDOJI # noqa
from polars_ta.talib import CDLHAMMER as ts_CDLHAMMER # noqa
from polars_ta.talib import CDLHANGINGMAN as ts_CDLHANGINGMAN # noqa
from polars_ta.talib import CDLHARAMI as ts_CDLHARAMI # noqa
from polars_ta.talib import CDLHARAMICROSS as ts_CDLHARAMICROSS # noqa
from polars_ta.talib import CDLHIGHWAVE as ts_CDLHIGHWAVE # noqa
from polars_ta.talib import CDLHIKKAKE as ts_CDLHIKKAKE # noqa
from polars_ta.talib import CDLHIKKAKEMOD as ts_CDLHIKKAKEMOD # noqa
from polars_ta.talib import CDLHOMINGPIGEON as ts_CDLHOMINGPIGEON # noqa
from polars_ta.talib import CDLIDENTICAL3CROWS as ts_CDLIDENTICAL3CROWS # noqa
from polars_ta.talib import CDLINNECK as ts_CDLINNECK # noqa
from polars_ta.talib import CDLINVERTEDHAMMER as ts_CDLINVERTEDHAMMER # noqa
from polars_ta.talib import CDLKICKING as ts_CDLKICKING # noqa
from polars_ta.talib import CDLKICKINGBYLENGTH as ts_CDLKICKINGBYLENGTH # noqa
from polars_ta.talib import CDLLADDERBOTTOM as ts_CDLLADDERBOTTOM # noqa
from polars_ta.talib import CDLLONGLEGGEDDOJI as ts_CDLLONGLEGGEDDOJI # noqa
from polars_ta.talib import CDLLONGLINE as ts_CDLLONGLINE # noqa
from polars_ta.talib import CDLMARUBOZU as ts_CDLMARUBOZU # noqa
from polars_ta.talib import CDLMATCHINGLOW as ts_CDLMATCHINGLOW # noqa
from polars_ta.talib import CDLMATHOLD as ts_CDLMATHOLD # noqa
from polars_ta.talib import CDLMORNINGDOJISTAR as ts_CDLMORNINGDOJISTAR # noqa
from polars_ta.talib import CDLMORNINGSTAR as ts_CDLMORNINGSTAR # noqa
from polars_ta.talib import CDLONNECK as ts_CDLONNECK # noqa
from polars_ta.talib import CDLPIERCING as ts_CDLPIERCING # noqa
from polars_ta.talib import CDLRICKSHAWMAN as ts_CDLRICKSHAWMAN # noqa
from polars_ta.talib import CDLRISEFALL3METHODS as ts_CDLRISEFALL3METHODS # noqa
from polars_ta.talib import CDLSEPARATINGLINES as ts_CDLSEPARATINGLINES # noqa
from polars_ta.talib import CDLSHOOTINGSTAR as ts_CDLSHOOTINGSTAR # noqa
from polars_ta.talib import CDLSHORTLINE as ts_CDLSHORTLINE # noqa
from polars_ta.talib import CDLSPINNINGTOP as ts_CDLSPINNINGTOP # noqa
from polars_ta.talib import CDLSTALLEDPATTERN as ts_CDLSTALLEDPATTERN # noqa
from polars_ta.talib import CDLSTICKSANDWICH as ts_CDLSTICKSANDWICH # noqa
from polars_ta.talib import CDLTAKURI as ts_CDLTAKURI # noqa
from polars_ta.talib import CDLTASUKIGAP as ts_CDLTASUKIGAP # noqa
from polars_ta.talib import CDLTHRUSTING as ts_CDLTHRUSTING # noqa
from polars_ta.talib import CDLTRISTAR as ts_CDLTRISTAR # noqa
from polars_ta.talib import CDLUNIQUE3RIVER as ts_CDLUNIQUE3RIVER # noqa
from polars_ta.talib import CDLUPSIDEGAP2CROWS as ts_CDLUPSIDEGAP2CROWS # noqa
from polars_ta.talib import CDLXSIDEGAP3METHODS as ts_CDLXSIDEGAP3METHODS # noqa
from polars_ta.talib import AVGPRICE # noqa
from polars_ta.talib import MEDPRICE # noqa
from polars_ta.talib import TYPPRICE # noqa
from polars_ta.talib import WCLPRICE # noqa
from polars_ta.talib import BETA as ts_BETA # noqa
from polars_ta.talib import CORREL as ts_CORREL # noqa
from polars_ta.talib import LINEARREG as ts_LINEARREG # noqa
from polars_ta.talib import LINEARREG_ANGLE as ts_LINEARREG_ANGLE # noqa
from polars_ta.talib import LINEARREG_INTERCEPT as ts_LINEARREG_INTERCEPT # noqa
from polars_ta.talib import LINEARREG_SLOPE as ts_LINEARREG_SLOPE # noqa
from polars_ta.talib import STDDEV as ts_STDDEV # noqa
from polars_ta.talib import TSF as ts_TSF # noqa
from polars_ta.talib import VAR as ts_VAR # noqa
from polars_ta.talib import ATR as ts_ATR # noqa
from polars_ta.talib import NATR as ts_NATR # noqa
from polars_ta.talib import TRANGE as ts_TRANGE # noqa
from polars_ta.talib import AD as ts_AD # noqa
from polars_ta.talib import ADOSC as ts_ADOSC # noqa
from polars_ta.talib import OBV as ts_OBV # noqa
================================================
FILE: polars_ta/prefix/tdx.py
================================================
# this code is auto generated by tools/prefix_tdx.py
from polars_ta.tdx.arithmetic import ABS # noqa
from polars_ta.tdx.arithmetic import ACOS # noqa
from polars_ta.tdx.arithmetic import ADD # noqa
from polars_ta.tdx.arithmetic import ASIN # noqa
from polars_ta.tdx.arithmetic import ATAN # noqa
from polars_ta.tdx.arithmetic import BETWEEN # noqa
from polars_ta.tdx.arithmetic import CEILING # noqa
from polars_ta.tdx.arithmetic import COS # noqa
from polars_ta.tdx.arithmetic import EXP # noqa
from polars_ta.tdx.arithmetic import FLOOR # noqa
from polars_ta.tdx.arithmetic import FRACPART # noqa
from polars_ta.tdx.arithmetic import LN # noqa
from polars_ta.tdx.arithmetic import LOG # noqa
from polars_ta.tdx.arithmetic import MAX # noqa
from polars_ta.tdx.arithmetic import MIN # noqa
from polars_ta.tdx.arithmetic import MOD # noqa
from polars_ta.tdx.arithmetic import POW # noqa
from polars_ta.tdx.arithmetic import REVERSE # noqa
from polars_ta.tdx.arithmetic import ROUND # noqa
from polars_ta.tdx.arithmetic import ROUND2 # noqa
from polars_ta.tdx.arithmetic import SGN # noqa
from polars_ta.tdx.arithmetic import SIGN # noqa
from polars_ta.tdx.arithmetic import SIN # noqa
from polars_ta.tdx.arithmetic import SQRT # noqa
from polars_ta.tdx.arithmetic import SUB # noqa
from polars_ta.tdx.arithmetic import TAN # noqa
from polars_ta.tdx.choice import IF # noqa
from polars_ta.tdx.choice import IFF # noqa
from polars_ta.tdx.choice import IFN # noqa
from polars_ta.tdx.choice import VALUEWHEN as ts_VALUEWHEN # noqa
from polars_ta.tdx.energy import BRAR_AR as ts_BRAR_AR # noqa
from polars_ta.tdx.energy import BRAR_BR as ts_BRAR_BR # noqa
from polars_ta.tdx.energy import CR as ts_CR # noqa
from polars_ta.tdx.energy import MASS as ts_MASS # noqa
from polars_ta.tdx.energy import PSY as ts_PSY # noqa
from polars_ta.tdx.logical import ALL as ts_ALL # noqa
from polars_ta.tdx.logical import ANY as ts_ANY # noqa
from polars_ta.tdx.logical import CROSS as ts_CROSS # noqa
from polars_ta.tdx.logical import DOWNNDAY as ts_DOWNNDAY # noqa
from polars_ta.tdx.logical import EVERY as ts_EVERY # noqa
from polars_ta.tdx.logical import EXIST as ts_EXIST # noqa
from polars_ta.tdx.logical import EXISTR as ts_EXISTR # noqa
from polars_ta.tdx.logical import LAST as ts_LAST # noqa
from polars_ta.tdx.logical import LONGCROSS as ts_LONGCROSS # noqa
from polars_ta.tdx.logical import NDAY as ts_NDAY # noqa
from polars_ta.tdx.logical import NOT # noqa
from polars_ta.tdx.logical import UPNDAY as ts_UPNDAY # noqa
from polars_ta.tdx.moving_average import BBI as ts_BBI # noqa
from polars_ta.tdx.over_bought_over_sold import ATR as ts_ATR # noqa
from polars_ta.tdx.over_bought_over_sold import BIAS as ts_BIAS # noqa
from polars_ta.tdx.over_bought_over_sold import CCI as ts_CCI # noqa
from polars_ta.tdx.over_bought_over_sold import KDJ as ts_KDJ # noqa
from polars_ta.tdx.over_bought_over_sold import MFI as ts_MFI # noqa
from polars_ta.tdx.over_bought_over_sold import MTM as ts_MTM # noqa
from polars_ta.tdx.over_bought_over_sold import RSI as ts_RSI # noqa
from polars_ta.tdx.over_bought_over_sold import RSV as ts_RSV # noqa
from polars_ta.tdx.pattern import ts_WINNER_COST # noqa
from polars_ta.tdx.pattern_feature import 仙人指路 as ts_仙人指路 # noqa
from polars_ta.tdx.pattern_feature import 低开大阳线 as ts_低开大阳线 # noqa
from polars_ta.tdx.pattern_feature import 低点搜寻 as ts_低点搜寻 # noqa
from polars_ta.tdx.pattern_feature import 出水芙蓉 as ts_出水芙蓉 # noqa
from polars_ta.tdx.pattern_feature import 出水芙蓉II as ts_出水芙蓉II # noqa
from polars_ta.tdx.pattern_feature import 剑 as ts_剑 # noqa
from polars_ta.tdx.pattern_feature import 单阳不破选股 as ts_单阳不破选股 # noqa
from polars_ta.tdx.pattern_feature import 四串阳 as ts_四串阳 # noqa
from polars_ta.tdx.pattern_feature import 四串阴 as ts_四串阴 # noqa
from polars_ta.tdx.pattern_feature import 回补跳空向上缺口 as ts_回补跳空向上缺口 # noqa
from polars_ta.tdx.pattern_feature import 均线多头排列 as ts_均线多头排列 # noqa
from polars_ta.tdx.pattern_feature import 均线空头排列 as ts_均线空头排列 # noqa
from polars_ta.tdx.pattern_feature import 天量法则 as ts_天量法则 # noqa
from polars_ta.tdx.pattern_feature import 强势整理 as ts_强势整理 # noqa
from polars_ta.tdx.pattern_feature import 揉搓线 as ts_揉搓线 # noqa
from polars_ta.tdx.pattern_feature import 早晨之星 as ts_早晨之星 # noqa
from polars_ta.tdx.pattern_feature import 旭日初升 as ts_旭日初升 # noqa
from polars_ta.tdx.pattern_feature import 突破 as ts_突破 # noqa
from polars_ta.tdx.pattern_feature import 老鸭头 as ts_老鸭头 # noqa
from polars_ta.tdx.pattern_feature import 蜻蜓点水 as ts_蜻蜓点水 # noqa
from polars_ta.tdx.pattern_feature import 跳空缺口选股 as ts_跳空缺口选股 # noqa
from polars_ta.tdx.pattern_feature import 近日创历史新低 as ts_近日创历史新低 # noqa
from polars_ta.tdx.pattern_feature import 近日创历史新高 as ts_近日创历史新高 # noqa
from polars_ta.tdx.pattern_feature import 高开大阴线 as ts_高开大阴线 # noqa
from polars_ta.tdx.pattern_feature import 鸳鸯底 as ts_鸳鸯底 # noqa
from polars_ta.tdx.pressure_support import BOLL as ts_BOLL # noqa
from polars_ta.tdx.pressure_support import BOLL_M as ts_BOLL_M # noqa
from polars_ta.tdx.reference import BARSLAST as ts_BARSLAST # noqa
from polars_ta.tdx.reference import BARSLASTCOUNT as ts_BARSLASTCOUNT # noqa
from polars_ta.tdx.reference import BARSSINCE as ts_BARSSINCE # noqa
from polars_ta.tdx.reference import BARSSINCEN as ts_BARSSINCEN # noqa
from polars_ta.tdx.reference import COUNT as ts_COUNT # noqa
from polars_ta.tdx.reference import CUMSUM as ts_CUMSUM # noqa
from polars_ta.tdx.reference import DIFF as ts_DIFF # noqa
from polars_ta.tdx.reference import DMA as ts_DMA # noqa
from polars_ta.tdx.reference import EMA as ts_EMA # noqa
from polars_ta.tdx.reference import EXPMA as ts_EXPMA # noqa
from polars_ta.tdx.reference import EXPMEMA as ts_EXPMEMA # noqa
from polars_ta.tdx.reference import FILTER as ts_FILTER # noqa
from polars_ta.tdx.reference import HHV as ts_HHV # noqa
from polars_ta.tdx.reference import HHVBARS as ts_HHVBARS # noqa
from polars_ta.tdx.reference import HOD as ts_HOD # noqa
from polars_ta.tdx.reference import LLV as ts_LLV # noqa
from polars_ta.tdx.reference import LLVBARS as ts_LLVBARS # noqa
from polars_ta.tdx.reference import LOD as ts_LOD # noqa
from polars_ta.tdx.reference import LOWRANGE # noqa
from polars_ta.tdx.reference import MA as ts_MA # noqa
from polars_ta.tdx.reference import MAX # noqa
from polars_ta.tdx.reference import MEMA as ts_MEMA # noqa
from polars_ta.tdx.reference import MIN # noqa
from polars_ta.tdx.reference import MULAR as ts_MULAR # noqa
from polars_ta.tdx.reference import RANGE # noqa
from polars_ta.tdx.reference import REF as ts_REF # noqa
from polars_ta.tdx.reference import REFX as ts_REFX # noqa
from polars_ta.tdx.reference import SMA_CN as ts_SMA_CN # noqa
from polars_ta.tdx.reference import SUM as ts_SUM # noqa
from polars_ta.tdx.reference import SUMIF as ts_SUMIF # noqa
from polars_ta.tdx.reference import TMA as ts_TMA # noqa
from polars_ta.tdx.reference import TR as ts_TR # noqa
from polars_ta.tdx.reference import WMA as ts_WMA # noqa
from polars_ta.tdx.statistic import AVEDEV as ts_AVEDEV # noqa
from polars_ta.tdx.statistic import COVAR as ts_COVAR # noqa
from polars_ta.tdx.statistic import DEVSQ as ts_DEVSQ # noqa
from polars_ta.tdx.statistic import RELATE as ts_RELATE # noqa
from polars_ta.tdx.statistic import SLOPE as ts_SLOPE # noqa
from polars_ta.tdx.statistic import STD as ts_STD # noqa
from polars_ta.tdx.statistic import STDDEV as ts_STDDEV # noqa
from polars_ta.tdx.statistic import STDP as ts_STDP # noqa
from polars_ta.tdx.statistic import VAR as ts_VAR # noqa
from polars_ta.tdx.statistic import VARP as ts_VARP # noqa
from polars_ta.tdx.statistic import ts_up_stat # noqa
from polars_ta.tdx.times import FROMOPEN # noqa
from polars_ta.tdx.times import FROMOPEN_1 # noqa
from polars_ta.tdx.trend import ADX as ts_ADX # noqa
from polars_ta.tdx.trend import ADXR as ts_ADXR # noqa
from polars_ta.tdx.trend import DPO as ts_DPO # noqa
from polars_ta.tdx.trend import EMV as ts_EMV # noqa
from polars_ta.tdx.trend import MINUS_DI as ts_MINUS_DI # noqa
from polars_ta.tdx.trend import MINUS_DM as ts_MINUS_DM # noqa
from polars_ta.tdx.trend import PLUS_DI as ts_PLUS_DI # noqa
from polars_ta.tdx.trend import PLUS_DM as ts_PLUS_DM # noqa
from polars_ta.tdx.trend_feature import N天内出现以涨停收盘 as ts_N天内出现以涨停收盘 # noqa
from polars_ta.tdx.trend_feature import N天内出现涨停 as ts_N天内出现涨停 # noqa
from polars_ta.tdx.trend_feature import N天内有跳空向上缺口 as ts_N天内有跳空向上缺口 # noqa
from polars_ta.tdx.trend_feature import N天内经常涨停 as ts_N天内经常涨停 # noqa
from polars_ta.tdx.trend_feature import N日内上涨多于下跌 as ts_N日内上涨多于下跌 # noqa
from polars_ta.tdx.trend_feature import N日内下跌多于上涨 as ts_N日内下跌多于上涨 # noqa
from polars_ta.tdx.trend_feature import N日内创新低 as ts_N日内创新低 # noqa
from polars_ta.tdx.trend_feature import N日内创新高 as ts_N日内创新高 # noqa
from polars_ta.tdx.trend_feature import N日内阳线多于阴线 as ts_N日内阳线多于阴线 # noqa
from polars_ta.tdx.trend_feature import N日内阴线多于阳线 as ts_N日内阴线多于阳线 # noqa
from polars_ta.tdx.trend_feature import 下跌多日再放量上涨 as ts_下跌多日再放量上涨 # noqa
from polars_ta.tdx.trend_feature import 价量渐低后阳包阴 as ts_价量渐低后阳包阴 # noqa
from polars_ta.tdx.trend_feature import 单日放量 as ts_单日放量 # noqa
from polars_ta.tdx.trend_feature import 小步碎阳 as ts_小步碎阳 # noqa
from polars_ta.tdx.trend_feature import 平台整理 as ts_平台整理 # noqa
from polars_ta.tdx.trend_feature import 拉升后多日调整 as ts_拉升后多日调整 # noqa
from polars_ta.tdx.trend_feature import 持续放量 as ts_持续放量 # noqa
from polars_ta.tdx.trend_feature import 持续缩量 as ts_持续缩量 # noqa
from polars_ta.tdx.trend_feature import 放量上攻 as ts_放量上攻 # noqa
from polars_ta.tdx.trend_feature import 昨日底部十字星 as ts_昨日底部十字星 # noqa
from polars_ta.tdx.trend_feature import 温和放量上攻 as ts_温和放量上攻 # noqa
from polars_ta.tdx.trend_feature import 突然放量 as ts_突然放量 # noqa
from polars_ta.tdx.trend_feature import 突破长期盘整 as ts_突破长期盘整 # noqa
from polars_ta.tdx.trend_feature import 跳空高开或低开 as ts_跳空高开或低开 # noqa
from polars_ta.tdx.trend_feature import 连续N天收阳线 as ts_连续N天收阳线 # noqa
from polars_ta.tdx.trend_feature import 连续N天收阴线 as ts_连续N天收阴线 # noqa
from polars_ta.tdx.trend_feature import 间隔放量 as ts_间隔放量 # noqa
from polars_ta.tdx.trend_feature import 阶段放量 as ts_阶段放量 # noqa
from polars_ta.tdx.trend_feature import 阶段缩量 as ts_阶段缩量 # noqa
from polars_ta.tdx.volume import OBV as ts_OBV # noqa
from polars_ta.tdx.volume import VR as ts_VR # noqa
================================================
FILE: polars_ta/prefix/vec.py
================================================
# this code is auto generated by tools/prefix_vec.py
from polars_ta.wq.vector import vec_avg as cs_vec_avg # noqa
from polars_ta.wq.vector import vec_choose as cs_vec_choose # noqa
from polars_ta.wq.vector import vec_count as cs_vec_count # noqa
from polars_ta.wq.vector import vec_ir as cs_vec_ir # noqa
from polars_ta.wq.vector import vec_kurtosis as cs_vec_kurtosis # noqa
from polars_ta.wq.vector import vec_l2_norm as cs_vec_l2_norm # noqa
from polars_ta.wq.vector import vec_max as cs_vec_max # noqa
from polars_ta.wq.vector import vec_median as cs_vec_median # noqa
from polars_ta.wq.vector import vec_min as cs_vec_min # noqa
from polars_ta.wq.vector import vec_norm as cs_vec_norm # noqa
from polars_ta.wq.vector import vec_percentage as cs_vec_percentage # noqa
from polars_ta.wq.vector import vec_powersum as cs_vec_powersum # noqa
from polars_ta.wq.vector import vec_range as cs_vec_range # noqa
from polars_ta.wq.vector import vec_skewness as cs_vec_skewness # noqa
from polars_ta.wq.vector import vec_stddev as cs_vec_stddev # noqa
from polars_ta.wq.vector import vec_sum as cs_vec_sum # noqa
================================================
FILE: polars_ta/prefix/wq.py
================================================
from polars_ta.wq import * # noqa
================================================
FILE: polars_ta/reports/__init__.py
================================================
from polars_ta.reports.cicc import * # noqa
================================================
FILE: polars_ta/reports/cicc.py
================================================
from polars import Expr
from polars_ta.wq import ts_corr, ts_zscore, ts_std_dev, ts_regression_slope
def ts_RSRS_R2(high: Expr, low: Expr, n: int = 18, m: int = 600) -> Expr:
"""光大RSRS指标,中金QRS指标,R^2调整
References
----------
中金:金融工程视角下的技术择时艺术
"""
a = ts_corr(high, low, n)
return ts_zscore(ts_std_dev(high, n) / ts_std_dev(low, n) * a, m) * (a ** 2)
def ts_RSRS(high: Expr, low: Expr, n: int = 18, m: int = 600) -> Expr:
"""光大RSRS指标,中金QRS指标
References
----------
中金:金融工程视角下的技术择时艺术
"""
return ts_zscore(ts_regression_slope(high, low, n), m)
================================================
FILE: polars_ta/ta/README.md
================================================
# polars_ta.ta
1. Files in this folder mimic `talib`, and implement `polars` versions for the same functions
2. Since we reduce the functino calls between `Python` and `C` code, it should be faster than `talib`.
3. We first try to import from `ta`, then from `wq`, and only implement the function if it is not available.
4. When there is a circular dependency, we use `polars` instead.
1. 本文件夹中模仿`talib`,实现同名函数的`polars`版
2. 由于减少了python与c来回调用,理论上比直接调用`talib`快
3. 优先从`ta`中导入,然后从`wq`中导入,没有的才实现
4. 出现循环依赖时,使用`polars`
================================================
FILE: polars_ta/ta/__init__.py
================================================
from polars_ta.ta.momentum import * # noqa
from polars_ta.ta.operators import * # noqa
from polars_ta.ta.overlap import * # noqa
from polars_ta.ta.price import * # noqa
from polars_ta.ta.statistic import * # noqa
from polars_ta.ta.transform import * # noqa
from polars_ta.ta.volatility import * # noqa
from polars_ta.ta.volume import * # noqa
================================================
FILE: polars_ta/ta/momentum.py
================================================
from polars import Expr, when, struct
from polars_ta import TA_EPSILON
from polars_ta.ta.operators import MAX
from polars_ta.ta.operators import MIN
from polars_ta.ta.overlap import EMA
from polars_ta.ta.overlap import RMA
from polars_ta.ta.overlap import SMA
from polars_ta.wq.arithmetic import max_
from polars_ta.wq.time_series import ts_delta, ts_arg_max, ts_arg_min
from polars_ta.wq.time_series import ts_returns
def APO(close: Expr, fastperiod: int = 12, slowperiod: int = 26, matype: int = 0) -> Expr:
if matype == 0:
return SMA(close, fastperiod) - SMA(close, slowperiod)
else:
return EMA(close, fastperiod) - EMA(close, slowperiod)
def AROON(high: Expr, low: Expr, timeperiod: int = 14) -> Expr:
"""
下轨:(N-LLVBARS(L,N))/N*100,COLORGREEN;
上轨:(N-HHVBARS(H,N))/N*100,COLORRED;
Notes
-----
You cannot use pd.Series.rolling().arg_max() with reverse order, which leads to a larger result when there are two or more high points
so we don't use pandas
pd.Series.rolling().arg_max()没有逆序,导致出现两个及以上最高点时,结果偏大
"""
aroondown = 1 - ts_arg_min(low, timeperiod, reverse=True) / timeperiod
aroonup = 1 - ts_arg_max(high, timeperiod, reverse=True) / timeperiod
return struct(aroondown=aroondown, aroonup=aroonup)
def MACD(close: Expr, fastperiod: int = 12, slowperiod: int = 26, signalperiod: int = 9) -> Expr:
"""MACD
Notes
-----
When counting how many data we have
we refer to `slowperiod`, while `talib.MACD` refers to `fastperiod`
talib.MACD有效数据按fastperiod,而本项目按slowperiod
"""
macd = EMA(close, fastperiod) - EMA(close, slowperiod)
macdsignal = EMA(macd, signalperiod)
macdhist = (macd - macdsignal) # * 2 # 中国版多了乘2
return struct(macd=macd, macdsignal=macdsignal, macdhist=macdhist)
def MOM(close: Expr, timeperiod: int = 10) -> Expr:
"""MOM = (price - prevPrice) [Momentum]
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MOM.c#L200
"""
return ts_delta(close, timeperiod)
def PPO(close: Expr, fastperiod: int = 12, slowperiod: int = 26, matype: int = 0) -> Expr:
if matype == 0:
return SMA(close, fastperiod) / SMA(close, slowperiod) - 1
else:
return EMA(close, fastperiod) / EMA(close, slowperiod) - 1
def ROC(close: Expr, timeperiod: int = 10) -> Expr:
"""ROC = ((price/prevPrice)-1)*100 [Rate of change]
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ROC.c#L200
"""
return ROCP(close, timeperiod) * 100
def ROCP(close: Expr, timeperiod: int = 10) -> Expr:
"""ROCP = (price-prevPrice)/prevPrice [Rate of change Percentage]
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ROCP.c#L202
"""
return ts_returns(close, timeperiod)
def ROCR(close: Expr, timeperiod: int = 10) -> Expr:
"""ROCR = (price/prevPrice) [Rate of change ratio]
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ROCR.c#L203
"""
return close / close.shift(timeperiod)
def ROCR100(close: Expr, timeperiod: int = 10) -> Expr:
"""ROCR100 = (price/prevPrice)*100 [Rate of change ratio 100 Scale]
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ROCR100.c#L203
"""
return ROCR(close, timeperiod) * 100
def RSI(close: Expr, timeperiod: int = 14) -> Expr:
dif = close.diff().fill_null(0)
return RMA(max_(dif, 0), timeperiod) / (RMA(dif.abs(), timeperiod) + TA_EPSILON) # * 100
def STOCHF(high: Expr, low: Expr, close: Expr, fastk_period: int = 5, fastd_period: int = 3) -> Expr:
fastk = RSV(high, low, close, fastk_period)
fastd = SMA(fastk, fastd_period)
return struct(fastk=fastk, fastd=fastd)
def TRIX(close: Expr, timeperiod: int = 30) -> Expr:
EMA1 = EMA(close, timeperiod)
EMA2 = EMA(EMA1, timeperiod)
EMA3 = EMA(EMA2, timeperiod)
return ROCP(EMA3, 1)
def RSV(high: Expr, low: Expr, close: Expr, timeperiod: int = 5) -> Expr:
"""RSV=STOCHF_FASTK
(Today's Close - LowestLow)
FASTK(Kperiod) = --------------------------- * 100
(HighestHigh - LowestLow)
Notes
-----
RSV = STOCHF_FASTK。没乘以100
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_STOCHF.c#L279
"""
a = MAX(high, timeperiod)
b = MIN(low, timeperiod)
# return (close - b) / (a - b + TA_EPSILON)
return when(a != b).then((close - b) / (a - b)).otherwise(0)
def WILLR(high: Expr, low: Expr, close: Expr, timeperiod: int = 14) -> Expr:
"""威廉指标
Notes
-----
WILLR=1-RSV
References
----------
- https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_WILLR.c#L294
- https://www.investopedia.com/terms/w/williamsr.asp
- https://school.stockcharts.com/doku.php?id=technical_indicators:williams_r
"""
a = MAX(high, timeperiod)
b = MIN(low, timeperiod)
# return (a - close) / (a - b + TA_EPSILON)
return when(a != b).then((a - close) / (a - b)).otherwise(0)
================================================
FILE: polars_ta/ta/operators.py
================================================
"""
通过`import`直接导入或更名的函数
```python
from polars_ta.wq.arithmetic import add as ADD # noqa
from polars_ta.wq.arithmetic import divide as DIV # noqa
from polars_ta.wq.arithmetic import multiply as MUL # noqa
from polars_ta.wq.arithmetic import subtract as SUB # noqa
from polars_ta.wq.time_series import ts_max as MAX # noqa
from polars_ta.wq.time_series import ts_min as MIN # noqa
from polars_ta.wq.time_series import ts_sum as SUM # noqa
```
"""
from polars import Expr
from polars_ta.wq.arithmetic import add as ADD # noqa
from polars_ta.wq.arithmetic import divide as DIV # noqa
from polars_ta.wq.arithmetic import multiply as MUL # noqa
from polars_ta.wq.arithmetic import subtract as SUB # noqa
from polars_ta.wq.time_series import ts_arg_max
from polars_ta.wq.time_series import ts_arg_min
from polars_ta.wq.time_series import ts_max as MAX # noqa
from polars_ta.wq.time_series import ts_min as MIN # noqa
from polars_ta.wq.time_series import ts_sum as SUM # noqa
def MAXINDEX(close: Expr, timeperiod: int = 30) -> Expr:
"""
Notes
-----
Comparing to `ts_arg_max` this also marks the abs. position of the max value
与ts_arg_max的区别是,标记了每个区间最大值的绝对位置,可用来画图标记
Examples
--------
```python
from polars_ta.ta import MAXINDEX as ta_MAXINDEX
from polars_ta.talib import MAXINDEX as talib_MAXINDEX
from polars_ta.wq import ts_arg_max
df = pl.DataFrame({
'a': [6, 2, 8, 5, 9, 4],
}).with_columns(
out1=ts_arg_max(pl.col('a'), 3),
out2=ta_MAXINDEX(pl.col('a'), 3),
out3=talib_MAXINDEX(pl.col('a'), 3),
)
shape: (6, 4)
┌─────┬──────┬──────┬──────┐
│ a ┆ out1 ┆ out2 ┆ out3 │
│ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ u16 ┆ i64 ┆ i32 │
╞═════╪══════╪══════╪══════╡
│ 6 ┆ null ┆ null ┆ 0 │
│ 2 ┆ null ┆ null ┆ 0 │
│ 8 ┆ 0 ┆ 2 ┆ 2 │
│ 5 ┆ 1 ┆ 2 ┆ 2 │
│ 9 ┆ 0 ┆ 4 ┆ 4 │
│ 4 ┆ 1 ┆ 4 ┆ 4 │
└─────┴──────┴──────┴──────┘
```
"""
a = close.cum_count()
b = ts_arg_max(close, timeperiod)
return a - b - 1
def MININDEX(close: Expr, timeperiod: int = 30) -> Expr:
"""
Examples
--------
```python
from polars_ta.ta import MININDEX as ta_MININDEX
from polars_ta.talib import MININDEX as talib_MININDEX
from polars_ta.wq import ts_arg_min
df = pl.DataFrame({
'a': [6, 2, 8, 5, 9, 4],
}).with_columns(
out1=ts_arg_min(pl.col('a'), 3),
out2=ta_MININDEX(pl.col('a'), 3),
out3=talib_MININDEX(pl.col('a'), 3),
)
shape: (6, 4)
┌─────┬──────┬──────┬──────┐
│ a ┆ out1 ┆ out2 ┆ out3 │
│ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ u16 ┆ i64 ┆ i32 │
╞═════╪══════╪══════╪══════╡
│ 6 ┆ null ┆ null ┆ 0 │
│ 2 ┆ null ┆ null ┆ 0 │
│ 8 ┆ 1 ┆ 1 ┆ 1 │
│ 5 ┆ 2 ┆ 1 ┆ 1 │
│ 9 ┆ 1 ┆ 3 ┆ 3 │
│ 4 ┆ 0 ┆ 5 ┆ 5 │
└─────┴──────┴──────┴──────┘
```
"""
a = close.cum_count()
b = ts_arg_min(close, timeperiod)
return a - b - 1
================================================
FILE: polars_ta/ta/overlap.py
================================================
from math import ceil, floor
from polars import Expr, struct
from polars_ta.ta.operators import MAX
from polars_ta.ta.operators import MIN
from polars_ta.ta.statistic import STDDEV
from polars_ta.wq.time_series import ts_decay_linear as WMA # noqa
from polars_ta.wq.time_series import ts_mean as SMA # noqa
def BBANDS(close: Expr, timeperiod: float = 5.0, nbdevup: float = 2.0, nbdevdn: float = 2.0, matype: float = 0.0) -> Expr:
middleband = SMA(close, timeperiod)
stddev = STDDEV(close, timeperiod)
return struct(upperband=middleband + stddev * nbdevup, middleband=middleband, lowerband=middleband - stddev * nbdevdn)
def DEMA(close: Expr, timeperiod: int = 30) -> Expr:
EMA1 = EMA(close, timeperiod)
EMA2 = EMA(EMA1, timeperiod)
return EMA1 * 2 - EMA2
def EMA(close: Expr, timeperiod: int = 30) -> Expr:
"""
References
----------
https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.ewm_mean.html#polars.Expr.ewm_mean
"""
# 相当于alpha=2/(1+timeperiod)
return close.ewm_mean(span=timeperiod, adjust=False, min_samples=timeperiod)
def KAMA(close: Expr, timeperiod: int = 30) -> Expr:
raise
def MIDPOINT(close: Expr, timeperiod: int = 14) -> Expr:
"""MIDPOINT = (Highest Value + Lowest Value)/2
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MIDPOINT.c#L198
"""
return (MAX(close, timeperiod) + MIN(close, timeperiod)) / 2
def MIDPRICE(high: Expr, low: Expr, timeperiod: int = 14) -> Expr:
"""MIDPRICE = (Highest High + Lowest Low)/2
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MIDPRICE.c#L202
"""
return (MAX(high, timeperiod) + MIN(low, timeperiod)) / 2
def RMA(close: Expr, timeperiod: int = 30) -> Expr:
"""TA-Lib does not provide this algorithm explicitly, it is just put here for convenience
TA-Lib没有明确的提供此算法,这里只是为了调用方便而放在此处
References
----------
https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.ewm_mean.html#polars.Expr.ewm_mean
https://github.com/twopirllc/pandas-ta/blob/main/pandas_ta/overlap/rma.py
"""
return close.ewm_mean(alpha=1 / timeperiod, adjust=False, min_samples=timeperiod)
def TEMA(close: Expr, timeperiod: int = 30) -> Expr:
"""
Notes
-----
todo: if the nesting level is too deep, maybe call talib.TEMA directly
嵌套层数过多,也许直接调用talib.TEMA更快
"""
EMA1 = EMA(close, timeperiod)
EMA2 = EMA(EMA1, timeperiod)
EMA3 = EMA(EMA2, timeperiod)
return (EMA1 - EMA2) * 3 + EMA3
def TRIMA(close: Expr, timeperiod: int = 30) -> Expr:
SMA1 = SMA(close, ceil(timeperiod / 2))
return SMA(SMA1, floor(timeperiod / 2) + 1)
================================================
FILE: polars_ta/ta/price.py
================================================
from polars import Expr
def AVGPRICE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
"""(open + high + low + close) / 4
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_AVGPRICE.c#L187
"""
return (open + high + low + close) / 4
def MEDPRICE(high: Expr, low: Expr) -> Expr:
"""(high + low) / 2
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MEDPRICE.c#L180
"""
return (high + low) / 2
def TYPPRICE(high: Expr, low: Expr, close: Expr) -> Expr:
"""(high + low + close) / 3
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_TYPPRICE.c#L185
"""
return (high + low + close) / 3
def WCLPRICE(high: Expr, low: Expr, close: Expr) -> Expr:
"""(high + low + close * 2) / 4
References
----------
https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_WCLPRICE.c#L184
"""
return (high + low + close * 2) / 4
================================================
FILE: polars_ta/ta/statistic.py
================================================
"""
通过`import`直接导入或更名的函数
```python
from polars_ta.wq.time_series import ts_corr as CORREL # noqa
```
"""
from polars import Expr
from polars_ta.wq.time_series import ts_corr as CORREL # noqa
from polars_ta.wq.time_series import ts_std_dev
def BETA(high: Expr, low: Expr, timeperiod: int = 5) -> Expr:
raise
def LINEARREG(close: Expr, timeperiod: int = 14) -> Expr:
raise
def LINEARREG_ANGLE(close: Expr, timeperiod: int = 14) -> Expr:
raise
def LINEARREG_INTERCEPT(close: Expr, timeperiod: int = 14) -> Expr:
raise
def LINEARREG_SLOPE(close: Expr, timeperiod: int = 14) -> Expr:
raise
def STDDEV(close: Expr, timeperiod: int = 5, nbdev: float = 1) -> Expr:
return ts_std_dev(close, timeperiod, ddof=0) * nbdev
def TSF(close: Expr, timeperiod: int = 14) -> Expr:
raise
def VAR(close: Expr, timeperiod: int = 5, nbdev: float = 1) -> Expr:
return close.rolling_var(timeperiod, ddof=0) * nbdev
================================================
FILE: polars_ta/ta/transform.py
================================================
"""
通过`import`直接导入或更名的函数
```python
from polars_ta.wq.arithmetic import arc_cos as ACOS # noqa
from polars_ta.wq.arithmetic import arc_sin as ASIN # noqa
from polars_ta.wq.arithmetic import arc_tan as ATAN # noqa
from polars_ta.wq.arithmetic import ceiling as CEIL # noqa
from polars_ta.wq.arithmetic import cos as COS # noqa
from polars_ta.wq.arithmetic import cosh as COSH # noqa
from polars_ta.wq.arithmetic import exp as EXP # noqa
from polars_ta.wq.arithmetic import floor as FLOOR # noqa
from polars_ta.wq.arithmetic import log as LN # noqa
from polars_ta.wq.arithmetic import log10 as LOG10 # noqa
from polars_ta.wq.arithmetic import sin as SIN # noqa
from polars_ta.wq.arithmetic import sinh as SINH # noqa
from polars_ta.wq.arithmetic import sqrt as SQRT # noqa
from polars_ta.wq.arithmetic import tan as TAN # noqa
from polars_ta.wq.arithmetic import tanh as TANH # noqa
```
"""
from polars_ta.wq.arithmetic import arc_cos as ACOS # noqa
from polars_ta.wq.arithmetic import arc_sin as ASIN # noqa
from polars_ta.wq.arithmetic import arc_tan as ATAN # noqa
from polars_ta.wq.arithmetic import ceiling as CEIL # noqa
from polars_ta.wq.arithmetic import cos as COS # noqa
from polars_ta.wq.arithmetic import cosh as COSH # noqa
from polars_ta.wq.arithmetic import exp as EXP # noqa
from polars_ta.wq.arithmetic import floor as FLOOR # noqa
from polars_ta.wq.arithmetic import log as LN # noqa
from polars_ta.wq.arithmetic import log10 as LOG10 # noqa
from polars_ta.wq.arithmetic import sin as SIN # noqa
from polars_ta.wq.arithmetic import sinh as SINH # noqa
from polars_ta.wq.arithmetic import sqrt as SQRT # noqa
from polars_ta.wq.arithmetic import tan as TAN # noqa
from polars_ta.wq.arithmetic import tanh as TANH # noqa
================================================
FILE: polars_ta/ta/volatility.py
================================================
from polars import Expr, max_horizontal
from polars_ta.ta.overlap import RMA
def TRANGE(high: Expr, low: Expr, close: Expr) -> Expr:
"""
Notes
-----
the 0-th position is `x` rather than `nan` in talib
第0位置为max(x,nan,nan)=x,比talib多一个值
"""
prev_close = close.shift(1)
tr1 = high - low
tr2 = (high - prev_close).abs()
tr3 = (low - prev_close).abs()
return max_horizontal(tr1, tr2, tr3)
def ATR(high: Expr, low: Expr, close: Expr, timeperiod: int = 14) -> Expr:
""""""
return RMA(TRANGE(high, low, close), timeperiod)
def NATR(high: Expr, low: Expr, close: Expr, timeperiod: int = 14) -> Expr:
"""
Notes
-----
talib.ATR multiples another 100
talib.ATR版相当于多乘了100
"""
return ATR(high, low, close, timeperiod) / close
================================================
FILE: polars_ta/ta/volume.py
================================================
from polars import Expr, when
from polars_ta.ta.overlap import EMA
def AD(high: Expr, low: Expr, close: Expr, volume: Expr) -> Expr:
ad = when(high != low).then(((close - low) - (high - close)) / (high - low)).otherwise(0)
return (ad * volume).cum_sum()
def ADOSC(high: Expr, low: Expr, close: Expr, volume: Expr, fastperiod: int = 3, slowperiod: int = 10) -> Expr:
ad = AD(high, low, close, volume)
return EMA(ad, fastperiod) - EMA(ad, slowperiod)
def OBV(close: Expr, volume: Expr) -> Expr:
""""""
# using volume for the first value will be exactly the same as talib.OBV
# 第一个值用volume就与talib.OBV完全一样了
obv = close.diff().sign().fill_null(1) * volume
return obv.cum_sum()
================================================
FILE: polars_ta/talib/README.md
================================================
# polars_ta.talib
Inside this package, files are generated by `tools.codegen_talib2`.
It is a wrapper of `talib` functions, with the following features:
1. Input and output are `Expr` instead of `Series`
2. ~~Add skipna feature (not efficient, will update when `polars` support backward fill)~~
本包由`tools.codegen_talib2`自动生成,是对`talib`代码的封装。实现了以下功能
1. 输入输出由`Series`改`Expr`
2. ~~添加跳过空值功能(效率不高,等`polars`支持反向填充,此部分将更新)~~
================================================
FILE: polars_ta/talib/__init__.py
================================================
# generated by codegen_talib.py
import talib as _ta
from polars import Expr, struct, Struct, Field, Float64, Int32
from polars_ta.utils.numba_ import batches_i1_o1, batches_i1_o2, batches_i2_o1, batches_i2_o2, struct_to_numpy
def HT_DCPERIOD(close: Expr) -> Expr: # ['real']
"""HT_DCPERIOD(ndarray real)
HT_DCPERIOD(real)
Hilbert Transform - Dominant Cycle Period (Cycle Indicators)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.HT_DCPERIOD), return_dtype=Float64)
def HT_DCPHASE(close: Expr) -> Expr: # ['real']
"""HT_DCPHASE(ndarray real)
HT_DCPHASE(real)
Hilbert Transform - Dominant Cycle Phase (Cycle Indicators)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.HT_DCPHASE), return_dtype=Float64)
def HT_PHASOR(close: Expr) -> Expr: # ['inphase', 'quadrature']
"""HT_PHASOR(ndarray real)
HT_PHASOR(real)
Hilbert Transform - Phasor Components (Cycle Indicators)
Inputs:
real: (any ndarray)
Outputs:
inphase
quadrature"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.HT_PHASOR), return_dtype=dtype)
def HT_SINE(close: Expr) -> Expr: # ['sine', 'leadsine']
"""HT_SINE(ndarray real)
HT_SINE(real)
Hilbert Transform - SineWave (Cycle Indicators)
Inputs:
real: (any ndarray)
Outputs:
sine
leadsine"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.HT_SINE), return_dtype=dtype)
def HT_TRENDMODE(close: Expr) -> Expr: # ['integer']
"""HT_TRENDMODE(ndarray real)
HT_TRENDMODE(real)
Hilbert Transform - Trend vs Cycle Mode (Cycle Indicators)
Inputs:
real: (any ndarray)
Outputs:
integer (values are -100, 0 or 100)"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.HT_TRENDMODE), return_dtype=Int32)
def ADD(high: Expr, low: Expr) -> Expr: # ['real']
"""ADD(ndarray real0, ndarray real1)
ADD(real0, real1)
Vector Arithmetic Add (Math Operators)
Inputs:
real0: (any ndarray)
real1: (any ndarray)
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.ADD), return_dtype=Float64)
def DIV(high: Expr, low: Expr) -> Expr: # ['real']
"""DIV(ndarray real0, ndarray real1)
DIV(real0, real1)
Vector Arithmetic Div (Math Operators)
Inputs:
real0: (any ndarray)
real1: (any ndarray)
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.DIV), return_dtype=Float64)
def MAX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""MAX(ndarray real, int timeperiod=-0x80000000)
MAX(real[, timeperiod=?])
Highest value over a specified period (Math Operators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.MAX, timeperiod), return_dtype=Float64)
def MAXINDEX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['integer']
"""MAXINDEX(ndarray real, int timeperiod=-0x80000000)
MAXINDEX(real[, timeperiod=?])
Index of highest value over a specified period (Math Operators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
integer (values are -100, 0 or 100)"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.MAXINDEX, timeperiod), return_dtype=Int32)
def MIN(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""MIN(ndarray real, int timeperiod=-0x80000000)
MIN(real[, timeperiod=?])
Lowest value over a specified period (Math Operators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.MIN, timeperiod), return_dtype=Float64)
def MININDEX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['integer']
"""MININDEX(ndarray real, int timeperiod=-0x80000000)
MININDEX(real[, timeperiod=?])
Index of lowest value over a specified period (Math Operators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
integer (values are -100, 0 or 100)"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.MININDEX, timeperiod), return_dtype=Int32)
def MINMAX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['min', 'max']
"""MINMAX(ndarray real, int timeperiod=-0x80000000)
MINMAX(real[, timeperiod=?])
Lowest and highest values over a specified period (Math Operators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
min
max"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.MINMAX, timeperiod), return_dtype=dtype)
def MINMAXINDEX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['minidx', 'maxidx']
"""MINMAXINDEX(ndarray real, int timeperiod=-0x80000000)
MINMAXINDEX(real[, timeperiod=?])
Indexes of lowest and highest values over a specified period (Math Operators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
minidx
maxidx"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.MINMAXINDEX, timeperiod), return_dtype=dtype)
def MULT(high: Expr, low: Expr) -> Expr: # ['real']
"""MULT(ndarray real0, ndarray real1)
MULT(real0, real1)
Vector Arithmetic Mult (Math Operators)
Inputs:
real0: (any ndarray)
real1: (any ndarray)
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.MULT), return_dtype=Float64)
def SUB(high: Expr, low: Expr) -> Expr: # ['real']
"""SUB(ndarray real0, ndarray real1)
SUB(real0, real1)
Vector Arithmetic Subtraction (Math Operators)
Inputs:
real0: (any ndarray)
real1: (any ndarray)
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.SUB), return_dtype=Float64)
def SUM(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""SUM(ndarray real, int timeperiod=-0x80000000)
SUM(real[, timeperiod=?])
Summation (Math Operators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.SUM, timeperiod), return_dtype=Float64)
def ACOS(close: Expr) -> Expr: # ['real']
"""ACOS(ndarray real)
ACOS(real)
Vector Trigonometric ACos (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.ACOS), return_dtype=Float64)
def ASIN(close: Expr) -> Expr: # ['real']
"""ASIN(ndarray real)
ASIN(real)
Vector Trigonometric ASin (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.ASIN), return_dtype=Float64)
def ATAN(close: Expr) -> Expr: # ['real']
"""ATAN(ndarray real)
ATAN(real)
Vector Trigonometric ATan (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.ATAN), return_dtype=Float64)
def CEIL(close: Expr) -> Expr: # ['real']
"""CEIL(ndarray real)
CEIL(real)
Vector Ceil (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.CEIL), return_dtype=Float64)
def COS(close: Expr) -> Expr: # ['real']
"""COS(ndarray real)
COS(real)
Vector Trigonometric Cos (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.COS), return_dtype=Float64)
def COSH(close: Expr) -> Expr: # ['real']
"""COSH(ndarray real)
COSH(real)
Vector Trigonometric Cosh (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.COSH), return_dtype=Float64)
def EXP(close: Expr) -> Expr: # ['real']
"""EXP(ndarray real)
EXP(real)
Vector Arithmetic Exp (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.EXP), return_dtype=Float64)
def FLOOR(close: Expr) -> Expr: # ['real']
"""FLOOR(ndarray real)
FLOOR(real)
Vector Floor (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.FLOOR), return_dtype=Float64)
def LN(close: Expr) -> Expr: # ['real']
"""LN(ndarray real)
LN(real)
Vector Log Natural (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.LN), return_dtype=Float64)
def LOG10(close: Expr) -> Expr: # ['real']
"""LOG10(ndarray real)
LOG10(real)
Vector Log10 (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.LOG10), return_dtype=Float64)
def SIN(close: Expr) -> Expr: # ['real']
"""SIN(ndarray real)
SIN(real)
Vector Trigonometric Sin (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.SIN), return_dtype=Float64)
def SINH(close: Expr) -> Expr: # ['real']
"""SINH(ndarray real)
SINH(real)
Vector Trigonometric Sinh (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.SINH), return_dtype=Float64)
def SQRT(close: Expr) -> Expr: # ['real']
"""SQRT(ndarray real)
SQRT(real)
Vector Square Root (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.SQRT), return_dtype=Float64)
def TAN(close: Expr) -> Expr: # ['real']
"""TAN(ndarray real)
TAN(real)
Vector Trigonometric Tan (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.TAN), return_dtype=Float64)
def TANH(close: Expr) -> Expr: # ['real']
"""TANH(ndarray real)
TANH(real)
Vector Trigonometric Tanh (Math Transform)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.TANH), return_dtype=Float64)
def ADX(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""ADX(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
ADX(high, low, close[, timeperiod=?])
Average Directional Movement Index (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.ADX, timeperiod), return_dtype=Float64)
def ADXR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""ADXR(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
ADXR(high, low, close[, timeperiod=?])
Average Directional Movement Index Rating (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.ADXR, timeperiod), return_dtype=Float64)
def APO(close: Expr, fastperiod: float = 12.0, slowperiod: float = 26.0, matype: float = 0.0) -> Expr: # ['real']
"""APO(ndarray real, int fastperiod=-0x80000000, int slowperiod=-0x80000000, int matype=0)
APO(real[, fastperiod=?, slowperiod=?, matype=?])
Absolute Price Oscillator (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
fastperiod: 12
slowperiod: 26
matype: 0 (Simple Moving Average)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.APO, fastperiod, slowperiod, matype), return_dtype=Float64)
def AROON(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: # ['aroondown', 'aroonup']
"""AROON(ndarray high, ndarray low, int timeperiod=-0x80000000)
AROON(high, low[, timeperiod=?])
Aroon (Momentum Indicators)
Inputs:
prices: ['high', 'low']
Parameters:
timeperiod: 14
Outputs:
aroondown
aroonup"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o2(struct_to_numpy(xx, 2, dtype=float), _ta.AROON, timeperiod), return_dtype=dtype)
def AROONOSC(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""AROONOSC(ndarray high, ndarray low, int timeperiod=-0x80000000)
AROONOSC(high, low[, timeperiod=?])
Aroon Oscillator (Momentum Indicators)
Inputs:
prices: ['high', 'low']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.AROONOSC, timeperiod), return_dtype=Float64)
def BOP(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
"""BOP(ndarray open, ndarray high, ndarray low, ndarray close)
BOP(open, high, low, close)
Balance Of Power (Momentum Indicators)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
real"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.BOP), return_dtype=Float64)
def CCI(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""CCI(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
CCI(high, low, close[, timeperiod=?])
Commodity Channel Index (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.CCI, timeperiod), return_dtype=Float64)
def CMO(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""CMO(ndarray real, int timeperiod=-0x80000000)
CMO(real[, timeperiod=?])
Chande Momentum Oscillator (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.CMO, timeperiod), return_dtype=Float64)
def DX(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""DX(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
DX(high, low, close[, timeperiod=?])
Directional Movement Index (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.DX, timeperiod), return_dtype=Float64)
def MACD(close: Expr, fastperiod: float = 12.0, slowperiod: float = 26.0, signalperiod: float = 9.0) -> Expr: # ['macd', 'macdsignal', 'macdhist']
"""MACD(ndarray real, int fastperiod=-0x80000000, int slowperiod=-0x80000000, int signalperiod=-0x80000000)
MACD(real[, fastperiod=?, slowperiod=?, signalperiod=?])
Moving Average Convergence/Divergence (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
fastperiod: 12
slowperiod: 26
signalperiod: 9
Outputs:
macd
macdsignal
macdhist"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(3)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.MACD, fastperiod, slowperiod, signalperiod), return_dtype=dtype)
def MACDEXT(close: Expr, fastperiod: float = 12.0, fastmatype: float = 0.0, slowperiod: float = 26.0, slowmatype: float = 0.0, signalperiod: float = 9.0, signalmatype: float = 0.0) -> Expr: # ['macd', 'macdsignal', 'macdhist']
"""MACDEXT(ndarray real, int fastperiod=-0x80000000, int fastmatype=0, int slowperiod=-0x80000000, int slowmatype=0, int signalperiod=-0x80000000, int signalmatype=0)
MACDEXT(real[, fastperiod=?, fastmatype=?, slowperiod=?, slowmatype=?, signalperiod=?, signalmatype=?])
MACD with controllable MA type (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
fastperiod: 12
fastmatype: 0
slowperiod: 26
slowmatype: 0
signalperiod: 9
signalmatype: 0
Outputs:
macd
macdsignal
macdhist"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(3)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.MACDEXT, fastperiod, fastmatype, slowperiod, slowmatype, signalperiod, signalmatype), return_dtype=dtype)
def MACDFIX(close: Expr, signalperiod: float = 9.0) -> Expr: # ['macd', 'macdsignal', 'macdhist']
"""MACDFIX(ndarray real, int signalperiod=-0x80000000)
MACDFIX(real[, signalperiod=?])
Moving Average Convergence/Divergence Fix 12/26 (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
signalperiod: 9
Outputs:
macd
macdsignal
macdhist"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(3)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.MACDFIX, signalperiod), return_dtype=dtype)
def MFI(high: Expr, low: Expr, close: Expr, volume: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""MFI(ndarray high, ndarray low, ndarray close, ndarray volume, int timeperiod=-0x80000000)
MFI(high, low, close, volume[, timeperiod=?])
Money Flow Index (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close', 'volume']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close, f3=volume).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.MFI, timeperiod), return_dtype=Float64)
def MINUS_DI(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""MINUS_DI(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
MINUS_DI(high, low, close[, timeperiod=?])
Minus Directional Indicator (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.MINUS_DI, timeperiod), return_dtype=Float64)
def MINUS_DM(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""MINUS_DM(ndarray high, ndarray low, int timeperiod=-0x80000000)
MINUS_DM(high, low[, timeperiod=?])
Minus Directional Movement (Momentum Indicators)
Inputs:
prices: ['high', 'low']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.MINUS_DM, timeperiod), return_dtype=Float64)
def MOM(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
"""MOM(ndarray real, int timeperiod=-0x80000000)
MOM(real[, timeperiod=?])
Momentum (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 10
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.MOM, timeperiod), return_dtype=Float64)
def PLUS_DI(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""PLUS_DI(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
PLUS_DI(high, low, close[, timeperiod=?])
Plus Directional Indicator (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.PLUS_DI, timeperiod), return_dtype=Float64)
def PLUS_DM(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""PLUS_DM(ndarray high, ndarray low, int timeperiod=-0x80000000)
PLUS_DM(high, low[, timeperiod=?])
Plus Directional Movement (Momentum Indicators)
Inputs:
prices: ['high', 'low']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.PLUS_DM, timeperiod), return_dtype=Float64)
def PPO(close: Expr, fastperiod: float = 12.0, slowperiod: float = 26.0, matype: float = 0.0) -> Expr: # ['real']
"""PPO(ndarray real, int fastperiod=-0x80000000, int slowperiod=-0x80000000, int matype=0)
PPO(real[, fastperiod=?, slowperiod=?, matype=?])
Percentage Price Oscillator (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
fastperiod: 12
slowperiod: 26
matype: 0 (Simple Moving Average)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.PPO, fastperiod, slowperiod, matype), return_dtype=Float64)
def ROC(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
"""ROC(ndarray real, int timeperiod=-0x80000000)
ROC(real[, timeperiod=?])
Rate of change : ((real/prevPrice)-1)*100 (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 10
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.ROC, timeperiod), return_dtype=Float64)
def ROCP(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
"""ROCP(ndarray real, int timeperiod=-0x80000000)
ROCP(real[, timeperiod=?])
Rate of change Percentage: (real-prevPrice)/prevPrice (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 10
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.ROCP, timeperiod), return_dtype=Float64)
def ROCR(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
"""ROCR(ndarray real, int timeperiod=-0x80000000)
ROCR(real[, timeperiod=?])
Rate of change ratio: (real/prevPrice) (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 10
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.ROCR, timeperiod), return_dtype=Float64)
def ROCR100(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
"""ROCR100(ndarray real, int timeperiod=-0x80000000)
ROCR100(real[, timeperiod=?])
Rate of change ratio 100 scale: (real/prevPrice)*100 (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 10
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.ROCR100, timeperiod), return_dtype=Float64)
def RSI(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""RSI(ndarray real, int timeperiod=-0x80000000)
RSI(real[, timeperiod=?])
Relative Strength Index (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.RSI, timeperiod), return_dtype=Float64)
def STOCH(high: Expr, low: Expr, close: Expr, fastk_period: float = 5.0, slowk_period: float = 3.0, slowk_matype: float = 0.0, slowd_period: float = 3.0, slowd_matype: float = 0.0) -> Expr: # ['slowk', 'slowd']
"""STOCH(ndarray high, ndarray low, ndarray close, int fastk_period=-0x80000000, int slowk_period=-0x80000000, int slowk_matype=0, int slowd_period=-0x80000000, int slowd_matype=0)
STOCH(high, low, close[, fastk_period=?, slowk_period=?, slowk_matype=?, slowd_period=?, slowd_matype=?])
Stochastic (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
fastk_period: 5
slowk_period: 3
slowk_matype: 0
slowd_period: 3
slowd_matype: 0
Outputs:
slowk
slowd"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o2(struct_to_numpy(xx, 3, dtype=float), _ta.STOCH, fastk_period, slowk_period, slowk_matype, slowd_period, slowd_matype), return_dtype=dtype)
def STOCHF(high: Expr, low: Expr, close: Expr, fastk_period: float = 5.0, fastd_period: float = 3.0, fastd_matype: float = 0.0) -> Expr: # ['fastk', 'fastd']
"""STOCHF(ndarray high, ndarray low, ndarray close, int fastk_period=-0x80000000, int fastd_period=-0x80000000, int fastd_matype=0)
STOCHF(high, low, close[, fastk_period=?, fastd_period=?, fastd_matype=?])
Stochastic Fast (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
fastk_period: 5
fastd_period: 3
fastd_matype: 0
Outputs:
fastk
fastd"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o2(struct_to_numpy(xx, 3, dtype=float), _ta.STOCHF, fastk_period, fastd_period, fastd_matype), return_dtype=dtype)
def STOCHRSI(close: Expr, timeperiod: float = 14.0, fastk_period: float = 5.0, fastd_period: float = 3.0, fastd_matype: float = 0.0) -> Expr: # ['fastk', 'fastd']
"""STOCHRSI(ndarray real, int timeperiod=-0x80000000, int fastk_period=-0x80000000, int fastd_period=-0x80000000, int fastd_matype=0)
STOCHRSI(real[, timeperiod=?, fastk_period=?, fastd_period=?, fastd_matype=?])
Stochastic Relative Strength Index (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
fastk_period: 5
fastd_period: 3
fastd_matype: 0
Outputs:
fastk
fastd"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.STOCHRSI, timeperiod, fastk_period, fastd_period, fastd_matype), return_dtype=dtype)
def TRIX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""TRIX(ndarray real, int timeperiod=-0x80000000)
TRIX(real[, timeperiod=?])
1-day Rate-Of-Change (ROC) of a Triple Smooth EMA (Momentum Indicators)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.TRIX, timeperiod), return_dtype=Float64)
def ULTOSC(high: Expr, low: Expr, close: Expr, timeperiod1: float = 7.0, timeperiod2: float = 14.0, timeperiod3: float = 28.0) -> Expr: # ['real']
"""ULTOSC(ndarray high, ndarray low, ndarray close, int timeperiod1=-0x80000000, int timeperiod2=-0x80000000, int timeperiod3=-0x80000000)
ULTOSC(high, low, close[, timeperiod1=?, timeperiod2=?, timeperiod3=?])
Ultimate Oscillator (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod1: 7
timeperiod2: 14
timeperiod3: 28
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.ULTOSC, timeperiod1, timeperiod2, timeperiod3), return_dtype=Float64)
def WILLR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""WILLR(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
WILLR(high, low, close[, timeperiod=?])
Williams' %R (Momentum Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.WILLR, timeperiod), return_dtype=Float64)
def BBANDS(close: Expr, timeperiod: float = 5.0, nbdevup: float = 2.0, nbdevdn: float = 2.0, matype: float = 0.0) -> Expr: # ['upperband', 'middleband', 'lowerband']
"""BBANDS(ndarray real, int timeperiod=-0x80000000, double nbdevup=-4e37, double nbdevdn=-4e37, int matype=0)
BBANDS(real[, timeperiod=?, nbdevup=?, nbdevdn=?, matype=?])
Bollinger Bands (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 5
nbdevup: 2.0
nbdevdn: 2.0
matype: 0 (Simple Moving Average)
Outputs:
upperband
middleband
lowerband"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(3)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.BBANDS, timeperiod, nbdevup, nbdevdn, matype), return_dtype=dtype)
def DEMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""DEMA(ndarray real, int timeperiod=-0x80000000)
DEMA(real[, timeperiod=?])
Double Exponential Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.DEMA, timeperiod), return_dtype=Float64)
def EMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""EMA(ndarray real, int timeperiod=-0x80000000)
EMA(real[, timeperiod=?])
Exponential Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.EMA, timeperiod), return_dtype=Float64)
def HT_TRENDLINE(close: Expr) -> Expr: # ['real']
"""HT_TRENDLINE(ndarray real)
HT_TRENDLINE(real)
Hilbert Transform - Instantaneous Trendline (Overlap Studies)
Inputs:
real: (any ndarray)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.HT_TRENDLINE), return_dtype=Float64)
def KAMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""KAMA(ndarray real, int timeperiod=-0x80000000)
KAMA(real[, timeperiod=?])
Kaufman Adaptive Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.KAMA, timeperiod), return_dtype=Float64)
def MA(close: Expr, timeperiod: float = 30.0, matype: float = 0.0) -> Expr: # ['real']
"""MA(ndarray real, int timeperiod=-0x80000000, int matype=0)
MA(real[, timeperiod=?, matype=?])
Moving average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
matype: 0 (Simple Moving Average)
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.MA, timeperiod, matype), return_dtype=Float64)
def MAMA(close: Expr, fastlimit: float = 0.5, slowlimit: float = 0.05) -> Expr: # ['mama', 'fama']
"""MAMA(ndarray real, double fastlimit=-4e37, double slowlimit=-4e37)
MAMA(real[, fastlimit=?, slowlimit=?])
MESA Adaptive Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
fastlimit: 0.5
slowlimit: 0.05
Outputs:
mama
fama"""
dtype = Struct([Field(f"column_{i}", Float64) for i in range(2)])
return close.map_batches(lambda x1: batches_i1_o2(x1.to_numpy().astype(float), _ta.MAMA, fastlimit, slowlimit), return_dtype=dtype)
def MAVP(close: Expr, periods: Expr, minperiod: float = 2.0, maxperiod: float = 30.0, matype: float = 0.0) -> Expr: # ['real']
"""MAVP(ndarray real, ndarray periods, int minperiod=-0x80000000, int maxperiod=-0x80000000, int matype=0)
MAVP(real, periods[, minperiod=?, maxperiod=?, matype=?])
Moving average with variable period (Overlap Studies)
Inputs:
real: (any ndarray)
periods: (any ndarray)
Parameters:
minperiod: 2
maxperiod: 30
matype: 0 (Simple Moving Average)
Outputs:
real"""
return struct(f0=close, f1=periods).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.MAVP, minperiod, maxperiod, matype), return_dtype=Float64)
def MIDPOINT(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""MIDPOINT(ndarray real, int timeperiod=-0x80000000)
MIDPOINT(real[, timeperiod=?])
MidPoint over period (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.MIDPOINT, timeperiod), return_dtype=Float64)
def MIDPRICE(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""MIDPRICE(ndarray high, ndarray low, int timeperiod=-0x80000000)
MIDPRICE(high, low[, timeperiod=?])
Midpoint Price over period (Overlap Studies)
Inputs:
prices: ['high', 'low']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.MIDPRICE, timeperiod), return_dtype=Float64)
def SAR(high: Expr, low: Expr, acceleration: float = 0.02, maximum: float = 0.2) -> Expr: # ['real']
"""SAR(ndarray high, ndarray low, double acceleration=0.02, double maximum=0.2)
SAR(high, low[, acceleration=?, maximum=?])
Parabolic SAR (Overlap Studies)
Inputs:
prices: ['high', 'low']
Parameters:
acceleration: 0.02
maximum: 0.2
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.SAR, acceleration, maximum), return_dtype=Float64)
def SAREXT(high: Expr, low: Expr, startvalue: float = 0.0, offsetonreverse: float = 0.0, accelerationinitlong: float = 0.02, accelerationlong: float = 0.02, accelerationmaxlong: float = 0.2, accelerationinitshort: float = 0.02, accelerationshort: float = 0.02, accelerationmaxshort: float = 0.2) -> Expr: # ['real']
"""SAREXT(ndarray high, ndarray low, double startvalue=-4e37, double offsetonreverse=-4e37, double accelerationinitlong=-4e37, double accelerationlong=-4e37, double accelerationmaxlong=-4e37, double accelerationinitshort=-4e37, double accelerationshort=-4e37, double accelerationmaxshort=-4e37)
SAREXT(high, low[, startvalue=?, offsetonreverse=?, accelerationinitlong=?, accelerationlong=?, accelerationmaxlong=?, accelerationinitshort=?, accelerationshort=?, accelerationmaxshort=?])
Parabolic SAR - Extended (Overlap Studies)
Inputs:
prices: ['high', 'low']
Parameters:
startvalue: 0.0
offsetonreverse: 0.0
accelerationinitlong: 0.02
accelerationlong: 0.02
accelerationmaxlong: 0.2
accelerationinitshort: 0.02
accelerationshort: 0.02
accelerationmaxshort: 0.2
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.SAREXT, startvalue, offsetonreverse, accelerationinitlong, accelerationlong, accelerationmaxlong, accelerationinitshort, accelerationshort, accelerationmaxshort), return_dtype=Float64)
def SMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""SMA(ndarray real, int timeperiod=-0x80000000)
SMA(real[, timeperiod=?])
Simple Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.SMA, timeperiod), return_dtype=Float64)
def T3(close: Expr, timeperiod: float = 5.0, vfactor: float = 0.7) -> Expr: # ['real']
"""T3(ndarray real, int timeperiod=-0x80000000, double vfactor=-4e37)
T3(real[, timeperiod=?, vfactor=?])
Triple Exponential Moving Average (T3) (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 5
vfactor: 0.7
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.T3, timeperiod, vfactor), return_dtype=Float64)
def TEMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""TEMA(ndarray real, int timeperiod=-0x80000000)
TEMA(real[, timeperiod=?])
Triple Exponential Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.TEMA, timeperiod), return_dtype=Float64)
def TRIMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""TRIMA(ndarray real, int timeperiod=-0x80000000)
TRIMA(real[, timeperiod=?])
Triangular Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.TRIMA, timeperiod), return_dtype=Float64)
def WMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""WMA(ndarray real, int timeperiod=-0x80000000)
WMA(real[, timeperiod=?])
Weighted Moving Average (Overlap Studies)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.WMA, timeperiod), return_dtype=Float64)
def CDL2CROWS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDL2CROWS(ndarray open, ndarray high, ndarray low, ndarray close)
CDL2CROWS(open, high, low, close)
Two Crows (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDL2CROWS), return_dtype=Int32)
def CDL3BLACKCROWS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDL3BLACKCROWS(ndarray open, ndarray high, ndarray low, ndarray close)
CDL3BLACKCROWS(open, high, low, close)
Three Black Crows (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDL3BLACKCROWS), return_dtype=Int32)
def CDL3INSIDE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDL3INSIDE(ndarray open, ndarray high, ndarray low, ndarray close)
CDL3INSIDE(open, high, low, close)
Three Inside Up/Down (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDL3INSIDE), return_dtype=Int32)
def CDL3LINESTRIKE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDL3LINESTRIKE(ndarray open, ndarray high, ndarray low, ndarray close)
CDL3LINESTRIKE(open, high, low, close)
Three-Line Strike (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDL3LINESTRIKE), return_dtype=Int32)
def CDL3OUTSIDE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDL3OUTSIDE(ndarray open, ndarray high, ndarray low, ndarray close)
CDL3OUTSIDE(open, high, low, close)
Three Outside Up/Down (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDL3OUTSIDE), return_dtype=Int32)
def CDL3STARSINSOUTH(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDL3STARSINSOUTH(ndarray open, ndarray high, ndarray low, ndarray close)
CDL3STARSINSOUTH(open, high, low, close)
Three Stars In The South (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDL3STARSINSOUTH), return_dtype=Int32)
def CDL3WHITESOLDIERS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDL3WHITESOLDIERS(ndarray open, ndarray high, ndarray low, ndarray close)
CDL3WHITESOLDIERS(open, high, low, close)
Three Advancing White Soldiers (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDL3WHITESOLDIERS), return_dtype=Int32)
def CDLABANDONEDBABY(open: Expr, high: Expr, low: Expr, close: Expr, penetration: float = 0.3) -> Expr: # ['integer']
"""CDLABANDONEDBABY(ndarray open, ndarray high, ndarray low, ndarray close, double penetration=0.3)
CDLABANDONEDBABY(open, high, low, close[, penetration=?])
Abandoned Baby (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Parameters:
penetration: 0.3
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLABANDONEDBABY, penetration), return_dtype=Int32)
def CDLADVANCEBLOCK(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLADVANCEBLOCK(ndarray open, ndarray high, ndarray low, ndarray close)
CDLADVANCEBLOCK(open, high, low, close)
Advance Block (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLADVANCEBLOCK), return_dtype=Int32)
def CDLBELTHOLD(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLBELTHOLD(ndarray open, ndarray high, ndarray low, ndarray close)
CDLBELTHOLD(open, high, low, close)
Belt-hold (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLBELTHOLD), return_dtype=Int32)
def CDLBREAKAWAY(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLBREAKAWAY(ndarray open, ndarray high, ndarray low, ndarray close)
CDLBREAKAWAY(open, high, low, close)
Breakaway (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLBREAKAWAY), return_dtype=Int32)
def CDLCLOSINGMARUBOZU(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLCLOSINGMARUBOZU(ndarray open, ndarray high, ndarray low, ndarray close)
CDLCLOSINGMARUBOZU(open, high, low, close)
Closing Marubozu (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLCLOSINGMARUBOZU), return_dtype=Int32)
def CDLCONCEALBABYSWALL(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLCONCEALBABYSWALL(ndarray open, ndarray high, ndarray low, ndarray close)
CDLCONCEALBABYSWALL(open, high, low, close)
Concealing Baby Swallow (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLCONCEALBABYSWALL), return_dtype=Int32)
def CDLCOUNTERATTACK(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLCOUNTERATTACK(ndarray open, ndarray high, ndarray low, ndarray close)
CDLCOUNTERATTACK(open, high, low, close)
Counterattack (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLCOUNTERATTACK), return_dtype=Int32)
def CDLDARKCLOUDCOVER(open: Expr, high: Expr, low: Expr, close: Expr, penetration: float = 0.5) -> Expr: # ['integer']
"""CDLDARKCLOUDCOVER(ndarray open, ndarray high, ndarray low, ndarray close, double penetration=0.5)
CDLDARKCLOUDCOVER(open, high, low, close[, penetration=?])
Dark Cloud Cover (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Parameters:
penetration: 0.5
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLDARKCLOUDCOVER, penetration), return_dtype=Int32)
def CDLDOJI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLDOJI(ndarray open, ndarray high, ndarray low, ndarray close)
CDLDOJI(open, high, low, close)
Doji (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLDOJI), return_dtype=Int32)
def CDLDOJISTAR(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLDOJISTAR(ndarray open, ndarray high, ndarray low, ndarray close)
CDLDOJISTAR(open, high, low, close)
Doji Star (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLDOJISTAR), return_dtype=Int32)
def CDLDRAGONFLYDOJI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLDRAGONFLYDOJI(ndarray open, ndarray high, ndarray low, ndarray close)
CDLDRAGONFLYDOJI(open, high, low, close)
Dragonfly Doji (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLDRAGONFLYDOJI), return_dtype=Int32)
def CDLENGULFING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLENGULFING(ndarray open, ndarray high, ndarray low, ndarray close)
CDLENGULFING(open, high, low, close)
Engulfing Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLENGULFING), return_dtype=Int32)
def CDLEVENINGDOJISTAR(open: Expr, high: Expr, low: Expr, close: Expr, penetration: float = 0.3) -> Expr: # ['integer']
"""CDLEVENINGDOJISTAR(ndarray open, ndarray high, ndarray low, ndarray close, double penetration=0.3)
CDLEVENINGDOJISTAR(open, high, low, close[, penetration=?])
Evening Doji Star (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Parameters:
penetration: 0.3
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLEVENINGDOJISTAR, penetration), return_dtype=Int32)
def CDLEVENINGSTAR(open: Expr, high: Expr, low: Expr, close: Expr, penetration: float = 0.3) -> Expr: # ['integer']
"""CDLEVENINGSTAR(ndarray open, ndarray high, ndarray low, ndarray close, double penetration=0.3)
CDLEVENINGSTAR(open, high, low, close[, penetration=?])
Evening Star (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Parameters:
penetration: 0.3
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLEVENINGSTAR, penetration), return_dtype=Int32)
def CDLGAPSIDESIDEWHITE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLGAPSIDESIDEWHITE(ndarray open, ndarray high, ndarray low, ndarray close)
CDLGAPSIDESIDEWHITE(open, high, low, close)
Up/Down-gap side-by-side white lines (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLGAPSIDESIDEWHITE), return_dtype=Int32)
def CDLGRAVESTONEDOJI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLGRAVESTONEDOJI(ndarray open, ndarray high, ndarray low, ndarray close)
CDLGRAVESTONEDOJI(open, high, low, close)
Gravestone Doji (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLGRAVESTONEDOJI), return_dtype=Int32)
def CDLHAMMER(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHAMMER(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHAMMER(open, high, low, close)
Hammer (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHAMMER), return_dtype=Int32)
def CDLHANGINGMAN(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHANGINGMAN(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHANGINGMAN(open, high, low, close)
Hanging Man (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHANGINGMAN), return_dtype=Int32)
def CDLHARAMI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHARAMI(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHARAMI(open, high, low, close)
Harami Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHARAMI), return_dtype=Int32)
def CDLHARAMICROSS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHARAMICROSS(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHARAMICROSS(open, high, low, close)
Harami Cross Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHARAMICROSS), return_dtype=Int32)
def CDLHIGHWAVE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHIGHWAVE(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHIGHWAVE(open, high, low, close)
High-Wave Candle (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHIGHWAVE), return_dtype=Int32)
def CDLHIKKAKE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHIKKAKE(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHIKKAKE(open, high, low, close)
Hikkake Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHIKKAKE), return_dtype=Int32)
def CDLHIKKAKEMOD(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHIKKAKEMOD(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHIKKAKEMOD(open, high, low, close)
Modified Hikkake Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHIKKAKEMOD), return_dtype=Int32)
def CDLHOMINGPIGEON(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLHOMINGPIGEON(ndarray open, ndarray high, ndarray low, ndarray close)
CDLHOMINGPIGEON(open, high, low, close)
Homing Pigeon (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLHOMINGPIGEON), return_dtype=Int32)
def CDLIDENTICAL3CROWS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLIDENTICAL3CROWS(ndarray open, ndarray high, ndarray low, ndarray close)
CDLIDENTICAL3CROWS(open, high, low, close)
Identical Three Crows (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLIDENTICAL3CROWS), return_dtype=Int32)
def CDLINNECK(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLINNECK(ndarray open, ndarray high, ndarray low, ndarray close)
CDLINNECK(open, high, low, close)
In-Neck Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLINNECK), return_dtype=Int32)
def CDLINVERTEDHAMMER(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLINVERTEDHAMMER(ndarray open, ndarray high, ndarray low, ndarray close)
CDLINVERTEDHAMMER(open, high, low, close)
Inverted Hammer (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLINVERTEDHAMMER), return_dtype=Int32)
def CDLKICKING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLKICKING(ndarray open, ndarray high, ndarray low, ndarray close)
CDLKICKING(open, high, low, close)
Kicking (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLKICKING), return_dtype=Int32)
def CDLKICKINGBYLENGTH(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLKICKINGBYLENGTH(ndarray open, ndarray high, ndarray low, ndarray close)
CDLKICKINGBYLENGTH(open, high, low, close)
Kicking - bull/bear determined by the longer marubozu (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLKICKINGBYLENGTH), return_dtype=Int32)
def CDLLADDERBOTTOM(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLLADDERBOTTOM(ndarray open, ndarray high, ndarray low, ndarray close)
CDLLADDERBOTTOM(open, high, low, close)
Ladder Bottom (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLLADDERBOTTOM), return_dtype=Int32)
def CDLLONGLEGGEDDOJI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLLONGLEGGEDDOJI(ndarray open, ndarray high, ndarray low, ndarray close)
CDLLONGLEGGEDDOJI(open, high, low, close)
Long Legged Doji (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLLONGLEGGEDDOJI), return_dtype=Int32)
def CDLLONGLINE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLLONGLINE(ndarray open, ndarray high, ndarray low, ndarray close)
CDLLONGLINE(open, high, low, close)
Long Line Candle (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLLONGLINE), return_dtype=Int32)
def CDLMARUBOZU(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLMARUBOZU(ndarray open, ndarray high, ndarray low, ndarray close)
CDLMARUBOZU(open, high, low, close)
Marubozu (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLMARUBOZU), return_dtype=Int32)
def CDLMATCHINGLOW(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLMATCHINGLOW(ndarray open, ndarray high, ndarray low, ndarray close)
CDLMATCHINGLOW(open, high, low, close)
Matching Low (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLMATCHINGLOW), return_dtype=Int32)
def CDLMATHOLD(open: Expr, high: Expr, low: Expr, close: Expr, penetration: float = 0.5) -> Expr: # ['integer']
"""CDLMATHOLD(ndarray open, ndarray high, ndarray low, ndarray close, double penetration=0.5)
CDLMATHOLD(open, high, low, close[, penetration=?])
Mat Hold (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Parameters:
penetration: 0.5
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLMATHOLD, penetration), return_dtype=Int32)
def CDLMORNINGDOJISTAR(open: Expr, high: Expr, low: Expr, close: Expr, penetration: float = 0.3) -> Expr: # ['integer']
"""CDLMORNINGDOJISTAR(ndarray open, ndarray high, ndarray low, ndarray close, double penetration=0.3)
CDLMORNINGDOJISTAR(open, high, low, close[, penetration=?])
Morning Doji Star (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Parameters:
penetration: 0.3
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLMORNINGDOJISTAR, penetration), return_dtype=Int32)
def CDLMORNINGSTAR(open: Expr, high: Expr, low: Expr, close: Expr, penetration: float = 0.3) -> Expr: # ['integer']
"""CDLMORNINGSTAR(ndarray open, ndarray high, ndarray low, ndarray close, double penetration=0.3)
CDLMORNINGSTAR(open, high, low, close[, penetration=?])
Morning Star (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Parameters:
penetration: 0.3
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLMORNINGSTAR, penetration), return_dtype=Int32)
def CDLONNECK(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLONNECK(ndarray open, ndarray high, ndarray low, ndarray close)
CDLONNECK(open, high, low, close)
On-Neck Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLONNECK), return_dtype=Int32)
def CDLPIERCING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLPIERCING(ndarray open, ndarray high, ndarray low, ndarray close)
CDLPIERCING(open, high, low, close)
Piercing Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLPIERCING), return_dtype=Int32)
def CDLRICKSHAWMAN(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLRICKSHAWMAN(ndarray open, ndarray high, ndarray low, ndarray close)
CDLRICKSHAWMAN(open, high, low, close)
Rickshaw Man (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLRICKSHAWMAN), return_dtype=Int32)
def CDLRISEFALL3METHODS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLRISEFALL3METHODS(ndarray open, ndarray high, ndarray low, ndarray close)
CDLRISEFALL3METHODS(open, high, low, close)
Rising/Falling Three Methods (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLRISEFALL3METHODS), return_dtype=Int32)
def CDLSEPARATINGLINES(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLSEPARATINGLINES(ndarray open, ndarray high, ndarray low, ndarray close)
CDLSEPARATINGLINES(open, high, low, close)
Separating Lines (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLSEPARATINGLINES), return_dtype=Int32)
def CDLSHOOTINGSTAR(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLSHOOTINGSTAR(ndarray open, ndarray high, ndarray low, ndarray close)
CDLSHOOTINGSTAR(open, high, low, close)
Shooting Star (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLSHOOTINGSTAR), return_dtype=Int32)
def CDLSHORTLINE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLSHORTLINE(ndarray open, ndarray high, ndarray low, ndarray close)
CDLSHORTLINE(open, high, low, close)
Short Line Candle (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLSHORTLINE), return_dtype=Int32)
def CDLSPINNINGTOP(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLSPINNINGTOP(ndarray open, ndarray high, ndarray low, ndarray close)
CDLSPINNINGTOP(open, high, low, close)
Spinning Top (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLSPINNINGTOP), return_dtype=Int32)
def CDLSTALLEDPATTERN(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLSTALLEDPATTERN(ndarray open, ndarray high, ndarray low, ndarray close)
CDLSTALLEDPATTERN(open, high, low, close)
Stalled Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLSTALLEDPATTERN), return_dtype=Int32)
def CDLSTICKSANDWICH(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLSTICKSANDWICH(ndarray open, ndarray high, ndarray low, ndarray close)
CDLSTICKSANDWICH(open, high, low, close)
Stick Sandwich (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLSTICKSANDWICH), return_dtype=Int32)
def CDLTAKURI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLTAKURI(ndarray open, ndarray high, ndarray low, ndarray close)
CDLTAKURI(open, high, low, close)
Takuri (Dragonfly Doji with very long lower shadow) (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLTAKURI), return_dtype=Int32)
def CDLTASUKIGAP(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLTASUKIGAP(ndarray open, ndarray high, ndarray low, ndarray close)
CDLTASUKIGAP(open, high, low, close)
Tasuki Gap (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLTASUKIGAP), return_dtype=Int32)
def CDLTHRUSTING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLTHRUSTING(ndarray open, ndarray high, ndarray low, ndarray close)
CDLTHRUSTING(open, high, low, close)
Thrusting Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLTHRUSTING), return_dtype=Int32)
def CDLTRISTAR(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLTRISTAR(ndarray open, ndarray high, ndarray low, ndarray close)
CDLTRISTAR(open, high, low, close)
Tristar Pattern (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLTRISTAR), return_dtype=Int32)
def CDLUNIQUE3RIVER(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLUNIQUE3RIVER(ndarray open, ndarray high, ndarray low, ndarray close)
CDLUNIQUE3RIVER(open, high, low, close)
Unique 3 River (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLUNIQUE3RIVER), return_dtype=Int32)
def CDLUPSIDEGAP2CROWS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLUPSIDEGAP2CROWS(ndarray open, ndarray high, ndarray low, ndarray close)
CDLUPSIDEGAP2CROWS(open, high, low, close)
Upside Gap Two Crows (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLUPSIDEGAP2CROWS), return_dtype=Int32)
def CDLXSIDEGAP3METHODS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['integer']
"""CDLXSIDEGAP3METHODS(ndarray open, ndarray high, ndarray low, ndarray close)
CDLXSIDEGAP3METHODS(open, high, low, close)
Upside/Downside Gap Three Methods (Pattern Recognition)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
integer (values are -100, 0 or 100)"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.CDLXSIDEGAP3METHODS), return_dtype=Int32)
def AVGPRICE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
"""AVGPRICE(ndarray open, ndarray high, ndarray low, ndarray close)
AVGPRICE(open, high, low, close)
Average Price (Price Transform)
Inputs:
prices: ['open', 'high', 'low', 'close']
Outputs:
real"""
return struct(f0=open, f1=high, f2=low, f3=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.AVGPRICE), return_dtype=Float64)
def MEDPRICE(high: Expr, low: Expr) -> Expr: # ['real']
"""MEDPRICE(ndarray high, ndarray low)
MEDPRICE(high, low)
Median Price (Price Transform)
Inputs:
prices: ['high', 'low']
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.MEDPRICE), return_dtype=Float64)
def TYPPRICE(high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
"""TYPPRICE(ndarray high, ndarray low, ndarray close)
TYPPRICE(high, low, close)
Typical Price (Price Transform)
Inputs:
prices: ['high', 'low', 'close']
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.TYPPRICE), return_dtype=Float64)
def WCLPRICE(high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
"""WCLPRICE(ndarray high, ndarray low, ndarray close)
WCLPRICE(high, low, close)
Weighted Close Price (Price Transform)
Inputs:
prices: ['high', 'low', 'close']
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.WCLPRICE), return_dtype=Float64)
def BETA(high: Expr, low: Expr, timeperiod: float = 5.0) -> Expr: # ['real']
"""BETA(ndarray real0, ndarray real1, int timeperiod=-0x80000000)
BETA(real0, real1[, timeperiod=?])
Beta (Statistic Functions)
Inputs:
real0: (any ndarray)
real1: (any ndarray)
Parameters:
timeperiod: 5
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.BETA, timeperiod), return_dtype=Float64)
def CORREL(high: Expr, low: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
"""CORREL(ndarray real0, ndarray real1, int timeperiod=-0x80000000)
CORREL(real0, real1[, timeperiod=?])
Pearson's Correlation Coefficient (r) (Statistic Functions)
Inputs:
real0: (any ndarray)
real1: (any ndarray)
Parameters:
timeperiod: 30
Outputs:
real"""
return struct(f0=high, f1=low).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.CORREL, timeperiod), return_dtype=Float64)
def LINEARREG(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""LINEARREG(ndarray real, int timeperiod=-0x80000000)
LINEARREG(real[, timeperiod=?])
Linear Regression (Statistic Functions)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.LINEARREG, timeperiod), return_dtype=Float64)
def LINEARREG_ANGLE(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""LINEARREG_ANGLE(ndarray real, int timeperiod=-0x80000000)
LINEARREG_ANGLE(real[, timeperiod=?])
Linear Regression Angle (Statistic Functions)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.LINEARREG_ANGLE, timeperiod), return_dtype=Float64)
def LINEARREG_INTERCEPT(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""LINEARREG_INTERCEPT(ndarray real, int timeperiod=-0x80000000)
LINEARREG_INTERCEPT(real[, timeperiod=?])
Linear Regression Intercept (Statistic Functions)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.LINEARREG_INTERCEPT, timeperiod), return_dtype=Float64)
def LINEARREG_SLOPE(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""LINEARREG_SLOPE(ndarray real, int timeperiod=-0x80000000)
LINEARREG_SLOPE(real[, timeperiod=?])
Linear Regression Slope (Statistic Functions)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.LINEARREG_SLOPE, timeperiod), return_dtype=Float64)
def STDDEV(close: Expr, timeperiod: float = 5.0, nbdev: float = 1.0) -> Expr: # ['real']
"""STDDEV(ndarray real, int timeperiod=-0x80000000, double nbdev=-4e37)
STDDEV(real[, timeperiod=?, nbdev=?])
Standard Deviation (Statistic Functions)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 5
nbdev: 1.0
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.STDDEV, timeperiod, nbdev), return_dtype=Float64)
def TSF(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""TSF(ndarray real, int timeperiod=-0x80000000)
TSF(real[, timeperiod=?])
Time Series Forecast (Statistic Functions)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 14
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.TSF, timeperiod), return_dtype=Float64)
def VAR(close: Expr, timeperiod: float = 5.0, nbdev: float = 1.0) -> Expr: # ['real']
"""VAR(ndarray real, int timeperiod=-0x80000000, double nbdev=-4e37)
VAR(real[, timeperiod=?, nbdev=?])
Variance (Statistic Functions)
Inputs:
real: (any ndarray)
Parameters:
timeperiod: 5
nbdev: 1.0
Outputs:
real"""
return close.map_batches(lambda x1: batches_i1_o1(x1.to_numpy().astype(float), _ta.VAR, timeperiod, nbdev), return_dtype=Float64)
def ATR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""ATR(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
ATR(high, low, close[, timeperiod=?])
Average True Range (Volatility Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.ATR, timeperiod), return_dtype=Float64)
def NATR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
"""NATR(ndarray high, ndarray low, ndarray close, int timeperiod=-0x80000000)
NATR(high, low, close[, timeperiod=?])
Normalized Average True Range (Volatility Indicators)
Inputs:
prices: ['high', 'low', 'close']
Parameters:
timeperiod: 14
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.NATR, timeperiod), return_dtype=Float64)
def TRANGE(high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
"""TRANGE(ndarray high, ndarray low, ndarray close)
TRANGE(high, low, close)
True Range (Volatility Indicators)
Inputs:
prices: ['high', 'low', 'close']
Outputs:
real"""
return struct(f0=high, f1=low, f2=close).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 3, dtype=float), _ta.TRANGE), return_dtype=Float64)
def AD(high: Expr, low: Expr, close: Expr, volume: Expr) -> Expr: # ['real']
"""AD(ndarray high, ndarray low, ndarray close, ndarray volume)
AD(high, low, close, volume)
Chaikin A/D Line (Volume Indicators)
Inputs:
prices: ['high', 'low', 'close', 'volume']
Outputs:
real"""
return struct(f0=high, f1=low, f2=close, f3=volume).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.AD), return_dtype=Float64)
def ADOSC(high: Expr, low: Expr, close: Expr, volume: Expr, fastperiod: float = 3.0, slowperiod: float = 10.0) -> Expr: # ['real']
"""ADOSC(ndarray high, ndarray low, ndarray close, ndarray volume, int fastperiod=-0x80000000, int slowperiod=-0x80000000)
ADOSC(high, low, close, volume[, fastperiod=?, slowperiod=?])
Chaikin A/D Oscillator (Volume Indicators)
Inputs:
prices: ['high', 'low', 'close', 'volume']
Parameters:
fastperiod: 3
slowperiod: 10
Outputs:
real"""
return struct(f0=high, f1=low, f2=close, f3=volume).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 4, dtype=float), _ta.ADOSC, fastperiod, slowperiod), return_dtype=Float64)
def OBV(close: Expr, volume: Expr) -> Expr: # ['real']
"""OBV(ndarray real, ndarray volume)
OBV(real, volume)
On Balance Volume (Volume Indicators)
Inputs:
real: (any ndarray)
prices: ['volume']
Outputs:
real"""
return struct(f0=close, f1=volume).map_batches(lambda xx: batches_i2_o1(struct_to_numpy(xx, 2, dtype=float), _ta.OBV), return_dtype=Float64)
================================================
FILE: polars_ta/tdx/README.md
================================================
# polars_ta.tdx
1. Follows the `tdx` naming convention
2. Except for some element-wise functions, all functions are time-series functions. Pay special attention to `MAX` and similar functions.
3. First import from `tdx`, then from `wq`, and finally from `ta`. Only implement the function if it is not available.
1. 函数名称按照通达信来
2. 除了部分按元素计算的函数,其它都为时序函数,特别注意`MAX`等一类不要混淆
3. 优先从`tdx`中导入,然后从`wq`中导入,最后从`ta`,没有的才实现
================================================
FILE: polars_ta/tdx/__init__.py
================================================
from polars_ta.tdx.arithmetic import * # noqa
from polars_ta.tdx.choice import * # noqa
from polars_ta.tdx.energy import * # noqa
from polars_ta.tdx.logical import * # noqa
from polars_ta.tdx.moving_average import * # noqa
from polars_ta.tdx.over_bought_over_sold import * # noqa
from polars_ta.tdx.pattern import * # noqa
from polars_ta.tdx.pattern_feature import * # noqa
from polars_ta.tdx.pressure_support import * # noqa
from polars_ta.tdx.reference import * # noqa
from polars_ta.tdx.statistic import * # noqa
from polars_ta.tdx.times import * # noqa
from polars_ta.tdx.trend import * # noqa
from polars_ta.tdx.trend_feature import * # noqa
from polars_ta.tdx.volume import * # noqa
================================================
FILE: polars_ta/tdx/_chip.py
================================================
import numba
import numpy as np
@numba.jit(nopython=True, nogil=True, fastmath=True, cache=True)
def nb_chip(high, low, avg, turnover,
start=None, stop=None, step=0.2):
"""筹码分布,可用于WINNER或COST指标
不可能完全还原真实的筹码分布,只能接近。所以做了一下特别处理
1. 三角分布,比平均分布更接近
2. 步长。没有必要每个价格都统计,特别是复权后价格也无法正好是0.01间隔
高价股建议步长设大些,低价股步长需设小些
Parameters
----------
high
low
avg
一维序列
turnover:
换手率,需要在外转成0~1范围内
start
开始价格
stop
结束价格
step
步长。一字涨停时,三角分布的底为1,高为2。但无法当成梯形计算面积,所以从中用半步长切开计算
Returns
-------
out
筹码分布
columns
价格表头
"""
# 网格范围
if start is None:
start = np.min(low)
if stop is None:
stop = np.max(high)
left = round(start / step) * 2 - 1
right = round(stop / step) * 2 + 1
# 最小最大值左右要留半格,range是左闭右开,长度必须为2n+1
columns = np.arange(left, right + 1)
grid_shape = (len(turnover), len(columns))
# numba中round写法特殊
_high = np.empty_like(high)
_low = np.empty_like(low)
_avg = np.empty_like(avg)
# high和low必须落到边缘上
_high = np.round(high / step, 0, _high) * 2 + 1
_low = np.round(low / step, 0, _low) * 2 - 1
# avg必须落在实体上
_avg = np.round(avg / step, 0, _avg) * 2
tri_height = 2 / ((_high - _low) // 2) # 三角形高度
# 得到三组值在网格中的位置
high_arg = np.argwhere(columns == _high.reshape(-1, 1))[:, 1]
avg_arg = np.argwhere(columns == _avg.reshape(-1, 1))[:, 1]
low_arg = np.argwhere(columns == _low.reshape(-1, 1))[:, 1]
# 高度表
height = np.zeros(grid_shape)
for i in range(len(height)):
la = low_arg[i]
aa = avg_arg[i]
ha = high_arg[i]
th = tri_height[i]
height[i, la:aa + 1] = np.linspace(0, th, aa - la + 1)
height[i, aa:ha + 1] = np.linspace(th, 0, ha - aa + 1)
# 计算半块面积, 三角形的高变成了梯形的上下底,梯形高固定为0.5,*0.5/2=/4
# 宽度-1,例如,原长度为5,-1后为4
area = (height[:, :-1] + height[:, 1:]) / 4
# 合成一块。宽度/2,例如原长度为4,/2后为2
weight = area[:, ::2] + area[:, 1::2]
# 输出
out = np.zeros_like(weight)
# 剩余换手率
turnover2 = 1 - turnover
# 第一天其实应当用上市发行价,过于麻烦,还是将第一天等权
# 取巧方法,利用-1的特性,可减少if判断,
out[-1] = weight[0]
# 这里现在用的numpy, 还要快可考虑numba
for i in range(len(turnover)):
out[i] = out[i - 1] * turnover2[i] + weight[i] * turnover[i]
# print(out.sum(axis=1))
return out, (step / 2) * columns[1::2]
@numba.jit(nopython=True, nogil=True, fastmath=True, cache=True)
def _WINNER_COST(high, low, avg, turnover, close, cost, step):
out, columns = nb_chip(high, low, avg, turnover, step=step)
# WINNER
cheap = np.where(columns <= close.reshape(-1, 1), out, 0)
sum_cheap = np.sum(cheap, axis=1)
# COST
# cum = np.cumsum(out, axis=1)
cum = np.copy(out)
for i in range(0, out.shape[0]):
cum[i, :] = np.cumsum(out[i, :])
prices = np.where(cum <= cost.reshape(-1, 1), columns, 0)
# np.max(prices, axis=1)
max_price = prices[:, 0]
for i in range(0, out.shape[0]):
max_price[i] = np.max(prices[i, :])
return sum_cheap, max_price
================================================
FILE: polars_ta/tdx/_nb.py
================================================
import numpy as np
from numba import jit
from numpy import mean, abs, full, argmax
from numpy.lib.stride_tricks import sliding_window_view
@jit(nopython=True, nogil=True, cache=True)
def roll_avedev(x1, window):
out = full(x1.shape, np.nan, dtype=np.float64)
if len(x1) < window:
return out
a1 = sliding_window_view(x1, window)
for i, v1 in enumerate(a1):
out[i + window - 1] = mean(abs(v1 - mean(v1)))
return out
@jit(nopython=True, nogil=True, fastmath=True, cache=True)
def roll_bars_since_n(x1, window):
"""BARSSINCEN(X,N): the distance of the first observation that `X != 0` in `N` periods
BARSSINCEN(X,N):N周期内第一次X不为0到现在的天数
TODO what if all values are 0?
TODO 如果一个周期内,都不满足,值取多少?0表当前值满足条件, window-1表示的是区间第0位置的值
TODO 用window来表示都不满足
"""
out = full(x1.shape, np.nan, dtype=np.float64)
if len(x1) < window:
return out
a1 = sliding_window_view(x1, window)
for i, v1 in enumerate(a1):
p = argmax(v1)
out[i + window - 1] = window - 1 - p if p or v1[0] else window
return out
@jit(nopython=True, nogil=True, fastmath=True, cache=True)
def _up_stat(a, d: int = 3):
"""T天N板,最稀疏为5天2板
最近几天涨停但当天没涨停也会有记录,如6天2板,所以要与涨停一起使用
"""
out1 = full(a.shape, 0, dtype=np.int64)
out2 = full(a.shape, 0, dtype=np.int64)
out3 = full(a.shape, 0, dtype=np.int64)
t = 0 # T天
n = 0 # N板
k = 0 # 连续False个数
f = True # 前面的False不处理
for i in range(0, a.shape[0]):
if a[i]:
k = 0
t += 1
n += 1
f = False
out1[i] = t
out2[i] = n
out3[i] = k
else:
if f:
continue
k += 1
t += 1
if k > d:
# 超过指定天数才会重置
t = 0
n = 0
out1[i] = t
out2[i] = n
out3[i] = k
return out1, out2, out3
================================================
FILE: polars_ta/tdx/_slow.py
================================================
from polars import Series, Expr
def _avedev(x: Series) -> Series:
# x is Series rather than Expr. Making this function slow
# 可惜rolling_map后这里已经由Expr变成了Series
return (x - x.mean()).abs().mean()
def AVEDEV(close: Expr, timeperiod: int = 5) -> Expr:
"""Avoid using this function, it is slow.
平均绝对偏差
"""
return close.rolling_map(_avedev, timeperiod)
================================================
FILE: polars_ta/tdx/arithmetic.py
================================================
"""
通过`import`直接导入或更名的函数
```python
from polars_ta.wq.arithmetic import abs_ as ABS # noqa
from polars_ta.wq.arithmetic import add as ADD # noqa
from polars_ta.wq.arithmetic import arc_cos as ACOS # noqa
from polars_ta.wq.arithmetic import arc_sin as ASIN # noqa
from polars_ta.wq.arithmetic import arc_tan as ATAN # noqa
from polars_ta.wq.arithmetic import ceiling as CEILING # noqa
from polars_ta.wq.arithmetic import cos as COS # noqa
from polars_ta.wq.arithmetic import exp as EXP # noqa
from polars_ta.wq.arithmetic import floor as FLOOR # noqa
from polars_ta.wq.arithmetic import fraction as FRACPART # noqa
from polars_ta.wq.arithmetic import log as LN # noqa # 自然对数 (log base e)
from polars_ta.wq.arithmetic import log10 as LOG # noqa # 10为底的对数 (log base 10)
from polars_ta.wq.arithmetic import max_ as MAX # noqa
from polars_ta.wq.arithmetic import min_ as MIN # noqa
from polars_ta.wq.arithmetic import mod as MOD # noqa
from polars_ta.wq.arithmetic import power as POW # noqa
from polars_ta.wq.arithmetic import reverse as REVERSE # noqa
from polars_ta.wq.arithmetic import round_ as _round # noqa
from polars_ta.wq.arithmetic import sign as SIGN # noqa
from polars_ta.wq.arithmetic import sin as SIN # noqa
from polars_ta.wq.arithmetic import sqrt as SQRT # noqa
from polars_ta.wq.arithmetic import subtract as SUB # noqa
from polars_ta.wq.arithmetic import tan as TAN # noqa
from polars_ta.wq.transformational import int_ as INTPART # noqa
```
"""
from polars import Expr
from polars_ta.wq.arithmetic import abs_ as ABS # noqa
from polars_ta.wq.arithmetic import add as ADD # noqa
from polars_ta.wq.arithmetic import arc_cos as ACOS # noqa
from polars_ta.wq.arithmetic import arc_sin as ASIN # noqa
from polars_ta.wq.arithmetic import arc_tan as ATAN # noqa
from polars_ta.wq.arithmetic import ceiling as CEILING # noqa
from polars_ta.wq.arithmetic import cos as COS # noqa
from polars_ta.wq.arithmetic import exp as EXP # noqa
from polars_ta.wq.arithmetic import floor as FLOOR # noqa
from polars_ta.wq.arithmetic import fraction as FRACPART # noqa
from polars_ta.wq.arithmetic import log as LN # noqa # 自然对数 (log base e)
from polars_ta.wq.arithmetic import log10 as LOG # noqa # 10为底的对数 (log base 10)
from polars_ta.wq.arithmetic import max_ as MAX # noqa
from polars_ta.wq.arithmetic import min_ as MIN # noqa
from polars_ta.wq.arithmetic import mod as MOD # noqa
from polars_ta.wq.arithmetic impo
gitextract_uz7e5vob/
├── .github/
│ └── workflows/
│ └── python-publish.yml
├── .gitignore
├── .readthedocs.yaml
├── LICENSE
├── README.md
├── compare.md
├── deprecated/
│ ├── demo_ta1.py
│ ├── demo_ta2.py
│ ├── helper.py
│ ├── pandas_.py
│ └── wrapper.py
├── docs/
│ ├── index.md
│ ├── ta/
│ │ ├── index.md
│ │ ├── momentum.md
│ │ ├── operators.md
│ │ ├── overlap.md
│ │ ├── price.md
│ │ ├── statistic.md
│ │ ├── transform.md
│ │ ├── volatility.md
│ │ └── volume.md
│ ├── talib/
│ │ └── index.md
│ ├── tdx/
│ │ ├── arithmetic.md
│ │ ├── choice.md
│ │ ├── energy.md
│ │ ├── logical.md
│ │ ├── moving_average.md
│ │ ├── over_bought_over_sold.md
│ │ ├── pattern.md
│ │ ├── pattern_feature.md
│ │ ├── pressure_support.md
│ │ ├── reference.md
│ │ ├── statistic.md
│ │ ├── times.md
│ │ ├── trend.md
│ │ ├── trend_feature.md
│ │ └── volume.md
│ └── wq/
│ ├── arithmetic.md
│ ├── cross_sectional.md
│ ├── half_life.md
│ ├── logical.md
│ ├── preprocess.md
│ ├── time_series.md
│ ├── transformational.md
│ └── vector.md
├── examples/
│ ├── alpha101.py
│ └── demo_ta3.py
├── mkdocs.yml
├── nan_to_null.md
├── point_in_time.md
├── polars_ta/
│ ├── __init__.py
│ ├── _version.py
│ ├── candles/
│ │ ├── __init__.py
│ │ ├── cdl1.py
│ │ ├── cdl1_limit.py
│ │ └── cdl2.py
│ ├── labels/
│ │ ├── __init__.py
│ │ ├── _nb.py
│ │ └── future.py
│ ├── noise.py
│ ├── performance/
│ │ ├── __init__.py
│ │ ├── drawdown.py
│ │ └── returns.py
│ ├── prefix/
│ │ ├── __init__.py
│ │ ├── cdl.py
│ │ ├── labels.py
│ │ ├── reports.py
│ │ ├── ta.py
│ │ ├── talib.py
│ │ ├── tdx.py
│ │ ├── vec.py
│ │ └── wq.py
│ ├── reports/
│ │ ├── __init__.py
│ │ └── cicc.py
│ ├── ta/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── momentum.py
│ │ ├── operators.py
│ │ ├── overlap.py
│ │ ├── price.py
│ │ ├── statistic.py
│ │ ├── transform.py
│ │ ├── volatility.py
│ │ └── volume.py
│ ├── talib/
│ │ ├── README.md
│ │ └── __init__.py
│ ├── tdx/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── _chip.py
│ │ ├── _nb.py
│ │ ├── _slow.py
│ │ ├── arithmetic.py
│ │ ├── choice.py
│ │ ├── energy.py
│ │ ├── logical.py
│ │ ├── moving_average.py
│ │ ├── over_bought_over_sold.py
│ │ ├── pattern.py
│ │ ├── pattern_feature.py
│ │ ├── pressure_support.py
│ │ ├── reference.py
│ │ ├── statistic.py
│ │ ├── times.py
│ │ ├── trend.py
│ │ ├── trend_feature.py
│ │ └── volume.py
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── factor.py
│ │ ├── functions.py
│ │ ├── numba_.py
│ │ ├── pit.py
│ │ └── withs.py
│ └── wq/
│ ├── __init__.py
│ ├── _nb.py
│ ├── _slow.py
│ ├── arithmetic.py
│ ├── cross_sectional.py
│ ├── half_life.py
│ ├── logical.py
│ ├── preprocess.py
│ ├── time_series.py
│ ├── transformational.py
│ └── vector.py
├── prompt.txt
├── pyproject.toml
├── requirements-docs.txt
├── requirements.txt
├── setup.py
├── tests/
│ ├── numba_test.py
│ ├── pit_test.py
│ ├── ta/
│ │ ├── test_momentum.py
│ │ ├── test_operators.py
│ │ ├── test_overlap.py
│ │ ├── test_statistic.py
│ │ ├── test_volatility.py
│ │ └── test_volume.py
│ ├── tdx/
│ │ ├── chip_test.py
│ │ ├── test_reference.py
│ │ └── test_statistic.py
│ └── wq/
│ ├── test_arithmetic.py
│ └── test_time_series.py
├── thinking_about_TA.md
└── tools/
├── README.md
├── codegen_talib.py
├── prefix.py
├── prefix_ta.py
├── prefix_talib.py
├── prefix_tdx.py
├── prefix_vec.py
└── prompt.py
SYMBOL INDEX (722 symbols across 71 files)
FILE: deprecated/helper.py
function func_wrap_mn (line 49) | def func_wrap_mn(func, cols,
function func_wrap_11 (line 124) | def func_wrap_11(func, cols,
class FuncHelper (line 156) | class FuncHelper:
method __init__ (line 157) | def __init__(self, expr: Expr, lib=None, wrap=None) -> None:
method __getattribute__ (line 184) | def __getattribute__(self, name: str):
class TaLibHelper (line 201) | class TaLibHelper(FuncHelper):
method __init__ (line 202) | def __init__(self, expr: Expr) -> None:
class BottleneckHelper (line 208) | class BottleneckHelper(FuncHelper):
method __init__ (line 209) | def __init__(self, expr: Expr) -> None:
FILE: deprecated/pandas_.py
function get_window_bounds (line 28) | def get_window_bounds(
function roll_rank (line 38) | def roll_rank(x: Series, d: int, minp: int, pct: bool = True, method: st...
function roll_kurt (line 53) | def roll_kurt(x, d: int, minp: int):
FILE: deprecated/wrapper.py
function ta_func (line 35) | def ta_func(func, func_name, input_names, output_names,
function ta_decorator (line 76) | def ta_decorator(func, func_name, input_names, output_names):
function init (line 89) | def init(to_globals=False, name_format='{}'):
FILE: examples/alpha101.py
function func_ts_date (line 60) | def func_ts_date(df: pl.DataFrame) -> pl.DataFrame:
FILE: polars_ta/candles/cdl1.py
function real_body (line 18) | def real_body(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function upper_shadow (line 23) | def upper_shadow(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function lower_shadow (line 28) | def lower_shadow(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function high_low_range (line 33) | def high_low_range(open_: Expr, high: Expr, low: Expr, close: Expr) -> E...
function upper_body (line 38) | def upper_body(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function lower_body (line 43) | def lower_body(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function shadows (line 48) | def shadows(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function efficiency_ratio (line 53) | def efficiency_ratio(open_: Expr, high: Expr, low: Expr, close: Expr) ->...
function candle_color (line 67) | def candle_color(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function four_price_doji (line 72) | def four_price_doji(open_: Expr, high: Expr, low: Expr, close: Expr) -> ...
function doji (line 77) | def doji(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function dragonfly (line 82) | def dragonfly(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function gravestone (line 87) | def gravestone(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
FILE: polars_ta/candles/cdl1_limit.py
function limit_up (line 19) | def limit_up(price: Expr, high_limit: Expr) -> Expr:
function limit_up_at_open (line 32) | def limit_up_at_open(open_: Expr, high: Expr, low: Expr, close: Expr, hi...
function limit_up_at_close (line 40) | def limit_up_at_close(open_: Expr, high: Expr, low: Expr, close: Expr, h...
function limit_up_at_high (line 48) | def limit_up_at_high(open_: Expr, high: Expr, low: Expr, close: Expr, hi...
function limit_up_four_price_doji (line 56) | def limit_up_four_price_doji(open_: Expr, high: Expr, low: Expr, close: ...
function limit_up_dragonfly (line 64) | def limit_up_dragonfly(open_: Expr, high: Expr, low: Expr, close: Expr, ...
function limit_down (line 72) | def limit_down(price: Expr, low_limit: Expr) -> Expr:
function limit_down_at_open (line 85) | def limit_down_at_open(open_: Expr, high: Expr, low: Expr, close: Expr, ...
function limit_down_at_close (line 93) | def limit_down_at_close(open_: Expr, high: Expr, low: Expr, close: Expr,...
function limit_down_at_high (line 101) | def limit_down_at_high(open_: Expr, high: Expr, low: Expr, close: Expr, ...
function limit_down_four_price_doji (line 109) | def limit_down_four_price_doji(open_: Expr, high: Expr, low: Expr, close...
function limit_down_gravestone (line 117) | def limit_down_gravestone(open_: Expr, high: Expr, low: Expr, close: Exp...
FILE: polars_ta/candles/cdl2.py
function ts_gap_up (line 17) | def ts_gap_up(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function ts_gap_down (line 22) | def ts_gap_down(open_: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function ts_real_body_gap_up (line 27) | def ts_real_body_gap_up(open_: Expr, high: Expr, low: Expr, close: Expr)...
function ts_real_body_gap_down (line 32) | def ts_real_body_gap_down(open_: Expr, high: Expr, low: Expr, close: Exp...
FILE: polars_ta/labels/_nb.py
function _triple_barrier (line 7) | def _triple_barrier(close: np.ndarray, high: np.ndarray, low: np.ndarray...
FILE: polars_ta/labels/future.py
function ts_log_return (line 22) | def ts_log_return(close: Expr, n: int = 5) -> Expr:
function _ts_log_return (line 56) | def _ts_log_return(close: Expr, n: int = 5) -> Expr:
function ts_simple_return (line 65) | def ts_simple_return(close: Expr, n: int = 5, threshold: float = 0.0, *m...
function ts_triple_barrier (line 112) | def ts_triple_barrier(close: Expr, high: Expr, low: Expr, d: int = 5, ta...
FILE: polars_ta/noise.py
function ts_efficiency_ratio (line 20) | def ts_efficiency_ratio(close: Expr, timeperiod: int = 14) -> Expr:
function ts_price_density (line 30) | def ts_price_density(high: Expr, low: Expr, timeperiod: int = 14) -> Expr:
function ts_fractal_dimension (line 41) | def ts_fractal_dimension(high: Expr, low: Expr, close: Expr, timeperiod:...
FILE: polars_ta/performance/drawdown.py
function ts_max_drawdown (line 4) | def ts_max_drawdown(close: Expr) -> Expr:
function ts_max_drawdown_rate (line 9) | def ts_max_drawdown_rate(close: Expr) -> Expr:
FILE: polars_ta/performance/returns.py
function ts_cum_return (line 6) | def ts_cum_return(close: Expr) -> Expr:
function simple_to_log_return (line 15) | def simple_to_log_return(x: Expr) -> Expr:
function log_to_simple_return (line 20) | def log_to_simple_return(x: Expr) -> Expr:
FILE: polars_ta/reports/cicc.py
function ts_RSRS_R2 (line 6) | def ts_RSRS_R2(high: Expr, low: Expr, n: int = 18, m: int = 600) -> Expr:
function ts_RSRS (line 17) | def ts_RSRS(high: Expr, low: Expr, n: int = 18, m: int = 600) -> Expr:
FILE: polars_ta/ta/momentum.py
function APO (line 14) | def APO(close: Expr, fastperiod: int = 12, slowperiod: int = 26, matype:...
function AROON (line 21) | def AROON(high: Expr, low: Expr, timeperiod: int = 14) -> Expr:
function MACD (line 39) | def MACD(close: Expr, fastperiod: int = 12, slowperiod: int = 26, signal...
function MOM (line 56) | def MOM(close: Expr, timeperiod: int = 10) -> Expr:
function PPO (line 67) | def PPO(close: Expr, fastperiod: int = 12, slowperiod: int = 26, matype:...
function ROC (line 74) | def ROC(close: Expr, timeperiod: int = 10) -> Expr:
function ROCP (line 85) | def ROCP(close: Expr, timeperiod: int = 10) -> Expr:
function ROCR (line 96) | def ROCR(close: Expr, timeperiod: int = 10) -> Expr:
function ROCR100 (line 107) | def ROCR100(close: Expr, timeperiod: int = 10) -> Expr:
function RSI (line 118) | def RSI(close: Expr, timeperiod: int = 14) -> Expr:
function STOCHF (line 123) | def STOCHF(high: Expr, low: Expr, close: Expr, fastk_period: int = 5, fa...
function TRIX (line 129) | def TRIX(close: Expr, timeperiod: int = 30) -> Expr:
function RSV (line 136) | def RSV(high: Expr, low: Expr, close: Expr, timeperiod: int = 5) -> Expr:
function WILLR (line 159) | def WILLR(high: Expr, low: Expr, close: Expr, timeperiod: int = 14) -> E...
FILE: polars_ta/ta/operators.py
function MAXINDEX (line 28) | def MAXINDEX(close: Expr, timeperiod: int = 30) -> Expr:
function MININDEX (line 72) | def MININDEX(close: Expr, timeperiod: int = 30) -> Expr:
FILE: polars_ta/ta/overlap.py
function BBANDS (line 12) | def BBANDS(close: Expr, timeperiod: float = 5.0, nbdevup: float = 2.0, n...
function DEMA (line 18) | def DEMA(close: Expr, timeperiod: int = 30) -> Expr:
function EMA (line 24) | def EMA(close: Expr, timeperiod: int = 30) -> Expr:
function KAMA (line 36) | def KAMA(close: Expr, timeperiod: int = 30) -> Expr:
function MIDPOINT (line 40) | def MIDPOINT(close: Expr, timeperiod: int = 14) -> Expr:
function MIDPRICE (line 51) | def MIDPRICE(high: Expr, low: Expr, timeperiod: int = 14) -> Expr:
function RMA (line 62) | def RMA(close: Expr, timeperiod: int = 30) -> Expr:
function TEMA (line 75) | def TEMA(close: Expr, timeperiod: int = 30) -> Expr:
function TRIMA (line 90) | def TRIMA(close: Expr, timeperiod: int = 30) -> Expr:
FILE: polars_ta/ta/price.py
function AVGPRICE (line 4) | def AVGPRICE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:
function MEDPRICE (line 15) | def MEDPRICE(high: Expr, low: Expr) -> Expr:
function TYPPRICE (line 26) | def TYPPRICE(high: Expr, low: Expr, close: Expr) -> Expr:
function WCLPRICE (line 37) | def WCLPRICE(high: Expr, low: Expr, close: Expr) -> Expr:
FILE: polars_ta/ta/statistic.py
function BETA (line 16) | def BETA(high: Expr, low: Expr, timeperiod: int = 5) -> Expr:
function LINEARREG (line 20) | def LINEARREG(close: Expr, timeperiod: int = 14) -> Expr:
function LINEARREG_ANGLE (line 24) | def LINEARREG_ANGLE(close: Expr, timeperiod: int = 14) -> Expr:
function LINEARREG_INTERCEPT (line 28) | def LINEARREG_INTERCEPT(close: Expr, timeperiod: int = 14) -> Expr:
function LINEARREG_SLOPE (line 32) | def LINEARREG_SLOPE(close: Expr, timeperiod: int = 14) -> Expr:
function STDDEV (line 36) | def STDDEV(close: Expr, timeperiod: int = 5, nbdev: float = 1) -> Expr:
function TSF (line 40) | def TSF(close: Expr, timeperiod: int = 14) -> Expr:
function VAR (line 44) | def VAR(close: Expr, timeperiod: int = 5, nbdev: float = 1) -> Expr:
FILE: polars_ta/ta/volatility.py
function TRANGE (line 6) | def TRANGE(high: Expr, low: Expr, close: Expr) -> Expr:
function ATR (line 23) | def ATR(high: Expr, low: Expr, close: Expr, timeperiod: int = 14) -> Expr:
function NATR (line 28) | def NATR(high: Expr, low: Expr, close: Expr, timeperiod: int = 14) -> Expr:
FILE: polars_ta/ta/volume.py
function AD (line 6) | def AD(high: Expr, low: Expr, close: Expr, volume: Expr) -> Expr:
function ADOSC (line 11) | def ADOSC(high: Expr, low: Expr, close: Expr, volume: Expr, fastperiod: ...
function OBV (line 16) | def OBV(close: Expr, volume: Expr) -> Expr:
FILE: polars_ta/talib/__init__.py
function HT_DCPERIOD (line 8) | def HT_DCPERIOD(close: Expr) -> Expr: # ['real']
function HT_DCPHASE (line 22) | def HT_DCPHASE(close: Expr) -> Expr: # ['real']
function HT_PHASOR (line 36) | def HT_PHASOR(close: Expr) -> Expr: # ['inphase', 'quadrature']
function HT_SINE (line 52) | def HT_SINE(close: Expr) -> Expr: # ['sine', 'leadsine']
function HT_TRENDMODE (line 68) | def HT_TRENDMODE(close: Expr) -> Expr: # ['integer']
function ADD (line 82) | def ADD(high: Expr, low: Expr) -> Expr: # ['real']
function DIV (line 97) | def DIV(high: Expr, low: Expr) -> Expr: # ['real']
function MAX (line 112) | def MAX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function MAXINDEX (line 128) | def MAXINDEX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['integer']
function MIN (line 144) | def MIN(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function MININDEX (line 160) | def MININDEX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['integer']
function MINMAX (line 176) | def MINMAX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['min', 'm...
function MINMAXINDEX (line 194) | def MINMAXINDEX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['min...
function MULT (line 212) | def MULT(high: Expr, low: Expr) -> Expr: # ['real']
function SUB (line 227) | def SUB(high: Expr, low: Expr) -> Expr: # ['real']
function SUM (line 242) | def SUM(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function ACOS (line 258) | def ACOS(close: Expr) -> Expr: # ['real']
function ASIN (line 272) | def ASIN(close: Expr) -> Expr: # ['real']
function ATAN (line 286) | def ATAN(close: Expr) -> Expr: # ['real']
function CEIL (line 300) | def CEIL(close: Expr) -> Expr: # ['real']
function COS (line 314) | def COS(close: Expr) -> Expr: # ['real']
function COSH (line 328) | def COSH(close: Expr) -> Expr: # ['real']
function EXP (line 342) | def EXP(close: Expr) -> Expr: # ['real']
function FLOOR (line 356) | def FLOOR(close: Expr) -> Expr: # ['real']
function LN (line 370) | def LN(close: Expr) -> Expr: # ['real']
function LOG10 (line 384) | def LOG10(close: Expr) -> Expr: # ['real']
function SIN (line 398) | def SIN(close: Expr) -> Expr: # ['real']
function SINH (line 412) | def SINH(close: Expr) -> Expr: # ['real']
function SQRT (line 426) | def SQRT(close: Expr) -> Expr: # ['real']
function TAN (line 440) | def TAN(close: Expr) -> Expr: # ['real']
function TANH (line 454) | def TANH(close: Expr) -> Expr: # ['real']
function ADX (line 468) | def ADX(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) ->...
function ADXR (line 484) | def ADXR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -...
function APO (line 500) | def APO(close: Expr, fastperiod: float = 12.0, slowperiod: float = 26.0,...
function AROON (line 518) | def AROON(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: # [...
function AROONOSC (line 536) | def AROONOSC(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: ...
function BOP (line 552) | def BOP(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ['re...
function CCI (line 566) | def CCI(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) ->...
function CMO (line 582) | def CMO(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
function DX (line 598) | def DX(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -> ...
function MACD (line 614) | def MACD(close: Expr, fastperiod: float = 12.0, slowperiod: float = 26.0...
function MACDEXT (line 635) | def MACDEXT(close: Expr, fastperiod: float = 12.0, fastmatype: float = 0...
function MACDFIX (line 659) | def MACDFIX(close: Expr, signalperiod: float = 9.0) -> Expr: # ['macd',...
function MFI (line 678) | def MFI(high: Expr, low: Expr, close: Expr, volume: Expr, timeperiod: fl...
function MINUS_DI (line 694) | def MINUS_DI(high: Expr, low: Expr, close: Expr, timeperiod: float = 14....
function MINUS_DM (line 710) | def MINUS_DM(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: ...
function MOM (line 726) | def MOM(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
function PLUS_DI (line 742) | def PLUS_DI(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0...
function PLUS_DM (line 758) | def PLUS_DM(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: #...
function PPO (line 774) | def PPO(close: Expr, fastperiod: float = 12.0, slowperiod: float = 26.0,...
function ROC (line 792) | def ROC(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
function ROCP (line 808) | def ROCP(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
function ROCR (line 824) | def ROCR(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
function ROCR100 (line 840) | def ROCR100(close: Expr, timeperiod: float = 10.0) -> Expr: # ['real']
function RSI (line 856) | def RSI(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
function STOCH (line 872) | def STOCH(high: Expr, low: Expr, close: Expr, fastk_period: float = 5.0,...
function STOCHF (line 894) | def STOCHF(high: Expr, low: Expr, close: Expr, fastk_period: float = 5.0...
function STOCHRSI (line 914) | def STOCHRSI(close: Expr, timeperiod: float = 14.0, fastk_period: float ...
function TRIX (line 935) | def TRIX(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function ULTOSC (line 951) | def ULTOSC(high: Expr, low: Expr, close: Expr, timeperiod1: float = 7.0,...
function WILLR (line 969) | def WILLR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) ...
function BBANDS (line 985) | def BBANDS(close: Expr, timeperiod: float = 5.0, nbdevup: float = 2.0, n...
function DEMA (line 1007) | def DEMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function EMA (line 1023) | def EMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function HT_TRENDLINE (line 1039) | def HT_TRENDLINE(close: Expr) -> Expr: # ['real']
function KAMA (line 1053) | def KAMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function MA (line 1069) | def MA(close: Expr, timeperiod: float = 30.0, matype: float = 0.0) -> Ex...
function MAMA (line 1086) | def MAMA(close: Expr, fastlimit: float = 0.5, slowlimit: float = 0.05) -...
function MAVP (line 1105) | def MAVP(close: Expr, periods: Expr, minperiod: float = 2.0, maxperiod: ...
function MIDPOINT (line 1124) | def MIDPOINT(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
function MIDPRICE (line 1140) | def MIDPRICE(high: Expr, low: Expr, timeperiod: float = 14.0) -> Expr: ...
function SAR (line 1156) | def SAR(high: Expr, low: Expr, acceleration: float = 0.02, maximum: floa...
function SAREXT (line 1173) | def SAREXT(high: Expr, low: Expr, startvalue: float = 0.0, offsetonrever...
function SMA (line 1196) | def SMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function T3 (line 1212) | def T3(close: Expr, timeperiod: float = 5.0, vfactor: float = 0.7) -> Ex...
function TEMA (line 1229) | def TEMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function TRIMA (line 1245) | def TRIMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function WMA (line 1261) | def WMA(close: Expr, timeperiod: float = 30.0) -> Expr: # ['real']
function CDL2CROWS (line 1277) | def CDL2CROWS(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDL3BLACKCROWS (line 1291) | def CDL3BLACKCROWS(open: Expr, high: Expr, low: Expr, close: Expr) -> Ex...
function CDL3INSIDE (line 1305) | def CDL3INSIDE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDL3LINESTRIKE (line 1319) | def CDL3LINESTRIKE(open: Expr, high: Expr, low: Expr, close: Expr) -> Ex...
function CDL3OUTSIDE (line 1333) | def CDL3OUTSIDE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:...
function CDL3STARSINSOUTH (line 1347) | def CDL3STARSINSOUTH(open: Expr, high: Expr, low: Expr, close: Expr) -> ...
function CDL3WHITESOLDIERS (line 1361) | def CDL3WHITESOLDIERS(open: Expr, high: Expr, low: Expr, close: Expr) ->...
function CDLABANDONEDBABY (line 1375) | def CDLABANDONEDBABY(open: Expr, high: Expr, low: Expr, close: Expr, pen...
function CDLADVANCEBLOCK (line 1391) | def CDLADVANCEBLOCK(open: Expr, high: Expr, low: Expr, close: Expr) -> E...
function CDLBELTHOLD (line 1405) | def CDLBELTHOLD(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:...
function CDLBREAKAWAY (line 1419) | def CDLBREAKAWAY(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr...
function CDLCLOSINGMARUBOZU (line 1433) | def CDLCLOSINGMARUBOZU(open: Expr, high: Expr, low: Expr, close: Expr) -...
function CDLCONCEALBABYSWALL (line 1447) | def CDLCONCEALBABYSWALL(open: Expr, high: Expr, low: Expr, close: Expr) ...
function CDLCOUNTERATTACK (line 1461) | def CDLCOUNTERATTACK(open: Expr, high: Expr, low: Expr, close: Expr) -> ...
function CDLDARKCLOUDCOVER (line 1475) | def CDLDARKCLOUDCOVER(open: Expr, high: Expr, low: Expr, close: Expr, pe...
function CDLDOJI (line 1491) | def CDLDOJI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: # ...
function CDLDOJISTAR (line 1505) | def CDLDOJISTAR(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:...
function CDLDRAGONFLYDOJI (line 1519) | def CDLDRAGONFLYDOJI(open: Expr, high: Expr, low: Expr, close: Expr) -> ...
function CDLENGULFING (line 1533) | def CDLENGULFING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr...
function CDLEVENINGDOJISTAR (line 1547) | def CDLEVENINGDOJISTAR(open: Expr, high: Expr, low: Expr, close: Expr, p...
function CDLEVENINGSTAR (line 1563) | def CDLEVENINGSTAR(open: Expr, high: Expr, low: Expr, close: Expr, penet...
function CDLGAPSIDESIDEWHITE (line 1579) | def CDLGAPSIDESIDEWHITE(open: Expr, high: Expr, low: Expr, close: Expr) ...
function CDLGRAVESTONEDOJI (line 1593) | def CDLGRAVESTONEDOJI(open: Expr, high: Expr, low: Expr, close: Expr) ->...
function CDLHAMMER (line 1607) | def CDLHAMMER(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLHANGINGMAN (line 1621) | def CDLHANGINGMAN(open: Expr, high: Expr, low: Expr, close: Expr) -> Exp...
function CDLHARAMI (line 1635) | def CDLHARAMI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLHARAMICROSS (line 1649) | def CDLHARAMICROSS(open: Expr, high: Expr, low: Expr, close: Expr) -> Ex...
function CDLHIGHWAVE (line 1663) | def CDLHIGHWAVE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:...
function CDLHIKKAKE (line 1677) | def CDLHIKKAKE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLHIKKAKEMOD (line 1691) | def CDLHIKKAKEMOD(open: Expr, high: Expr, low: Expr, close: Expr) -> Exp...
function CDLHOMINGPIGEON (line 1705) | def CDLHOMINGPIGEON(open: Expr, high: Expr, low: Expr, close: Expr) -> E...
function CDLIDENTICAL3CROWS (line 1719) | def CDLIDENTICAL3CROWS(open: Expr, high: Expr, low: Expr, close: Expr) -...
function CDLINNECK (line 1733) | def CDLINNECK(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLINVERTEDHAMMER (line 1747) | def CDLINVERTEDHAMMER(open: Expr, high: Expr, low: Expr, close: Expr) ->...
function CDLKICKING (line 1761) | def CDLKICKING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLKICKINGBYLENGTH (line 1775) | def CDLKICKINGBYLENGTH(open: Expr, high: Expr, low: Expr, close: Expr) -...
function CDLLADDERBOTTOM (line 1789) | def CDLLADDERBOTTOM(open: Expr, high: Expr, low: Expr, close: Expr) -> E...
function CDLLONGLEGGEDDOJI (line 1803) | def CDLLONGLEGGEDDOJI(open: Expr, high: Expr, low: Expr, close: Expr) ->...
function CDLLONGLINE (line 1817) | def CDLLONGLINE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:...
function CDLMARUBOZU (line 1831) | def CDLMARUBOZU(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:...
function CDLMATCHINGLOW (line 1845) | def CDLMATCHINGLOW(open: Expr, high: Expr, low: Expr, close: Expr) -> Ex...
function CDLMATHOLD (line 1859) | def CDLMATHOLD(open: Expr, high: Expr, low: Expr, close: Expr, penetrati...
function CDLMORNINGDOJISTAR (line 1875) | def CDLMORNINGDOJISTAR(open: Expr, high: Expr, low: Expr, close: Expr, p...
function CDLMORNINGSTAR (line 1891) | def CDLMORNINGSTAR(open: Expr, high: Expr, low: Expr, close: Expr, penet...
function CDLONNECK (line 1907) | def CDLONNECK(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLPIERCING (line 1921) | def CDLPIERCING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:...
function CDLRICKSHAWMAN (line 1935) | def CDLRICKSHAWMAN(open: Expr, high: Expr, low: Expr, close: Expr) -> Ex...
function CDLRISEFALL3METHODS (line 1949) | def CDLRISEFALL3METHODS(open: Expr, high: Expr, low: Expr, close: Expr) ...
function CDLSEPARATINGLINES (line 1963) | def CDLSEPARATINGLINES(open: Expr, high: Expr, low: Expr, close: Expr) -...
function CDLSHOOTINGSTAR (line 1977) | def CDLSHOOTINGSTAR(open: Expr, high: Expr, low: Expr, close: Expr) -> E...
function CDLSHORTLINE (line 1991) | def CDLSHORTLINE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr...
function CDLSPINNINGTOP (line 2005) | def CDLSPINNINGTOP(open: Expr, high: Expr, low: Expr, close: Expr) -> Ex...
function CDLSTALLEDPATTERN (line 2019) | def CDLSTALLEDPATTERN(open: Expr, high: Expr, low: Expr, close: Expr) ->...
function CDLSTICKSANDWICH (line 2033) | def CDLSTICKSANDWICH(open: Expr, high: Expr, low: Expr, close: Expr) -> ...
function CDLTAKURI (line 2047) | def CDLTAKURI(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLTASUKIGAP (line 2061) | def CDLTASUKIGAP(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr...
function CDLTHRUSTING (line 2075) | def CDLTHRUSTING(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr...
function CDLTRISTAR (line 2089) | def CDLTRISTAR(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: ...
function CDLUNIQUE3RIVER (line 2103) | def CDLUNIQUE3RIVER(open: Expr, high: Expr, low: Expr, close: Expr) -> E...
function CDLUPSIDEGAP2CROWS (line 2117) | def CDLUPSIDEGAP2CROWS(open: Expr, high: Expr, low: Expr, close: Expr) -...
function CDLXSIDEGAP3METHODS (line 2131) | def CDLXSIDEGAP3METHODS(open: Expr, high: Expr, low: Expr, close: Expr) ...
function AVGPRICE (line 2145) | def AVGPRICE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr: #...
function MEDPRICE (line 2159) | def MEDPRICE(high: Expr, low: Expr) -> Expr: # ['real']
function TYPPRICE (line 2173) | def TYPPRICE(high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
function WCLPRICE (line 2187) | def WCLPRICE(high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
function BETA (line 2201) | def BETA(high: Expr, low: Expr, timeperiod: float = 5.0) -> Expr: # ['r...
function CORREL (line 2218) | def CORREL(high: Expr, low: Expr, timeperiod: float = 30.0) -> Expr: # ...
function LINEARREG (line 2235) | def LINEARREG(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
function LINEARREG_ANGLE (line 2251) | def LINEARREG_ANGLE(close: Expr, timeperiod: float = 14.0) -> Expr: # [...
function LINEARREG_INTERCEPT (line 2267) | def LINEARREG_INTERCEPT(close: Expr, timeperiod: float = 14.0) -> Expr: ...
function LINEARREG_SLOPE (line 2283) | def LINEARREG_SLOPE(close: Expr, timeperiod: float = 14.0) -> Expr: # [...
function STDDEV (line 2299) | def STDDEV(close: Expr, timeperiod: float = 5.0, nbdev: float = 1.0) -> ...
function TSF (line 2316) | def TSF(close: Expr, timeperiod: float = 14.0) -> Expr: # ['real']
function VAR (line 2332) | def VAR(close: Expr, timeperiod: float = 5.0, nbdev: float = 1.0) -> Exp...
function ATR (line 2349) | def ATR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) ->...
function NATR (line 2365) | def NATR(high: Expr, low: Expr, close: Expr, timeperiod: float = 14.0) -...
function TRANGE (line 2381) | def TRANGE(high: Expr, low: Expr, close: Expr) -> Expr: # ['real']
function AD (line 2395) | def AD(high: Expr, low: Expr, close: Expr, volume: Expr) -> Expr: # ['r...
function ADOSC (line 2409) | def ADOSC(high: Expr, low: Expr, close: Expr, volume: Expr, fastperiod: ...
function OBV (line 2426) | def OBV(close: Expr, volume: Expr) -> Expr: # ['real']
FILE: polars_ta/tdx/_chip.py
function nb_chip (line 6) | def nb_chip(high, low, avg, turnover,
function _WINNER_COST (line 101) | def _WINNER_COST(high, low, avg, turnover, close, cost, step):
FILE: polars_ta/tdx/_nb.py
function roll_avedev (line 8) | def roll_avedev(x1, window):
function roll_bars_since_n (line 19) | def roll_bars_since_n(x1, window):
function _up_stat (line 39) | def _up_stat(a, d: int = 3):
FILE: polars_ta/tdx/_slow.py
function _avedev (line 4) | def _avedev(x: Series) -> Series:
function AVEDEV (line 10) | def AVEDEV(close: Expr, timeperiod: int = 5) -> Expr:
FILE: polars_ta/tdx/arithmetic.py
function ROUND (line 62) | def ROUND(x: Expr) -> Expr:
function ROUND2 (line 67) | def ROUND2(x: Expr, decimals: int = 0) -> Expr:
function BETWEEN (line 72) | def BETWEEN(a: Expr, b: Expr, c: Expr) -> Expr:
FILE: polars_ta/tdx/choice.py
function IF (line 8) | def IF(condition: Expr, a: Expr, b: Expr) -> Expr:
function IFN (line 15) | def IFN(condition: Expr, a: Expr, b: Expr) -> Expr:
function VALUEWHEN (line 22) | def VALUEWHEN(condition: Expr, x: Expr) -> Expr:
FILE: polars_ta/tdx/energy.py
function BRAR_AR (line 11) | def BRAR_AR(OPEN: Expr, HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 26)...
function BRAR_BR (line 22) | def BRAR_BR(OPEN: Expr, HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 26)...
function CR (line 33) | def CR(HIGH: Expr, LOW: Expr, N: int = 26) -> Expr:
function PSY (line 47) | def PSY(CLOSE: Expr, N: int = 12) -> Expr:
function MASS (line 56) | def MASS(HIGH: Expr, LOW: Expr, N1: int = 9, N2: int = 25) -> Expr:
FILE: polars_ta/tdx/logical.py
function CROSS (line 8) | def CROSS(a: Expr, b: Expr) -> Expr:
function DOWNNDAY (line 49) | def DOWNNDAY(close: Expr, N: int) -> Expr:
function EVERY (line 54) | def EVERY(condition: Expr, N: int) -> Expr:
function EXIST (line 59) | def EXIST(condition: Expr, N: int) -> Expr:
function EXISTR (line 64) | def EXISTR(condition: Expr, a: int, b: int) -> Expr:
function LAST (line 72) | def LAST(condition: Expr, a: int, b: int) -> Expr:
function LONGCROSS (line 80) | def LONGCROSS(a: Expr, b: Expr, N: int) -> Expr:
function NDAY (line 85) | def NDAY(close: Expr, open_: Expr, N: int) -> Expr:
function NOT (line 90) | def NOT(condition: Expr) -> Expr:
function UPNDAY (line 95) | def UPNDAY(close: Expr, N: int) -> Expr:
FILE: polars_ta/tdx/moving_average.py
function BBI (line 7) | def BBI(CLOSE: Expr, M1: int = 3, M2: int = 6, M3: int = 12, M4: int = 2...
FILE: polars_ta/tdx/over_bought_over_sold.py
function ATR (line 17) | def ATR(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 14) -> Expr:
function BIAS (line 29) | def BIAS(CLOSE: Expr, N: int = 6) -> Expr:
function CCI (line 39) | def CCI(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 14) -> Expr:
function KDJ (line 54) | def KDJ(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 9, M1: int = 3, M2:...
function MTM (line 69) | def MTM(CLOSE: Expr, N: int = 12) -> Expr:
function MFI (line 78) | def MFI(CLOSE: Expr, HIGH: Expr, LOW: Expr, VOL: Expr, N: int = 14) -> E...
FILE: polars_ta/tdx/pattern.py
function ts_WINNER_COST (line 7) | def ts_WINNER_COST(high: Expr, low: Expr, avg: Expr, turnover: Expr, clo...
FILE: polars_ta/tdx/pattern_feature.py
function 早晨之星 (line 16) | def 早晨之星(OPEN: Expr, CLOSE: Expr) -> Expr:
function 剑 (line 26) | def 剑(OPEN: Expr, HIGH: Expr, LOW: Expr, CLOSE: Expr, VOL: Expr, CAPITAL...
function 天量法则 (line 38) | def 天量法则(OPEN: Expr, CLOSE: Expr) -> Expr:
function 四串阴 (line 47) | def 四串阴(OPEN: Expr, CLOSE: Expr) -> Expr:
function 四串阳 (line 52) | def 四串阳(OPEN: Expr, CLOSE: Expr) -> Expr:
function 鸳鸯底 (line 57) | def 鸳鸯底(O: Expr, LOW: Expr, C: Expr, V: Expr, N: int = 50) -> Expr:
function 出水芙蓉 (line 62) | def 出水芙蓉(OPEN: Expr, CLOSE: Expr, S: int = 20, M: int = 40, N: int = 60)...
function 出水芙蓉II (line 70) | def 出水芙蓉II(C: Expr, V: Expr, N: float = 0.05, M: float = 2.0) -> Expr:
function 近日创历史新高 (line 78) | def 近日创历史新高(HIGH: Expr, N: int = 3, M: int = 0) -> Expr:
function 近日创历史新低 (line 86) | def 近日创历史新低(LOW: Expr, N: int = 3, M: int = 0) -> Expr:
function 旭日初升 (line 94) | def 旭日初升(CLOSE: Expr, VOL: Expr, N: int = 120) -> Expr:
function 蜻蜓点水 (line 100) | def 蜻蜓点水(CLOSE: Expr, N: int = 120) -> Expr:
function 均线多头排列 (line 107) | def 均线多头排列(OPEN: Expr, CLOSE: Expr, N: int = 5, N1: int = 10, N2: int = ...
function 均线空头排列 (line 116) | def 均线空头排列(OPEN: Expr, CLOSE: Expr, N: int = 5, N1: int = 10, N2: int = ...
function 强势整理 (line 125) | def 强势整理(OPEN: Expr, CLOSE: Expr, N: int = 2, M: float = 0.05) -> Expr:
function 高开大阴线 (line 133) | def 高开大阴线(OPEN: Expr, CLOSE: Expr, N: float = 0.06, M: float = 0.04) -> ...
function 低开大阳线 (line 140) | def 低开大阳线(OPEN: Expr, CLOSE: Expr, N: float = 0.06, M: float = 0.04) -> ...
function 跳空缺口选股 (line 147) | def 跳空缺口选股(HIGH: Expr, LOW: Expr) -> Expr:
function 单阳不破选股 (line 154) | def 单阳不破选股(O: Expr, H: Expr, L: Expr, C: Expr, N1: int = 2, N2: int = 7)...
function 回补跳空向上缺口 (line 168) | def 回补跳空向上缺口(O: Expr, H: Expr, L: Expr, C: Expr, N1: int = 2, N2: int = ...
function 揉搓线 (line 173) | def 揉搓线(O: Expr, H: Expr, L: Expr, C: Expr, V: Expr, N: int = 50) -> Expr:
function 老鸭头 (line 184) | def 老鸭头(L: Expr, C: Expr, V: Expr) -> Expr:
function 仙人指路 (line 204) | def 仙人指路(O: Expr, H: Expr, C: Expr) -> Expr:
function 低点搜寻 (line 217) | def 低点搜寻(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 5) -> Expr:
function 突破 (line 223) | def 突破(C: Expr, N1: int = 5, N2: int = 10, N3: int = 30) -> Expr:
FILE: polars_ta/tdx/pressure_support.py
function BOLL (line 8) | def BOLL(close: Expr, M: int = 20, N: int = 2) -> Expr:
function BOLL_M (line 21) | def BOLL_M(close: Expr, M: int = 20, N: int = 2) -> Expr:
FILE: polars_ta/tdx/reference.py
function BARSLAST (line 45) | def BARSLAST(condition: Expr) -> Expr:
function BARSLASTCOUNT (line 53) | def BARSLASTCOUNT(condition: Expr) -> Expr:
function BARSSINCE (line 61) | def BARSSINCE(condition: Expr) -> Expr:
function BARSSINCEN (line 69) | def BARSSINCEN(condition: Expr, N: int = 30) -> Expr:
function CUMSUM (line 75) | def CUMSUM(close: Expr) -> Expr:
function DMA (line 80) | def DMA(close: Expr, alpha: float = 0.5) -> Expr:
function EMA (line 90) | def EMA(close: Expr, N: int = 30) -> Expr:
function EXPMA (line 100) | def EXPMA(close: Expr, N: int = 30) -> Expr:
function EXPMEMA (line 104) | def EXPMEMA(close: Expr, N: int = 30) -> Expr:
function HOD (line 118) | def HOD(close: Expr, N: int = 30) -> Expr:
function LOD (line 124) | def LOD(close: Expr, N: int = 30) -> Expr:
function LOWRANGE (line 130) | def LOWRANGE(close: Expr) -> Expr:
function MEMA (line 136) | def MEMA(close: Expr, N: int = 30) -> Expr:
function RANGE (line 145) | def RANGE(a: Expr, b: Expr, c: Expr) -> Expr:
function SMA_CN (line 150) | def SMA_CN(X: Expr, N: int, M: int) -> Expr:
function SUMIF (line 161) | def SUMIF(condition: Expr, close: Expr, N: int = 30) -> Expr:
function TMA (line 165) | def TMA(close: Expr, N: int = 30) -> Expr:
function FILTER (line 170) | def FILTER(close: Expr, N: int = 30) -> Expr:
function REFX (line 174) | def REFX(close: Expr, N: int = 30) -> Expr:
FILE: polars_ta/tdx/statistic.py
function AVEDEV (line 10) | def AVEDEV(close: Expr, timeperiod: int = 5) -> Expr:
function DEVSQ (line 16) | def DEVSQ(close: Expr, timeperiod: int = 5) -> Expr:
function SLOPE (line 20) | def SLOPE(close: Expr, timeperiod: int = 5) -> Expr:
function STD (line 24) | def STD(close: Expr, timeperiod: int = 5) -> Expr:
function STDDEV (line 30) | def STDDEV(close: Expr, timeperiod: int = 5) -> Expr:
function STDP (line 35) | def STDP(close: Expr, timeperiod: int = 5) -> Expr:
function VAR (line 41) | def VAR(close: Expr, timeperiod: int = 5) -> Expr:
function VARP (line 45) | def VARP(close: Expr, timeperiod: int = 5) -> Expr:
function ts_up_stat (line 49) | def ts_up_stat(x: Expr) -> Expr:
FILE: polars_ta/tdx/times.py
function FROMOPEN (line 6) | def FROMOPEN(t: Expr) -> Expr:
function FROMOPEN_1 (line 54) | def FROMOPEN_1(t: Expr, offset: int) -> Expr:
FILE: polars_ta/tdx/trend.py
function DPO (line 12) | def DPO(CLOSE: Expr, N: int = 20) -> Expr:
function EMV (line 21) | def EMV(HIGH: Expr, LOW: Expr, VOL: Expr, N: int = 14) -> Expr:
function PLUS_DM (line 36) | def PLUS_DM(HIGH: Expr, LOW: Expr, N: int = 14) -> Expr:
function MINUS_DM (line 50) | def MINUS_DM(HIGH: Expr, LOW: Expr, N: int = 14) -> Expr:
function PLUS_DI (line 57) | def PLUS_DI(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 14) -> Expr:
function MINUS_DI (line 73) | def MINUS_DI(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 14) -> Expr:
function ADX (line 80) | def ADX(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 14, M: int = 6) -> ...
function ADXR (line 102) | def ADXR(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 14, M: int = 6) ->...
FILE: polars_ta/tdx/trend_feature.py
function N天内有跳空向上缺口 (line 15) | def N天内有跳空向上缺口(H: Expr, L: Expr, N: int = 1, M: float = 0.01) -> Expr:
function N日内创新高 (line 30) | def N日内创新高(HIGH: Expr, N: int = 10) -> Expr:
function N日内创新低 (line 36) | def N日内创新低(LOW: Expr, N: int = 10) -> Expr:
function N日内阴线多于阳线 (line 42) | def N日内阴线多于阳线(OPEN: Expr, CLOSE: Expr, N: int = 30, M: float = 0.6) -> E...
function N日内阳线多于阴线 (line 56) | def N日内阳线多于阴线(OPEN: Expr, CLOSE: Expr, N: int = 30, M: float = 0.6) -> E...
function N日内上涨多于下跌 (line 70) | def N日内上涨多于下跌(CLOSE: Expr, N: int = 120, M: float = 0.6) -> Expr:
function N日内下跌多于上涨 (line 84) | def N日内下跌多于上涨(CLOSE: Expr, N: int = 120, M: float = 0.6) -> Expr:
function 连续N天收阳线 (line 98) | def 连续N天收阳线(OPEN: Expr, CLOSE: Expr, N: int = 7) -> Expr:
function 连续N天收阴线 (line 110) | def 连续N天收阴线(OPEN: Expr, CLOSE: Expr, N: int = 7) -> Expr:
function 单日放量 (line 122) | def 单日放量(VOL: Expr, CAPITAL: Expr, N: float = 2, M: float = 0.15) -> Expr:
function 阶段缩量 (line 140) | def 阶段缩量(VOL: Expr, CAPITAL: Expr, N: int = 20, M: float = 0.02) -> Expr:
function 阶段放量 (line 158) | def 阶段放量(VOL: Expr, CAPITAL: Expr, N: int = 10, M: float = 2.0) -> Expr:
function 持续放量 (line 172) | def 持续放量(VOL: Expr, M: int = 5) -> Expr:
function 持续缩量 (line 184) | def 持续缩量(VOL: Expr, M: int = 5) -> Expr:
function 间隔放量 (line 196) | def 间隔放量(VOL: Expr, N: int = 30, N1: float = 4.0, N2: float = 2.0, N3: i...
function 放量上攻 (line 219) | def 放量上攻(CLOSE: Expr, VOL: Expr, CAPITAL: Expr,
function 温和放量上攻 (line 246) | def 温和放量上攻(CLOSE: Expr, VOL: Expr, CAPITAL: Expr, N: int = 5) -> Expr:
function 突然放量 (line 270) | def 突然放量(VOL: Expr, N: int = 10, M: float = 3.0) -> Expr:
function 平台整理 (line 286) | def 平台整理(CLOSE: Expr, N: int = 30, N1: float = 0.05) -> Expr:
function 小步碎阳 (line 300) | def 小步碎阳(O: Expr, H: Expr, L: Expr, C: Expr, avg: Expr, turnover_ratio: ...
function 突破长期盘整 (line 321) | def 突破长期盘整(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 30, N1: int = 5)...
function N天内出现以涨停收盘 (line 338) | def N天内出现以涨停收盘(收盘涨停: Expr, N: int = 10) -> Expr:
function N天内出现涨停 (line 350) | def N天内出现涨停(最高涨停: Expr, N: int = 20) -> Expr:
function N天内经常涨停 (line 362) | def N天内经常涨停(收盘涨停: Expr, N: int = 100, M: int = 8) -> Expr:
function 下跌多日再放量上涨 (line 376) | def 下跌多日再放量上涨(HIGH: Expr, CLOSE: Expr, VOL: Expr) -> Expr:
function 跳空高开或低开 (line 388) | def 跳空高开或低开(O: Expr, H: Expr, L: Expr, C: Expr, N: float = 0.03) -> Expr:
function 拉升后多日调整 (line 405) | def 拉升后多日调整(C: Expr, N: int = 3, ZF: float = 0.09) -> Expr:
function 昨日底部十字星 (line 421) | def 昨日底部十字星(O: Expr, H: Expr, L: Expr, C: Expr, N: int = 60) -> Expr:
function 价量渐低后阳包阴 (line 437) | def 价量渐低后阳包阴(O: Expr, C: Expr, V: Expr) -> Expr:
FILE: polars_ta/tdx/volume.py
function OBV (line 9) | def OBV(CLOSE: Expr, VOL: Expr) -> Expr:
function VR (line 20) | def VR(CLOSE: Expr, VOL: Expr, N: int = 26) -> Expr:
FILE: polars_ta/utils/factor.py
function calc_factor_muldiv (line 16) | def calc_factor_muldiv(df: pl.DataFrame,
function calc_factor_addsub (line 48) | def calc_factor_addsub(df: pl.DataFrame,
FILE: polars_ta/utils/functions.py
function const_to_expr (line 10) | def const_to_expr(func):
function apply_const_to_expr (line 28) | def apply_const_to_expr():
FILE: polars_ta/utils/numba_.py
function isnan (line 21) | def isnan(x):
function full_with_window_size (line 30) | def full_with_window_size(arr, fill_value, dtype=None, window_size: int ...
function sliding_window_with_min_periods (line 38) | def sliding_window_with_min_periods(arr, window_size: int, min_periods: ...
function _roll_1 (line 49) | def _roll_1(x1: np.ndarray, window: int, min_periods: int, func):
function _roll_2 (line 62) | def _roll_2(x1, x2, window, min_periods, func):
function _roll_3 (line 79) | def _roll_3(x1, x2, x3, window, min_periods, func):
function struct_to_numpy (line 99) | def struct_to_numpy(xx, n: int, dtype=None):
function batches_i1_o1 (line 106) | def batches_i1_o1(x1: np.ndarray, func, *args, dtype=None) -> Series:
function batches_i2_o1 (line 110) | def batches_i2_o1(xx: List[np.ndarray], func, *args, dtype=None) -> Series:
function batches_i1_o2 (line 114) | def batches_i1_o2(x1: np.ndarray, func, *args, dtype=None) -> Series:
function batches_i2_o2 (line 118) | def batches_i2_o2(xx: List[np.ndarray], func, *args, dtype=None) -> Series:
function batches_i2_o2_v2 (line 122) | def batches_i2_o2_v2(xx: List[np.ndarray], func, *args, dtype=None) -> S...
function nb_roll_sum (line 132) | def nb_roll_sum(x1, window):
function nb_roll_cov (line 145) | def nb_roll_cov(x1, x2, window):
function roll_sum (line 158) | def roll_sum(x: Expr, n: int) -> Expr:
function roll_cov (line 162) | def roll_cov(a: Expr, b: Expr, n: int) -> Expr:
function get_exponent_weights (line 168) | def get_exponent_weights(
FILE: polars_ta/utils/pit.py
function pit_prepare (line 43) | def pit_prepare(df: pl.DataFrame | pl.LazyFrame,
function pit_calc (line 124) | def pit_calc(df: pl.DataFrame | pl.LazyFrame,
function pit_frist (line 141) | def pit_frist(df: pl.DataFrame | pl.LazyFrame,
function period_to_quarter (line 173) | def period_to_quarter(col: pl.Expr | str, quarter: pl.Expr | str) -> pl....
function ttm_from_point (line 195) | def ttm_from_point(col: pl.Expr | str) -> pl.Expr:
function last_year (line 220) | def last_year(col: pl.Expr | str, quarter: pl.Expr | str) -> pl.Expr:
function ttm_from_period (line 239) | def ttm_from_period(col: pl.Expr | str, quarter: pl.Expr | str) -> pl.Expr:
function yoy (line 270) | def yoy(col: pl.Expr, period: int = 4) -> pl.Expr:
function qoq (line 275) | def qoq(col: pl.Expr, period: int = 1) -> pl.Expr:
function join_quote_financial (line 280) | def join_quote_financial(quote: pl.DataFrame | pl.LazyFrame,
function sheet_from_joinquant (line 321) | def sheet_from_joinquant(df: pl.DataFrame | pl.LazyFrame) -> pl.DataFram...
FILE: polars_ta/utils/withs.py
function with_industry (line 6) | def with_industry(df: pl.DataFrame, industry_name: str, drop_first: bool...
FILE: polars_ta/wq/_nb.py
function roll_argmax (line 10) | def roll_argmax(x1, window, min_periods, reverse):
function roll_argmin (line 26) | def roll_argmin(x1, window, min_periods, reverse):
function roll_prod (line 42) | def roll_prod(x1, window, min_periods):
function _co_kurtosis (line 54) | def _co_kurtosis(a1, a2):
function roll_co_kurtosis (line 63) | def roll_co_kurtosis(x1, x2, window, min_periods):
function _co_skewness (line 79) | def _co_skewness(a1, a2):
function roll_co_skewness (line 88) | def roll_co_skewness(x1, x2, window, min_periods):
function _moment (line 104) | def _moment(a1, k):
function roll_moment (line 111) | def roll_moment(x1, window, min_periods, k):
function _partial_corr (line 123) | def _partial_corr(a1, a2, a3):
function roll_partial_corr (line 136) | def roll_partial_corr(x1, x2, x3, window, min_periods):
function _triple_corr (line 156) | def _triple_corr(a1, a2, a3):
function roll_triple_corr (line 167) | def roll_triple_corr(x1, x2, x3, window, min_periods):
function _cum_prod_by (line 187) | def _cum_prod_by(r, by):
function _cum_sum_by (line 197) | def _cum_sum_by(r, by):
function _cum_sum_reset (line 207) | def _cum_sum_reset(a):
function _sum_split_by (line 231) | def _sum_split_by(x1, x2, window=10, n=2):
function _signals_to_size (line 249) | def _signals_to_size(is_long_entry: np.ndarray, is_long_exit: np.ndarray,
function _roll_decay_linear (line 321) | def _roll_decay_linear(x1, window, min_periods):
function _roll_decay_exp_window (line 342) | def _roll_decay_exp_window(x1, window, min_periods, factor):
FILE: polars_ta/wq/_slow.py
function _arg_max (line 9) | def _arg_max(x: Series):
function ts_arg_max (line 21) | def ts_arg_max(x: Expr, d: int = 5) -> Expr:
function _arg_min (line 26) | def _arg_min(x: Series):
function ts_arg_min (line 30) | def ts_arg_min(x: Expr, d: int = 5) -> Expr:
function ts_product (line 34) | def ts_product(x: Expr, d: int = 5) -> Expr:
FILE: polars_ta/wq/arithmetic.py
function abs_ (line 9) | def abs_(x: Expr) -> Expr:
function add (line 42) | def add(a: Expr, b: Expr, *args) -> Expr:
function arc_cos (line 82) | def arc_cos(x: Expr) -> Expr:
function arc_sin (line 89) | def arc_sin(x: Expr) -> Expr:
function arc_tan (line 96) | def arc_tan(x: Expr) -> Expr:
function arc_tan2 (line 103) | def arc_tan2(y: Expr, x: Expr) -> Expr:
function cbrt (line 110) | def cbrt(x: Expr) -> Expr:
function ceiling (line 117) | def ceiling(x: Expr) -> Expr:
function cos (line 124) | def cos(x: Expr) -> Expr:
function cosh (line 131) | def cosh(x: Expr) -> Expr:
function cot (line 138) | def cot(x: Expr) -> Expr:
function cube (line 145) | def cube(x: Expr) -> Expr:
function degrees (line 152) | def degrees(x: Expr) -> Expr:
function _densify (line 159) | def _densify(x: Expr) -> Expr:
function div (line 163) | def div(x: Expr, y: Expr) -> Expr:
function divide (line 195) | def divide(x: Expr, y: Expr) -> Expr:
function exp (line 229) | def exp(x: Expr) -> Expr:
function expm1 (line 260) | def expm1(x: Expr) -> Expr:
function floor (line 293) | def floor(x: Expr) -> Expr:
function fraction (line 300) | def fraction(x: Expr) -> Expr:
function inverse (line 344) | def inverse(x: Expr) -> Expr:
function log (line 375) | def log(x: Expr) -> Expr:
function log10 (line 406) | def log10(x: Expr) -> Expr:
function log1p (line 437) | def log1p(x: Expr) -> Expr:
function log2 (line 472) | def log2(x: Expr) -> Expr:
function max_ (line 503) | def max_(a: Expr, b: Expr, *args) -> Expr:
function mean (line 510) | def mean(a: Expr, b: Expr, *args) -> Expr:
function min_ (line 541) | def min_(a: Expr, b: Expr, *args) -> Expr:
function mod (line 548) | def mod(x: Expr, y: Expr) -> Expr:
function multiply (line 581) | def multiply(a: Expr, b: Expr, *args) -> Expr:
function power (line 624) | def power(x: Expr, y: Expr) -> Expr:
function radians (line 667) | def radians(x: Expr) -> Expr:
function reverse (line 674) | def reverse(x: Expr) -> Expr:
function round_ (line 679) | def round_(x: Expr, decimals: int = 0) -> Expr:
function round_down (line 723) | def round_down(x: Expr, f: int = 1) -> Expr:
function s_log_1p (line 763) | def s_log_1p(x: Expr) -> Expr:
function sign (line 805) | def sign(x: Expr) -> Expr:
function signed_power (line 812) | def signed_power(x: Expr, y: Expr) -> Expr:
function sin (line 863) | def sin(x: Expr) -> Expr:
function sinh (line 870) | def sinh(x: Expr) -> Expr:
function softsign (line 877) | def softsign(x: Expr) -> Expr:
function sqrt (line 909) | def sqrt(x: Expr) -> Expr:
function square (line 916) | def square(x: Expr) -> Expr:
function subtract (line 923) | def subtract(x: Expr, y: Expr) -> Expr:
function tan (line 930) | def tan(x: Expr) -> Expr:
function tanh (line 962) | def tanh(x: Expr) -> Expr:
function var (line 994) | def var(a: Expr, b: Expr, *args) -> Expr:
function std (line 1028) | def std(a: Expr, b: Expr, *args) -> Expr:
FILE: polars_ta/wq/cross_sectional.py
function cs_one_side (line 19) | def cs_one_side(x: Expr, is_long: bool = True) -> Expr:
function cs_scale (line 58) | def cs_scale(x: Expr, scale_: float = 1, long_scale: float = 1, short_sc...
function cs_scale_down (line 103) | def cs_scale_down(x: Expr, constant: int = 0) -> Expr:
function cs_truncate (line 140) | def cs_truncate(x: Expr, max_percent: float = 0.01) -> Expr:
function cs_fill_except_all_null (line 174) | def cs_fill_except_all_null(x: Expr, value: float = 0) -> Expr:
function cs_fill_mean (line 211) | def cs_fill_mean(x: Expr) -> Expr:
function cs_fill_max (line 216) | def cs_fill_max(x: Expr) -> Expr:
function cs_fill_min (line 221) | def cs_fill_min(x: Expr) -> Expr:
function cs_fill_null (line 226) | def cs_fill_null(x: Expr, value: float = 0) -> Expr:
function cs_regression_neut (line 231) | def cs_regression_neut(y: Expr, x: Expr) -> Expr:
function cs_regression_proj (line 236) | def cs_regression_proj(y: Expr, x: Expr) -> Expr:
function cs_rank (line 241) | def cs_rank(x: Expr, pct: bool = True) -> Expr:
function cs_rank_if (line 292) | def cs_rank_if(condition: Expr, x: Expr, pct: bool = True) -> Expr:
function _cs_qcut_rank (line 341) | def _cs_qcut_rank(x: Expr, q: int = 10) -> Expr:
function cs_qcut (line 386) | def cs_qcut(x: Expr, q: int = 10) -> Expr:
function cs_top_bottom (line 436) | def cs_top_bottom(x: Expr, k: int = 10) -> Expr:
FILE: polars_ta/wq/half_life.py
function ts_mean_hl (line 7) | def ts_mean_hl(x: Expr, d: int, half_life: int):
function ts_sum_hl (line 12) | def ts_sum_hl(x: Expr, d: int, half_life: int):
function ts_std_hl (line 17) | def ts_std_hl(x: Expr, d: int, half_life: int):
function ts_var_hl (line 22) | def ts_var_hl(x: Expr, d: int, half_life: int):
FILE: polars_ta/wq/logical.py
function and_ (line 5) | def and_(a: Expr, *args) -> Expr:
function equal (line 12) | def equal(input1: Expr, input2: Expr) -> Expr:
function if_else (line 17) | def if_else(condition: Expr, true_value: Expr, false_value: Expr = None)...
function is_finite (line 29) | def is_finite(input1: Expr) -> Expr:
function is_nan (line 34) | def is_nan(input1: Expr) -> Expr:
function is_null (line 39) | def is_null(input1: Expr) -> Expr:
function is_not_finite (line 44) | def is_not_finite(input1: Expr) -> Expr:
function is_not_nan (line 49) | def is_not_nan(input1: Expr) -> Expr:
function is_not_null (line 54) | def is_not_null(input1: Expr) -> Expr:
function less (line 59) | def less(input1: Expr, input2: Expr) -> Expr:
function negate (line 64) | def negate(input1: Expr) -> Expr:
function not_ (line 69) | def not_(input1: Expr) -> Expr:
function or_ (line 74) | def or_(a: Expr, *args) -> Expr:
function xor (line 81) | def xor(a: Expr, b: Expr) -> Expr:
FILE: polars_ta/wq/preprocess.py
function cs_zscore (line 20) | def cs_zscore(x: Expr, ddof: int = 0) -> Expr:
function cs_minmax (line 25) | def cs_minmax(x: Expr) -> Expr:
function cs_robust_scale (line 34) | def cs_robust_scale(x: Expr) -> Expr:
function cs_quantile (line 41) | def cs_quantile(x: Expr, low_limit: float = 0.025, up_limit: float = 0.9...
function cs_3sigma (line 48) | def cs_3sigma(x: Expr, n: float = 3.) -> Expr:
function cs_mad (line 57) | def cs_mad(x: Expr, n: float = 3., k: float = 1.4826) -> Expr:
function cs_demean (line 72) | def cs_demean(x: Expr) -> Expr:
function cs_resid (line 94) | def cs_resid(y: Expr, *more_x: Expr) -> Expr:
function cs_zscore_resid (line 99) | def cs_zscore_resid(y: Expr, *more_x: Expr) -> Expr:
function cs_resid_zscore (line 104) | def cs_resid_zscore(y: Expr, *more_x: Expr) -> Expr:
function cs_mad_zscore (line 109) | def cs_mad_zscore(y: Expr) -> Expr:
function cs_mad_zscore_resid (line 114) | def cs_mad_zscore_resid(y: Expr, *more_x: Expr) -> Expr:
function cs_mad_zscore_resid_zscore (line 119) | def cs_mad_zscore_resid_zscore(y: Expr, *more_x: Expr) -> Expr:
function cs_quantile_zscore (line 124) | def cs_quantile_zscore(y: Expr, low_limit: float = 0.025, up_limit: floa...
function cs_resid_w (line 130) | def cs_resid_w(w: Expr, y: Expr, *more_x: Expr) -> Expr:
FILE: polars_ta/wq/time_series.py
function ts_arg_max (line 17) | def ts_arg_max(x: Expr, d: int = 5, reverse: bool = True, min_samples: O...
function ts_arg_min (line 73) | def ts_arg_min(x: Expr, d: int = 5, reverse: bool = True, min_samples: O...
function ts_co_kurtosis (line 125) | def ts_co_kurtosis(x: Expr, y: Expr, d: int = 5, ddof: int = 0, min_samp...
function ts_co_skewness (line 131) | def ts_co_skewness(x: Expr, y: Expr, d: int = 5, ddof: int = 0, min_samp...
function ts_corr (line 137) | def ts_corr(x: Expr, y: Expr, d: int = 5, ddof: int = 1, min_samples: Op...
function ts_count (line 160) | def ts_count(x: Expr, d: int = 30, min_samples: Optional[int] = None) ->...
function ts_count_eq (line 200) | def ts_count_eq(x: Expr, d: int = 30, n: int = 10, min_samples: Optional...
function ts_count_ge (line 217) | def ts_count_ge(x: Expr, d: int = 30, n: int = 10, min_samples: Optional...
function ts_count_nans (line 234) | def ts_count_nans(x: Expr, d: int = 5, min_samples: Optional[int] = None...
function ts_count_nulls (line 273) | def ts_count_nulls(x: Expr, d: int = 5, min_samples: Optional[int] = Non...
function ts_covariance (line 312) | def ts_covariance(x: Expr, y: Expr, d: int = 5, ddof: int = 1, min_sampl...
function ts_cum_count (line 335) | def ts_cum_count(x: Expr) -> Expr:
function ts_cum_max (line 367) | def ts_cum_max(x: Expr) -> Expr:
function ts_cum_min (line 399) | def ts_cum_min(x: Expr) -> Expr:
function ts_cum_prod (line 430) | def ts_cum_prod(x: Expr) -> Expr:
function ts_cum_sum (line 435) | def ts_cum_sum(x: Expr) -> Expr:
function ts_cum_sum_reset (line 440) | def ts_cum_sum_reset(x: Expr) -> Expr:
function ts_decay_exp_window (line 475) | def ts_decay_exp_window(x: Expr, d: int = 30, factor: float = 1.0, min_s...
function ts_decay_linear (line 524) | def ts_decay_linear(x: Expr, d: int = 30, min_samples: Optional[int] = N...
function ts_delay (line 568) | def ts_delay(x: Expr, d: int = 1, fill_value: float = None) -> Expr:
function ts_delta (line 585) | def ts_delta(x: Expr, d: int = 1) -> Expr:
function ts_fill_null (line 590) | def ts_fill_null(x: Expr, limit: int = None) -> Expr:
function ts_ir (line 628) | def ts_ir(x: Expr, d: int = 1, min_samples: Optional[int] = None) -> Expr:
function ts_kurtosis (line 635) | def ts_kurtosis(x: Expr, d: int = 5, bias: bool = False, min_samples: Op...
function ts_l2_norm (line 682) | def ts_l2_norm(x: Expr, d: int = 5, min_samples: Optional[int] = None) -...
function ts_log_diff (line 691) | def ts_log_diff(x: Expr, d: int = 1) -> Expr:
function ts_max (line 699) | def ts_max(x: Expr, d: int = 30, min_samples: Optional[int] = None) -> E...
function ts_max_diff (line 705) | def ts_max_diff(x: Expr, d: int = 30, min_samples: Optional[int] = None)...
function ts_mean (line 712) | def ts_mean(x: Expr, d: int = 5, min_samples: Optional[int] = None) -> E...
function ts_median (line 718) | def ts_median(x: Expr, d: int = 5, min_samples: Optional[int] = None) ->...
function ts_min (line 724) | def ts_min(x: Expr, d: int = 30, min_samples: Optional[int] = None) -> E...
function ts_min_diff (line 730) | def ts_min_diff(x: Expr, d: int = 30, min_samples: Optional[int] = None)...
function ts_min_max_cps (line 737) | def ts_min_max_cps(x: Expr, d: int, f: float = 2.0, min_samples: Optiona...
function ts_min_max_diff (line 744) | def ts_min_max_diff(x: Expr, d: int, f: float = 0.5, min_samples: Option...
function ts_moment (line 751) | def ts_moment(x: Expr, d: int, k: int = 0, min_samples: Optional[int] = ...
function ts_partial_corr (line 768) | def ts_partial_corr(x: Expr, y: Expr, z: Expr, d: int, min_samples: Opti...
function ts_percentage (line 778) | def ts_percentage(x: Expr, d: int, percentage: float = 0.5, min_samples:...
function ts_product (line 795) | def ts_product(x: Expr, d: int = 5, min_samples: Optional[int] = None) -...
function ts_rank (line 801) | def ts_rank(x: Expr, d: int = 5, min_samples: Optional[int] = None) -> E...
function ts_realized_volatility (line 807) | def ts_realized_volatility(close: Expr, d: int = 5, min_samples: Optiona...
function ts_returns (line 813) | def ts_returns(x: Expr, d: int = 1) -> Expr:
function ts_scale (line 818) | def ts_scale(x: Expr, d: int = 5, min_samples: Optional[int] = None) -> ...
function ts_shifts_v1 (line 830) | def ts_shifts_v1(*args) -> Expr:
function ts_shifts_v2 (line 871) | def ts_shifts_v2(*args) -> Expr:
function ts_shifts_v3 (line 914) | def ts_shifts_v3(*args) -> Expr:
function ts_skewness (line 964) | def ts_skewness(x: Expr, d: int = 5, bias: bool = False, min_samples: Op...
function ts_std_dev (line 986) | def ts_std_dev(x: Expr, d: int = 5, ddof: int = 0, min_samples: Optional...
function ts_sum (line 1002) | def ts_sum(x: Expr, d: int = 30, min_samples: Optional[int] = None) -> E...
function ts_sum_split_by (line 1008) | def ts_sum_split_by(x: Expr, by: Expr, d: int = 30, k: int = 10) -> Expr:
function ts_triple_corr (line 1061) | def ts_triple_corr(x: Expr, y: Expr, z: Expr, d: int, min_samples: Optio...
function ts_weighted_decay (line 1071) | def ts_weighted_decay(x: Expr, k: float = 0.5, min_samples: Optional[int...
function ts_zscore (line 1089) | def ts_zscore(x: Expr, d: int = 5, min_samples: Optional[int] = None) ->...
function ts_cum_prod_by (line 1094) | def ts_cum_prod_by(r: Expr, v: Expr) -> Expr:
function ts_cum_sum_by (line 1148) | def ts_cum_sum_by(r: Expr, v: Expr) -> Expr:
function ts_regression_resid (line 1197) | def ts_regression_resid(y: Expr, x: Expr, d: int, min_samples: Optional[...
function ts_regression_pred (line 1203) | def ts_regression_pred(y: Expr, x: Expr, d: int, min_samples: Optional[i...
function ts_regression_intercept (line 1210) | def ts_regression_intercept(y: Expr, x: Expr, d: int, min_samples: Optio...
function ts_regression_slope (line 1217) | def ts_regression_slope(y: Expr, x: Expr, d: int, min_samples: Optional[...
function ts_resid (line 1223) | def ts_resid(y: Expr, *more_x: Expr, d: int = 30, min_samples: Optional[...
function ts_pred (line 1239) | def ts_pred(y: Expr, *more_x: Expr, d: int = 30, min_samples: Optional[i...
function ts_weighted_mean (line 1255) | def ts_weighted_mean(x: Expr, w: Expr, d: int, min_samples: Optional[int...
function ts_weighted_sum (line 1261) | def ts_weighted_sum(x: Expr, w: Expr, d: int, min_samples: Optional[int]...
function ts_signals_to_size (line 1267) | def ts_signals_to_size(long_entry: Expr, long_exit: Expr,
FILE: polars_ta/wq/transformational.py
function cut (line 4) | def cut(x: Expr, b: float, *more_bins) -> Expr:
function clamp (line 43) | def clamp(x: Expr, lower: float = 0, upper: float = 0, inverse: bool = F...
function _keep (line 89) | def _keep(x: Expr, f: float, period: int = 5) -> Expr:
function left_tail (line 94) | def left_tail(x: Expr, maximum: float = 0) -> Expr:
function purify (line 139) | def purify(x: Expr) -> Expr:
function fill_nan (line 169) | def fill_nan(x: Expr) -> Expr:
function fill_null (line 174) | def fill_null(x: Expr, value=0) -> Expr:
function right_tail (line 179) | def right_tail(x: Expr, minimum: float = 0) -> Expr:
function sigmoid (line 213) | def sigmoid(x: Expr) -> Expr:
function logit (line 220) | def logit(x: Expr) -> Expr:
function tail (line 227) | def tail(x: Expr, lower: float = 0, upper: float = 0, newval: float = 0)...
function int_ (line 269) | def int_(a: Expr) -> Expr:
function bool_ (line 276) | def bool_(a: Expr) -> Expr:
function float_ (line 283) | def float_(a: Expr) -> Expr:
function nop (line 290) | def nop(x: Expr) -> Expr:
function lit_ (line 295) | def lit_(a: Expr) -> Expr:
FILE: polars_ta/wq/vector.py
function vec_avg (line 10) | def vec_avg(x: Expr) -> Expr:
function vec_choose (line 15) | def vec_choose(x: Expr, nth: int) -> Expr:
function vec_count (line 20) | def vec_count(x: Expr) -> Expr:
function vec_ir (line 25) | def vec_ir(x: Expr) -> Expr:
function vec_kurtosis (line 30) | def vec_kurtosis(x: Expr) -> Expr:
function vec_l2_norm (line 35) | def vec_l2_norm(x: Expr) -> Expr:
function vec_max (line 40) | def vec_max(x: Expr) -> Expr:
function vec_min (line 45) | def vec_min(x: Expr) -> Expr:
function vec_norm (line 50) | def vec_norm(x: Expr) -> Expr:
function vec_percentage (line 55) | def vec_percentage(x: Expr, percentage: float = 0.5) -> Expr:
function vec_powersum (line 60) | def vec_powersum(x: Expr, constant: float = 2) -> Expr:
function vec_range (line 65) | def vec_range(x: Expr) -> Expr:
function vec_skewness (line 70) | def vec_skewness(x: Expr) -> Expr:
function vec_stddev (line 75) | def vec_stddev(x: Expr) -> Expr:
function vec_sum (line 80) | def vec_sum(x: Expr) -> Expr:
function vec_median (line 84) | def vec_median(x: Expr) -> Expr:
FILE: tests/numba_test.py
function nb_sum (line 12) | def nb_sum(x):
FILE: tests/pit_test.py
function load_parquet (line 14) | def load_parquet(folder):
function balance (line 22) | def balance(df1):
function income (line 36) | def income(df1):
function cashflow (line 50) | def cashflow(df1):
FILE: tests/ta/test_momentum.py
class TestDemoClass (line 6) | class TestDemoClass:
method setup_class (line 12) | def setup_class(self):
method test_WILLR (line 20) | def test_WILLR(self):
method test_STOCHF_fastd (line 35) | def test_STOCHF_fastd(self):
method test_MACD (line 48) | def test_MACD(self):
method test_TRIX (line 65) | def test_TRIX(self):
method test_AROON (line 79) | def test_AROON(self):
method test_RSI (line 93) | def test_RSI(self):
FILE: tests/ta/test_operators.py
class TestDemoClass (line 6) | class TestDemoClass:
method setup_class (line 12) | def setup_class(self):
method test_MAX (line 20) | def test_MAX(self):
method test_MIN (line 29) | def test_MIN(self):
method test_MAXINDEX (line 38) | def test_MAXINDEX(self):
FILE: tests/ta/test_overlap.py
class TestDemoClass (line 6) | class TestDemoClass:
method setup_class (line 12) | def setup_class(self):
method test_SMA (line 20) | def test_SMA(self):
method test_WMA (line 29) | def test_WMA(self):
method test_EMA (line 38) | def test_EMA(self):
method test_DEMA (line 50) | def test_DEMA(self):
method test_TEMA (line 61) | def test_TEMA(self):
method test_TRIMA (line 75) | def test_TRIMA(self):
method test_BBANDS (line 102) | def test_BBANDS(self):
method test_MIDPOINT (line 111) | def test_MIDPOINT(self):
method test_MIDPRICE (line 120) | def test_MIDPRICE(self):
FILE: tests/ta/test_statistic.py
class TestDemoClass (line 6) | class TestDemoClass:
method setup_class (line 12) | def setup_class(self):
method test_STDDEV (line 21) | def test_STDDEV(self):
method test_VAR (line 30) | def test_VAR(self):
method test_CORREL (line 39) | def test_CORREL(self):
FILE: tests/ta/test_volatility.py
class TestDemoClass (line 6) | class TestDemoClass:
method setup_class (line 12) | def setup_class(self):
method test_TRANGE (line 20) | def test_TRANGE(self):
method test_ATR (line 34) | def test_ATR(self):
FILE: tests/ta/test_volume.py
class TestDemoClass (line 6) | class TestDemoClass:
method setup_class (line 12) | def setup_class(self):
method test_AD (line 21) | def test_AD(self):
method test_ADOSC (line 33) | def test_ADOSC(self):
method test_OBV (line 45) | def test_OBV(self):
FILE: tests/tdx/test_reference.py
class TestDemoClass (line 6) | class TestDemoClass:
method setup_class (line 12) | def setup_class(self):
method test_EXPMEMA (line 20) | def test_EXPMEMA(self):
method test_BARSLAST (line 29) | def test_BARSLAST(self):
method test_BARSLASTCOUNT (line 37) | def test_BARSLASTCOUNT(self):
method test_BARSSINCEN (line 45) | def test_BARSSINCEN(self):
method test_LOD (line 53) | def test_LOD(self):
method test_FILTER (line 62) | def test_FILTER(self):
FILE: tests/tdx/test_statistic.py
class TestDemoClass (line 7) | class TestDemoClass:
method setup_class (line 13) | def setup_class(self):
method test_AVEDEV (line 22) | def test_AVEDEV(self):
FILE: tests/wq/test_arithmetic.py
class TestDemoClass (line 7) | class TestDemoClass:
method setup_class (line 13) | def setup_class(self):
method test_add (line 22) | def test_add(self):
method test_fraction (line 29) | def test_fraction(self):
FILE: tests/wq/test_time_series.py
class TestDemoClass (line 8) | class TestDemoClass:
method setup_class (line 14) | def setup_class(self):
method test_ts_rank (line 25) | def test_ts_rank(self):
method test_ts_skewness (line 34) | def test_ts_skewness(self):
method test_ts_kurtosis (line 46) | def test_ts_kurtosis(self):
method test_ts_corr (line 55) | def test_ts_corr(self):
method test_ts_covariance (line 63) | def test_ts_covariance(self):
method test_ts_decay_exp_window (line 71) | def test_ts_decay_exp_window(self):
method test_ts_decay_linear (line 78) | def test_ts_decay_linear(self):
method test_ts_weighted_delay (line 85) | def test_ts_weighted_delay(self):
method test_ts_arg_max (line 93) | def test_ts_arg_max(self):
method test_ts_product (line 119) | def test_ts_product(self):
FILE: tools/codegen_talib.py
function _codegen_func (line 19) | def _codegen_func(name, input_names, parameters, output_names, doc):
function codegen (line 80) | def codegen():
FILE: tools/prefix.py
function codegen_import_as (line 5) | def codegen_import_as(module: str, prefix: str = 'ts_',
function save (line 74) | def save(txts, module, write=False):
FILE: tools/prefix_talib.py
function codegen (line 11) | def codegen():
FILE: tools/prefix_vec.py
function codegen_import_as (line 14) | def codegen_import_as(module: str, prefix: str = 'cs_',
FILE: tools/prompt.py
function get_annotation (line 5) | def get_annotation(annotation):
function get_parameter (line 12) | def get_parameter(p):
function codegen_import_as (line 28) | def codegen_import_as(module: str,
Condensed preview — 150 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (470K chars).
[
{
"path": ".github/workflows/python-publish.yml",
"chars": 1084,
"preview": "# This workflow will upload a Python Package using Twine when a release is created\n# For more information see: https://d"
},
{
"path": ".gitignore",
"chars": 3078,
"preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
},
{
"path": ".readthedocs.yaml",
"chars": 437,
"preview": "# Read the Docs configuration file for MkDocs projects\n# See https://docs.readthedocs.io/en/stable/config-file/v2.html f"
},
{
"path": "LICENSE",
"chars": 1062,
"preview": "MIT License\n\nCopyright (c) 2023 wukan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof t"
},
{
"path": "README.md",
"chars": 6005,
"preview": "# polars_ta\n\nTechnical Indicator Operators Rewritten in `polars`.\n\nWe provide wrappers for some functions (like `TA-Lib`"
},
{
"path": "compare.md",
"chars": 3158,
"preview": "# Differences in Indicators\n\n## 1. EMA alike indicators\n\n### 1.1 EMA\n\n1. EMA(CLOSE, 10), `talib.set_compatibility(0)` is"
},
{
"path": "deprecated/demo_ta1.py",
"chars": 1259,
"preview": "\"\"\"\nThisis how polars implements calling third-party packages\n以下是polars提供的实现调用第三方库的方案\nexpr.ta.func\n\n\"\"\"\nimport polars as"
},
{
"path": "deprecated/demo_ta2.py",
"chars": 1523,
"preview": "\"\"\"\nThis is how we wrap upon polars's code\n以下是polars提供的方案基础上封装的方案\nfunc(expr)\n\n\"\"\"\nimport polars as pl\n\nfrom polars_ta.ut"
},
{
"path": "deprecated/helper.py",
"chars": 5874,
"preview": "\"\"\"\nWe follow the spirit of\n\nhttps://github.com/pola-rs/polars/issues/9261\n\nand adjusted it to fit our needs. The usage "
},
{
"path": "deprecated/pandas_.py",
"chars": 1941,
"preview": "from functools import lru_cache\nfrom typing import Tuple\n\nimport numpy as np\nfrom numba import jit\nfrom pandas._libs.win"
},
{
"path": "deprecated/wrapper.py",
"chars": 3180,
"preview": "\"\"\"\nAnother wrapper for raised github issue\n\nbefore:\nexpr.ta.func(..., skip_nan=False, output_idx=None, schema=None, sch"
},
{
"path": "docs/index.md",
"chars": 380,
"preview": "# polars_ta\n\n尽量接近`WorldQuant Alpha101`风格函数,但部分又做了一定的调整\n\n例如:\n\n1. x.abs().log()\n - 可利用`IDE`的自动补全,输入方便\n - 默认是一个输入,多输入"
},
{
"path": "docs/ta/index.md",
"chars": 24,
"preview": "用`polars`函数模仿`TA-Lib`的函数"
},
{
"path": "docs/ta/momentum.md",
"chars": 25,
"preview": "::: polars_ta.ta.momentum"
},
{
"path": "docs/ta/operators.md",
"chars": 26,
"preview": "::: polars_ta.ta.operators"
},
{
"path": "docs/ta/overlap.md",
"chars": 24,
"preview": "::: polars_ta.ta.overlap"
},
{
"path": "docs/ta/price.md",
"chars": 22,
"preview": "::: polars_ta.ta.price"
},
{
"path": "docs/ta/statistic.md",
"chars": 26,
"preview": "::: polars_ta.ta.statistic"
},
{
"path": "docs/ta/transform.md",
"chars": 26,
"preview": "::: polars_ta.ta.transform"
},
{
"path": "docs/ta/volatility.md",
"chars": 27,
"preview": "::: polars_ta.ta.volatility"
},
{
"path": "docs/ta/volume.md",
"chars": 23,
"preview": "::: polars_ta.ta.volume"
},
{
"path": "docs/talib/index.md",
"chars": 83,
"preview": "直接调用`TA-Lib`, 多输出时返回`struct`, 可以使用`.struct[0]`取到对应字段的`Series`.\n\n::: polars_ta.talib"
},
{
"path": "docs/tdx/arithmetic.md",
"chars": 28,
"preview": "::: polars_ta.tdx.arithmetic"
},
{
"path": "docs/tdx/choice.md",
"chars": 24,
"preview": "::: polars_ta.tdx.choice"
},
{
"path": "docs/tdx/energy.md",
"chars": 24,
"preview": "::: polars_ta.tdx.energy"
},
{
"path": "docs/tdx/logical.md",
"chars": 25,
"preview": "::: polars_ta.tdx.logical"
},
{
"path": "docs/tdx/moving_average.md",
"chars": 32,
"preview": "::: polars_ta.tdx.moving_average"
},
{
"path": "docs/tdx/over_bought_over_sold.md",
"chars": 39,
"preview": "::: polars_ta.tdx.over_bought_over_sold"
},
{
"path": "docs/tdx/pattern.md",
"chars": 25,
"preview": "::: polars_ta.tdx.pattern"
},
{
"path": "docs/tdx/pattern_feature.md",
"chars": 33,
"preview": "::: polars_ta.tdx.pattern_feature"
},
{
"path": "docs/tdx/pressure_support.md",
"chars": 34,
"preview": "::: polars_ta.tdx.pressure_support"
},
{
"path": "docs/tdx/reference.md",
"chars": 27,
"preview": "::: polars_ta.tdx.reference"
},
{
"path": "docs/tdx/statistic.md",
"chars": 27,
"preview": "::: polars_ta.tdx.statistic"
},
{
"path": "docs/tdx/times.md",
"chars": 23,
"preview": "::: polars_ta.tdx.times"
},
{
"path": "docs/tdx/trend.md",
"chars": 23,
"preview": "::: polars_ta.tdx.trend"
},
{
"path": "docs/tdx/trend_feature.md",
"chars": 31,
"preview": "::: polars_ta.tdx.trend_feature"
},
{
"path": "docs/tdx/volume.md",
"chars": 24,
"preview": "::: polars_ta.tdx.volume"
},
{
"path": "docs/wq/arithmetic.md",
"chars": 27,
"preview": "::: polars_ta.wq.arithmetic"
},
{
"path": "docs/wq/cross_sectional.md",
"chars": 32,
"preview": "::: polars_ta.wq.cross_sectional"
},
{
"path": "docs/wq/half_life.md",
"chars": 26,
"preview": "::: polars_ta.wq.half_life"
},
{
"path": "docs/wq/logical.md",
"chars": 24,
"preview": "::: polars_ta.wq.logical"
},
{
"path": "docs/wq/preprocess.md",
"chars": 27,
"preview": "::: polars_ta.wq.preprocess"
},
{
"path": "docs/wq/time_series.md",
"chars": 28,
"preview": "::: polars_ta.wq.time_series"
},
{
"path": "docs/wq/transformational.md",
"chars": 33,
"preview": "::: polars_ta.wq.transformational"
},
{
"path": "docs/wq/vector.md",
"chars": 23,
"preview": "::: polars_ta.wq.vector"
},
{
"path": "examples/alpha101.py",
"chars": 3491,
"preview": "from datetime import datetime\n\nimport pandas as pd\nimport polars as pl\n\nfrom polars_ta.prefix.tdx import *\nfrom polars_t"
},
{
"path": "examples/demo_ta3.py",
"chars": 668,
"preview": "\"\"\"\nThis is how we wrap upon polars's code\n以下是polars提供的方案基础上封装的方案\nfunc(expr)\n\n\"\"\"\nimport polars as pl\n\nfrom polars_ta.ta"
},
{
"path": "mkdocs.yml",
"chars": 1759,
"preview": "site_name: polars_ta API References\nsite_url: https://polars-ta.readthedocs.io/en/latest/\n\nnav:\n - Home: index.md\n - p"
},
{
"path": "nan_to_null.md",
"chars": 2504,
"preview": "# nan_to_null\n\nIt is important to handle nan and null values correctly. In many cases, null values may occur. Such as:\n\n"
},
{
"path": "point_in_time.md",
"chars": 3024,
"preview": "# Point In Time\n\nEssentially it is due to the fix of historical erroneous data. Sometimes we even need to fix the histor"
},
{
"path": "polars_ta/__init__.py",
"chars": 144,
"preview": "from typing import Optional\n\nfrom ._version import __version__\n\n# 默认最小误差值\nTA_EPSILON: float = 1e-8\n# 默认最小样本数量\nMIN_SAMPLE"
},
{
"path": "polars_ta/_version.py",
"chars": 23,
"preview": "__version__ = \"0.5.17\"\n"
},
{
"path": "polars_ta/candles/__init__.py",
"chars": 141,
"preview": "from polars_ta.candles.cdl1 import * # noqa\nfrom polars_ta.candles.cdl1_limit import * # noqa\nfrom polars_ta.candles.c"
},
{
"path": "polars_ta/candles/cdl1.py",
"chars": 2890,
"preview": "\"\"\"\nIn this file we use\nopen_: Expr, high: Expr, low: Expr, close: Expr\nfor all parameters\nto ensure the similar functio"
},
{
"path": "polars_ta/candles/cdl1_limit.py",
"chars": 3734,
"preview": "\"\"\"\nIn this file we use\nopen_: Expr, high: Expr, low: Expr, close: Expr, high_limit: Expr\nopen_: Expr, high: Expr, low: "
},
{
"path": "polars_ta/candles/cdl2.py",
"chars": 1026,
"preview": "\"\"\"\nIn this file we use\nopen_: Expr, high: Expr, low: Expr, close: Expr\nfor all parameters\nto ensure the similar functio"
},
{
"path": "polars_ta/labels/__init__.py",
"chars": 46,
"preview": "from polars_ta.labels.future import * # noqa\n"
},
{
"path": "polars_ta/labels/_nb.py",
"chars": 1399,
"preview": "import numpy as np\nfrom numba import jit\nfrom numpy import full\n\n\n@jit(nopython=True, nogil=True, cache=True)\ndef _tripl"
},
{
"path": "polars_ta/labels/future.py",
"chars": 4060,
"preview": "\"\"\"\n\n由于标签的定义比较灵活,所以以下代码主要用于参考\n\nNotes\n-----\n标签都是未来数据,在机器学习中,只能用于`y`,不能用于`X`。\n\nReferences\n----------\nhttps://mp.weixin.qq."
},
{
"path": "polars_ta/noise.py",
"chars": 1239,
"preview": "\"\"\"\nThe following comes from Trading Systems and Methods, Chapter 1, Measuring Noise\n\nWe do not provide ATR and STD here"
},
{
"path": "polars_ta/performance/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "polars_ta/performance/drawdown.py",
"chars": 222,
"preview": "from polars import Expr\n\n\ndef ts_max_drawdown(close: Expr) -> Expr:\n \"\"\"最大回撤\"\"\"\n return close - close.cum_max()\n\n\n"
},
{
"path": "polars_ta/performance/returns.py",
"chars": 388,
"preview": "from polars import Expr\n\nfrom polars_ta.wq.arithmetic import log1p, expm1\n\n\ndef ts_cum_return(close: Expr) -> Expr:\n "
},
{
"path": "polars_ta/prefix/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "polars_ta/prefix/cdl.py",
"chars": 40,
"preview": "from polars_ta.candles import * # noqa\n"
},
{
"path": "polars_ta/prefix/labels.py",
"chars": 39,
"preview": "from polars_ta.labels import * # noqa\n"
},
{
"path": "polars_ta/prefix/reports.py",
"chars": 40,
"preview": "from polars_ta.reports import * # noqa\n"
},
{
"path": "polars_ta/prefix/ta.py",
"chars": 3860,
"preview": "# this code is auto generated by tools/prefix_ta.py\n\nfrom polars_ta.ta.momentum import APO as ts_APO # noqa\nfrom polars"
},
{
"path": "polars_ta/prefix/talib.py",
"chars": 9392,
"preview": "# this code is auto generated by tools/prefix_talib.py\n \nfrom polars_ta.talib import HT_DCPERIOD as ts_HT_DCPERIOD #"
},
{
"path": "polars_ta/prefix/tdx.py",
"chars": 10393,
"preview": "# this code is auto generated by tools/prefix_tdx.py\n\nfrom polars_ta.tdx.arithmetic import ABS # noqa\nfrom polars_ta.td"
},
{
"path": "polars_ta/prefix/vec.py",
"chars": 1123,
"preview": "# this code is auto generated by tools/prefix_vec.py\n\nfrom polars_ta.wq.vector import vec_avg as cs_vec_avg # noqa\nfrom"
},
{
"path": "polars_ta/prefix/wq.py",
"chars": 35,
"preview": "from polars_ta.wq import * # noqa\n"
},
{
"path": "polars_ta/reports/__init__.py",
"chars": 45,
"preview": "from polars_ta.reports.cicc import * # noqa\n"
},
{
"path": "polars_ta/reports/cicc.py",
"chars": 597,
"preview": "from polars import Expr\n\nfrom polars_ta.wq import ts_corr, ts_zscore, ts_std_dev, ts_regression_slope\n\n\ndef ts_RSRS_R2(h"
},
{
"path": "polars_ta/ta/README.md",
"chars": 515,
"preview": "# polars_ta.ta\n\n1. Files in this folder mimic `talib`, and implement `polars` versions for the same functions\n2. Since w"
},
{
"path": "polars_ta/ta/__init__.py",
"chars": 351,
"preview": "from polars_ta.ta.momentum import * # noqa\nfrom polars_ta.ta.operators import * # noqa\nfrom polars_ta.ta.overlap impor"
},
{
"path": "polars_ta/ta/momentum.py",
"chars": 5164,
"preview": "from polars import Expr, when, struct\n\nfrom polars_ta import TA_EPSILON\nfrom polars_ta.ta.operators import MAX\nfrom pola"
},
{
"path": "polars_ta/ta/operators.py",
"chars": 3113,
"preview": "\"\"\"\n通过`import`直接导入或更名的函数\n\n```python\nfrom polars_ta.wq.arithmetic import add as ADD # noqa\nfrom polars_ta.wq.arithmetic "
},
{
"path": "polars_ta/ta/overlap.py",
"chars": 2778,
"preview": "from math import ceil, floor\n\nfrom polars import Expr, struct\n\nfrom polars_ta.ta.operators import MAX\nfrom polars_ta.ta."
},
{
"path": "polars_ta/ta/price.py",
"chars": 1013,
"preview": "from polars import Expr\n\n\ndef AVGPRICE(open: Expr, high: Expr, low: Expr, close: Expr) -> Expr:\n \"\"\"(open + high + lo"
},
{
"path": "polars_ta/ta/statistic.py",
"chars": 944,
"preview": "\"\"\"\n通过`import`直接导入或更名的函数\n\n```python\nfrom polars_ta.wq.time_series import ts_corr as CORREL # noqa\n```\n\n\"\"\"\n\nfrom polars"
},
{
"path": "polars_ta/ta/transform.py",
"chars": 1765,
"preview": "\"\"\"\n通过`import`直接导入或更名的函数\n\n```python\nfrom polars_ta.wq.arithmetic import arc_cos as ACOS # noqa\nfrom polars_ta.wq.arithm"
},
{
"path": "polars_ta/ta/volatility.py",
"chars": 804,
"preview": "from polars import Expr, max_horizontal\n\nfrom polars_ta.ta.overlap import RMA\n\n\ndef TRANGE(high: Expr, low: Expr, close:"
},
{
"path": "polars_ta/ta/volume.py",
"chars": 715,
"preview": "from polars import Expr, when\n\nfrom polars_ta.ta.overlap import EMA\n\n\ndef AD(high: Expr, low: Expr, close: Expr, volume:"
},
{
"path": "polars_ta/talib/README.md",
"chars": 421,
"preview": "# polars_ta.talib\n\nInside this package, files are generated by `tools.codegen_talib2`.\nIt is a wrapper of `talib` functi"
},
{
"path": "polars_ta/talib/__init__.py",
"chars": 79318,
"preview": "# generated by codegen_talib.py\nimport talib as _ta\nfrom polars import Expr, struct, Struct, Field, Float64, Int32\n\nfrom"
},
{
"path": "polars_ta/tdx/README.md",
"chars": 411,
"preview": "# polars_ta.tdx\n\n1. Follows the `tdx` naming convention\n2. Except for some element-wise functions, all functions are tim"
},
{
"path": "polars_ta/tdx/__init__.py",
"chars": 704,
"preview": "from polars_ta.tdx.arithmetic import * # noqa\nfrom polars_ta.tdx.choice import * # noqa\nfrom polars_ta.tdx.energy impo"
},
{
"path": "polars_ta/tdx/_chip.py",
"chars": 3092,
"preview": "import numba\nimport numpy as np\n\n\n@numba.jit(nopython=True, nogil=True, fastmath=True, cache=True)\ndef nb_chip(high, low"
},
{
"path": "polars_ta/tdx/_nb.py",
"chars": 1948,
"preview": "import numpy as np\nfrom numba import jit\nfrom numpy import mean, abs, full, argmax\nfrom numpy.lib.stride_tricks import s"
},
{
"path": "polars_ta/tdx/_slow.py",
"chars": 379,
"preview": "from polars import Series, Expr\n\n\ndef _avedev(x: Series) -> Series:\n # x is Series rather than Expr. Making this func"
},
{
"path": "polars_ta/tdx/arithmetic.py",
"chars": 3355,
"preview": "\"\"\"\n通过`import`直接导入或更名的函数\n\n```python\nfrom polars_ta.wq.arithmetic import abs_ as ABS # noqa\nfrom polars_ta.wq.arithmetic"
},
{
"path": "polars_ta/tdx/choice.py",
"chars": 644,
"preview": "from polars import Boolean\nfrom polars import Expr\nfrom polars import when\n\nfrom polars_ta.wq.logical import if_else\n\n\nd"
},
{
"path": "polars_ta/tdx/energy.py",
"chars": 1726,
"preview": "from polars import Expr\n\nfrom polars_ta import TA_EPSILON\nfrom polars_ta.ta.price import MEDPRICE\nfrom polars_ta.tdx.ref"
},
{
"path": "polars_ta/tdx/logical.py",
"chars": 2750,
"preview": "from polars import Expr\n\nfrom polars_ta import TA_EPSILON\nfrom polars_ta.tdx.reference import COUNT\nfrom polars_ta.wq.lo"
},
{
"path": "polars_ta/tdx/moving_average.py",
"chars": 352,
"preview": "from polars import Expr\n\nfrom polars_ta.ta.price import AVGPRICE\nfrom polars_ta.tdx.reference import MA\n\n\ndef BBI(CLOSE:"
},
{
"path": "polars_ta/tdx/over_bought_over_sold.py",
"chars": 2294,
"preview": "from polars import Expr, struct\n\nfrom polars_ta import TA_EPSILON\nfrom polars_ta.ta.momentum import RSI # noqa\nfrom pol"
},
{
"path": "polars_ta/tdx/pattern.py",
"chars": 1243,
"preview": "from polars import Expr, Struct, Field, Float64, struct\n\nfrom polars_ta.tdx._chip import _WINNER_COST\nfrom polars_ta.uti"
},
{
"path": "polars_ta/tdx/pattern_feature.py",
"chars": 7934,
"preview": "from polars import Expr\n\nfrom polars_ta.tdx.arithmetic import ABS, BETWEEN\nfrom polars_ta.tdx.arithmetic import MAX\nfrom"
},
{
"path": "polars_ta/tdx/pressure_support.py",
"chars": 995,
"preview": "from polars import Expr\n\nfrom polars_ta.tdx.arithmetic import SQRT\nfrom polars_ta.tdx.reference import MA\nfrom polars_ta"
},
{
"path": "polars_ta/tdx/reference.py",
"chars": 5639,
"preview": "\"\"\"\n通过`import`直接导入或更名的函数\n\n```python\nfrom polars_ta.ta.overlap import SMA as MA\nfrom polars_ta.ta.volatility import TRANG"
},
{
"path": "polars_ta/tdx/statistic.py",
"chars": 2301,
"preview": "from polars import Expr, Struct, Field, Int64, Float64\n\nfrom polars_ta.tdx._nb import roll_avedev, _up_stat\nfrom polars_"
},
{
"path": "polars_ta/tdx/times.py",
"chars": 2129,
"preview": "from datetime import time, timedelta\n\nfrom polars import Expr, when\n\n\ndef FROMOPEN(t: Expr) -> Expr:\n \"\"\"返回当前时刻距开盘有多少"
},
{
"path": "polars_ta/tdx/trend.py",
"chars": 3008,
"preview": "from polars import Expr\n\nfrom polars_ta import TA_EPSILON\nfrom polars_ta.tdx.arithmetic import ABS\nfrom polars_ta.tdx.ch"
},
{
"path": "polars_ta/tdx/trend_feature.py",
"chars": 7822,
"preview": "from polars import Expr\n\nfrom polars_ta.tdx.arithmetic import ABS\nfrom polars_ta.tdx.logical import EXIST, EVERY\nfrom po"
},
{
"path": "polars_ta/tdx/volume.py",
"chars": 901,
"preview": "from polars import Expr\n\nfrom polars_ta.tdx.choice import IF\nfrom polars_ta.tdx.reference import REF\nfrom polars_ta.tdx."
},
{
"path": "polars_ta/utils/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "polars_ta/utils/factor.py",
"chars": 1728,
"preview": "\"\"\"\n复权算法\n1. 针对现金分红进行复权(使用加减法)\n2. 针对拆股进行复权(使用乘除法)\n\nfactor1: 稀疏的复权因子\nfactor2: 稠密的复权因子,之后主要使用这个\n\n复权因子使用方法\n乘除复权法:factor2*clo"
},
{
"path": "polars_ta/utils/functions.py",
"chars": 916,
"preview": "import inspect\nfrom functools import wraps\nfrom inspect import currentframe\n\nimport polars as pl\n\nimport polars_ta\n\n\ndef"
},
{
"path": "polars_ta/utils/numba_.py",
"chars": 5970,
"preview": "\"\"\"\nDemo for using numba to implement rolling functions.\n本文件是使用numba实现rolling的函数,演示用\n\"\"\"\nfrom functools import lru_cache"
},
{
"path": "polars_ta/utils/pit.py",
"chars": 8557,
"preview": "\"\"\"\n# Point In Time处理相关函数\n\n## 原始表\n资产负债表 时点数据\n 利润表 区间数据\n现金流量表 区间数据\n\n## 单季度数据\n资产负债表 同原始表\n 利润表 本季-上季;一季度\n现金流量"
},
{
"path": "polars_ta/utils/withs.py",
"chars": 971,
"preview": "import re\n\nimport polars as pl\n\n\ndef with_industry(df: pl.DataFrame, industry_name: str, drop_first: bool, keep_col: boo"
},
{
"path": "polars_ta/wq/__init__.py",
"chars": 372,
"preview": "from polars_ta.wq.arithmetic import * # noqa\nfrom polars_ta.wq.cross_sectional import * # noqa\nfrom polars_ta.wq.half_"
},
{
"path": "polars_ta/wq/_nb.py",
"chars": 11800,
"preview": "import numpy as np\nfrom numba import jit, float64, boolean\nfrom numpy import argmax, argmin, full, vstack, corrcoef, nan"
},
{
"path": "polars_ta/wq/_slow.py",
"chars": 781,
"preview": "\"\"\"\nAlgorithm in this file is slow, and has been replaced by numba and other methods\n本目录下算法有些慢,已经用numba等其它方法代替\n\"\"\"\nimpor"
},
{
"path": "polars_ta/wq/arithmetic.py",
"chars": 21903,
"preview": "\"\"\"\n除了使用概率极高的几个函数,其他函数不再对常量做lit\n\"\"\"\nfrom polars import Expr, fold, any_horizontal, Float64, Int64, lit\nfrom polars impor"
},
{
"path": "polars_ta/wq/cross_sectional.py",
"chars": 12810,
"preview": "\"\"\"\n与`WorldQuant Alpha101`的区别是添加了`cs_`前缀\n\n由于截面与时序的使用方式不同,在自动化工具中如果不在名字上做区分就得手工注册,反而要麻烦些\n\n\"\"\"\nimport polars_ols as pls\nfr"
},
{
"path": "polars_ta/wq/half_life.py",
"chars": 823,
"preview": "import numpy as np\nfrom polars import Expr\n\nfrom polars_ta.utils.numba_ import get_exponent_weights\n\n\ndef ts_mean_hl(x: "
},
{
"path": "polars_ta/wq/logical.py",
"chars": 2410,
"preview": "from polars import Expr, all_horizontal, any_horizontal, Boolean\nfrom polars import when\n\n\ndef and_(a: Expr, *args) -> E"
},
{
"path": "polars_ta/wq/preprocess.py",
"chars": 3485,
"preview": "\"\"\"\n1. 补空值 → 去极值 → 标准化 → 中性化 → 标准化(可选二次标准化)\n2. 补空值 → 去极值 → 中性化 → 标准化\n\n# 对数市值。去极值\nMC_LOG = cs_quantile(log1p(market_cap),"
},
{
"path": "polars_ta/wq/time_series.py",
"chars": 34803,
"preview": "import itertools\nfrom typing import Optional\n\nimport more_itertools\nimport numpy as np\nimport polars_ols as pls\nfrom pol"
},
{
"path": "polars_ta/wq/transformational.py",
"chars": 6748,
"preview": "from polars import Expr, when, Boolean, Int32, Float32, lit\n\n\ndef cut(x: Expr, b: float, *more_bins) -> Expr:\n \"\"\"分箱\n"
},
{
"path": "polars_ta/wq/vector.py",
"chars": 1821,
"preview": "\"\"\"\n本文件中算子都是对整列计算得到一个值,使用时可能会广播到整列\n\n可以用在横截面,也可以用在时序。但时序使用会引入未来数据,这时一般用途是统计\n\"\"\"\n\nfrom polars import Expr\n\n\ndef vec_avg(x:"
},
{
"path": "prompt.txt",
"chars": 3937,
"preview": "你是一个专业的量化因子开发助手,帮助创建、改进因子。\n\n你可以:\n- 编写和优化因子代码\n- 提供因子开发示例\n- 建议和改进因子逻辑\n\n【重要限制】\n1. 只回答与因子开发、编码和优化相关的问题\n2. 无论输入何种语言,都用中文回复\n3."
},
{
"path": "pyproject.toml",
"chars": 827,
"preview": "[project]\nname = \"polars_ta\"\nauthors = [\n { name = \"wukan\", email = \"wu-kan@163.com\" },\n]\ndescription = \"polars expre"
},
{
"path": "requirements-docs.txt",
"chars": 58,
"preview": "mkdocs\nmkdocstrings[python]\nmkdocs-material\nmkdocs-llmstxt"
},
{
"path": "requirements.txt",
"chars": 66,
"preview": "polars>=1.26.0\npolars-ols>=0.3.0\nnumpy\nnumba\npandas\nmore_itertools"
},
{
"path": "setup.py",
"chars": 38,
"preview": "from setuptools import setup\n\nsetup()\n"
},
{
"path": "tests/numba_test.py",
"chars": 2015,
"preview": "import time\n\nimport numpy as np\nimport polars as pl\nfrom numba import jit\n\nfrom polars_ta.utils.numba_ import nb_roll_su"
},
{
"path": "tests/pit_test.py",
"chars": 3422,
"preview": "import time\nfrom pathlib import Path\n\nimport pandas as pd\nimport polars as pl\n\nfrom polars_ta.utils.pit import pit_prepa"
},
{
"path": "tests/ta/test_momentum.py",
"chars": 3485,
"preview": "import numpy as np\nimport polars as pl\nimport talib\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/ta/test_operators.py",
"chars": 1474,
"preview": "import numpy as np\nimport polars as pl\nimport talib\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/ta/test_overlap.py",
"chars": 4294,
"preview": "import numpy as np\nimport polars as pl\nimport talib\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/ta/test_statistic.py",
"chars": 1548,
"preview": "import numpy as np\nimport polars as pl\nimport talib\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/ta/test_volatility.py",
"chars": 1559,
"preview": "import numpy as np\nimport polars as pl\nimport talib\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/ta/test_volume.py",
"chars": 1876,
"preview": "import numpy as np\nimport polars as pl\nimport talib\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/tdx/chip_test.py",
"chars": 817,
"preview": "import numpy as np\nimport polars as pl\n\nfrom polars_ta.tdx.pattern import ts_WINNER_COST\n\nhigh = np.array([10.4, 10.2, 1"
},
{
"path": "tests/tdx/test_reference.py",
"chars": 2168,
"preview": "import numpy as np\nimport polars as pl\nimport talib\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/tdx/test_statistic.py",
"chars": 1368,
"preview": "import time\n\nimport numpy as np\nimport polars as pl\n\n\nclass TestDemoClass:\n high_np = None\n low_np = None\n clos"
},
{
"path": "tests/wq/test_arithmetic.py",
"chars": 1263,
"preview": "import numpy as np\nimport polars as pl\n\nfrom polars_ta.wq.arithmetic import add\n\n\nclass TestDemoClass:\n high_np = Non"
},
{
"path": "tests/wq/test_time_series.py",
"chars": 4713,
"preview": "import time\n\nimport numpy as np\nimport polars as pl\nfrom pandas.testing import assert_frame_equal, assert_series_equal\n\n"
},
{
"path": "thinking_about_TA.md",
"chars": 4201,
"preview": "# About Technical Indicators\n\nThere are three types of technical indicators\n\n1. Time series indicators. Must be sorted b"
},
{
"path": "tools/README.md",
"chars": 1035,
"preview": "# Code Conversion Tools\n\n## TA-Lib tool (codegen_talib.py)\n\nWrap the original `TA-Lib` and save it to `polars_ta.talib._"
},
{
"path": "tools/codegen_talib.py",
"chars": 4147,
"preview": "\"\"\"\nParse talib functions for polars Expressions\n\nThis version is more direct, without skip nan values, and without inpu"
},
{
"path": "tools/prefix.py",
"chars": 2229,
"preview": "import inspect\nfrom typing import List, Optional\n\n\ndef codegen_import_as(module: str, prefix: str = 'ts_',\n "
},
{
"path": "tools/prefix_ta.py",
"chars": 1303,
"preview": "from tools.prefix import codegen_import_as, save\n\nlines = [\"\"\"# this code is auto generated by tools/prefix_ta.py\n\"\"\"]\nl"
},
{
"path": "tools/prefix_talib.py",
"chars": 825,
"preview": "\"\"\"\nAdd prefix to talib functions\n本脚本主要功能是将talib封装添加前缀\n\"\"\"\nimport talib as _talib\nfrom talib import abstract as _abstrac"
},
{
"path": "tools/prefix_tdx.py",
"chars": 1977,
"preview": "from tools.prefix import codegen_import_as, save\n\nlines = [\"\"\"# this code is auto generated by tools/prefix_tdx.py\n\"\"\"]\n"
},
{
"path": "tools/prefix_vec.py",
"chars": 1849,
"preview": "\"\"\"\n将vec_xxx改成cs_vec_xxx\n\n主要用于gp_vect_xxxx转换成cs_vec_xxxx\n\n\"\"\"\n\nimport inspect\nfrom typing import Optional, List\n\nfrom to"
},
{
"path": "tools/prompt.py",
"chars": 4347,
"preview": "import inspect\nfrom typing import List, Optional\n\n\ndef get_annotation(annotation):\n output = annotation.__name__\n "
}
]
About this extraction
This page contains the full source code of the wukan1986/polars_ta GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 150 files (392.1 KB), approximately 142.3k tokens, and a symbol index with 722 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.