Ta-lib介绍
Use TA-Lib to add technical analysis to your own financial market trading applications
200 indicators such as ADX, MACD, RSI, Stochastic, Bollinger Bands etc.
Candlestick patterns recognition
Core written in C/C++ with API also available for Python.
Open-Source (BSD License). Can be freely integrated in your own open-source or commercial applications.
安装环境
操作系统:windows x64
Python版本: python 3.11.5
安装错误日志
直接使用如下命令行尝试安装ta-lib
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple ta-lib
安装失败,日志输出如下
> pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple ta-lib
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting ta-lib
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/6d/7b/d903cd5588823ba14940957b3dec73a6cfa9d55ece5205d75e84c317ac40/TA-Lib-0.4.30.tar.gz (368 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in d:\repo\pricing-engine\pricing_env\lib\site-packages (from ta-lib) (1.26.3)
Building wheels for collected packages: ta-lib
Building wheel for ta-lib (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for ta-lib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
<string>:75: UserWarning: Cannot find ta-lib library, installation may fail.
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\talib
copying talib\abstract.py -> build\lib.win-amd64-cpython-311\talib
copying talib\deprecated.py -> build\lib.win-amd64-cpython-311\talib
copying talib\stream.py -> build\lib.win-amd64-cpython-311\talib
copying talib\__init__.py -> build\lib.win-amd64-cpython-311\talib
running build_ext
building 'talib._ta_lib' extension
creating build\temp.win-amd64-cpython-311
creating build\temp.win-amd64-cpython-311\Release
creating build\temp.win-amd64-cpython-311\Release\talib
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Ic:\ta-lib\c\include -IC:\Users\xyzq\AppData\Local\Temp\pip-build-env-48wp6y8s\normal\Lib\site-packages\numpy\core\include -ID:\repo\pricing-engine\pricing_env\include -IC:\Users\xyzq\miniconda3\include -IC:\Users\xyzq\miniconda3\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /Tctalib/_ta_lib.c /Fobuild\temp.win-amd64-cpython-311\Release\talib/_ta_lib.obj
_ta_lib.c
talib/_ta_lib.c(1223): fatal error C1083: 无法打开包括文件: “ta_libc.h”: No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for ta-lib
Failed to build ta-lib
ERROR: Could not build wheels for ta-lib, which is required to install pyproject.toml-based projects
解决方案
https://github.com/cgohlke/talib-build/releases,根据操作系统和python版本下载对应的wheel文件
将whl文件保存在D盘,安装命令如下
pip3 install D:/TA_Lib-0.4.29-cp311-cp311-win_amd64.whl
安装日志输出如下
> pip3 install D:/TA_Lib-0.4.29-cp311-cp311-win_amd64.whl
Processing d:\ta_lib-0.4.29-cp311-cp311-win_amd64.whl
Requirement already satisfied: numpy in d:\repo\pricing-engine\pricing_env\lib\site-packages (from TA-Lib==0.4.29) (1.26.3)
Installing collected packages: TA-Lib
Successfully installed TA-Lib-0.4.29