移植 Python 量化交易 TA-Lib 库到函数计算
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,TA-Lib,全称"Technical Analysis Library", 即技术分析库,是 Python 金融量化的高级库,涵盖了 150 多种股票、期货交易软件中常用的技术分析指标,如 MACD
千家信息网最后更新 2024年09月22日移植 Python 量化交易 TA-Lib 库到函数计算
TA-Lib,全称"Technical Analysis Library", 即技术分析库,是 Python 金融量化的高级库,涵盖了 150 多种股票、期货交易软件中常用的技术分析指标,如 MACD、RSI、KDJ、动量指标、布林带等等。
TA-Lib 可分为 10 个子板块:
- Overlap Studies(重叠指标)
- Momentum Indicators(动量指标)
- Volume Indicators(交易量指标)
- Cycle Indicators(周期指标)
- Price Transform(价格变换)
- Volatility Indicators(波动率指标)
- Pattern Recognition(模式识别)
- Statistic Functions(统计函数)
- Math Transform(数学变换)
- Math Operators(数学运算)
本文介绍通过 Funcraft 的模板将 Python 量化交易库 TA-lib 移植到函数计算。
依赖工具
本项目是在 MacOS 下开发的,涉及到的工具是平台无关的,对于 Linux 和 Windows 桌面系统应该也同样适用。在开始本例之前请确保如下工具已经正确的安装,更新到最新版本,并进行正确的配置。
- Docker
- Funcraft
对于 MacOS 用户可以使用 homebrew 进行安装:
brew cask install dockerbrew tap vangie/formulabrew install fun
Windows 和 Linux 用户安装请参考:
https://github.com/aliyun/fun/blob/master/docs/usage/installation.md
安装好后,记得先执行 fun config
初始化一下配置。
初始化
使用 fun init 命令可以快捷地将本模板项目初始化到本地。
fun init vangie/ta-lib-example
安装依赖
$ fun installusing template: template.ymlstart installing function dependencies without dockerbuilding ta-lib-example/ta-lib-exampleFunfile exist, Fun will use container to build forcelyStep 1/5 : FROM registry.cn-beijing.aliyuncs.com/aliyunfc/runtime-python3.6:build-1.7.7 ---> 373f5819463bStep 2/5 : COPY ta-lib-0.4.0-src.tar.gz /tmp ---> Using cache ---> 64f9f85112b4Step 3/5 : RUN cd /tmp; tar -xzf ta-lib-0.4.0-src.tar.gz ---> Using cache ---> 9f2d3f836de9Step 4/5 : RUN cd /tmp/ta-lib/ ; ./configure --prefix=/code/.fun/root/usr ; make ; make install ---> Using cache ---> 7725836973d4Step 5/5 : RUN TA_LIBRARY_PATH=/code/.fun/root/usr/lib TA_INCLUDE_PATH=/code/.fun/root/usr/include fun-install pip install TA-Lib ---> Using cache ---> a338e71895b7sha256:a338e71895b74a0be98278f35da38c48545f04a54e19ec9e689bab976265350bSuccessfully built a338e71895b7Successfully tagged fun-cache-d4ac1d89-5b75-4429-933a-2260e2f7fbec:latestcopying function artifact to /Users/vangie/Workspace/ta-lib-example/{{ projectName }}Install SuccessTips for next step======================* Invoke Event Function: fun local invoke* Invoke Http Function: fun local start* Build Http Function: fun build* Deploy Resources: fun deploy
本地调用
$ fun local invokeusing template: template.ymlMissing invokeName argument, Fun will use the first function ta-lib-example/ta-lib-example as invokeNameskip pulling image aliyunfc/runtime-python3.6:1.7.7...FunctionCompute python3 runtime inited.FC Invoke Start RequestId: dc1495b2-13ec-4ecf-a2dc-a0026d82651aFC Invoke End RequestId: dc1495b2-13ec-4ecf-a2dc-a0026d82651a[ "HT_DCPERIOD", "HT_DCPHASE", "HT_PHASOR", "HT_SINE", "HT_TRENDMODE"]RequestId: dc1495b2-13ec-4ecf-a2dc-a0026d82651a Billed Duration: 350 ms Memory Size: 1998 MB Max Memory Used: 34 MB
部署
$ fun deployusing template: template.ymlusing region: cn-shanghaiusing accountId: ***********4733using accessKeyId: ***********EUz3using timeout: 600Waiting for service ta-lib-example to be deployed... Waiting for function ta-lib-example to be deployed... Waiting for packaging function ta-lib-example code... The function ta-lib-example has been packaged. A total of 39 files files were compressed and the final size was 3.23 MB function ta-lib-example deploy successservice ta-lib-example deploy success
执行
$ fun invokeusing template: template.ymlMissing invokeName argument, Fun will use the first function ta-lib-example/ta-lib-example as invokeName========= FC invoke Logs begin =========FC Invoke Start RequestId: 83e23eba-02b4-4380-bbca-daec6856bf4aFC Invoke End RequestId: 83e23eba-02b4-4380-bbca-daec6856bf4aDuration: 213.86 ms, Billed Duration: 300 ms, Memory Size: 128 MB, Max Memory Used: 43.50 MB========= FC invoke Logs end =========FC Invoke Result:[ "HT_DCPERIOD", "HT_DCPHASE", "HT_PHASOR", "HT_SINE", "HT_TRENDMODE"]
参考阅读
- 函数计算
- 【手把手教你】股市技术分析利器之TA-Lib(一)
"阿里巴巴云原生关注微服务、Serverless、容器、Service Mesh 等技术领域、聚焦云原生流行技术趋势、云原生大规模的落地实践,做最懂云原生开发者的技术圈。"
指标
技术
函数
交易
工具
分析
动量
数学
模板
用户
项目
参考
变换
开发
配置
移植
巴巴
高级
手把手
个子
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
ios系统软件开发服务价钱
域名不能解析到服务器了
泰拉瑞亚服务器添加玩家组
开发区运行服务器
计算机网络技术和计算机应用技术有什么区别
企业管理erp服务器
我的世界全部服务器
软件开发常用组件
数据库软件课程设计考试管理系统
数据库top10
浙江大学数据库技术作业
erp用什么软件开发好
处罚企业网络安全保护义务
网络技术与电子商务 书本
类似股票行情软件开发
spss读不出数据库
地籍数据的属性数据库
2016年网络安全讲话
多煤体与网络技术哪个好
纵目科技网络安全与合作
网络安全指导原则范本
网络安全法的信意义
危害网络安全属于危害公共安全吗
ios换服务器下的游戏换回来
数据库系统安全包含
游侠饥荒如何搭建专用服务器
数据库中如何删除图片
学软件开发大专学校
网络安全信息专业课程
网络安全工程师自学