0%

vectorbt学习_01安装

参考教程:
官方文档:https://vectorbt.dev/
vector-bt 例程介绍:https://www.jianshu.com/p/4fc4ce04b925

vectorbt中文资料有限,阅读官方英文材料效率较低,将学习过程梳理为笔记,方便大家学习。
由于水平所限,如有错误,欢迎指正。

docker失败

docker具体构建步骤参考

1
/home/john/docker/vectorbt/readme.txt

原始安装docker时这里会卡顿

1
2
3
4
5
6
7
8
Collecting plotly>=4.12.0
。。。

Collecting ccxt>=4.0.14
Downloading ccxt-4.1.2-py2.py3-none-any.whl (3.9 MB)

Collecting TA-Lib
Downloading TA-Lib-0.4.28.tar.gz (357 kB)

需要修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(base) john@john-HLYL-WXX9:~/docker/vectorbt/vectorbt$ git diff Dockerfile
diff --git a/Dockerfile b/Dockerfile
index 0200fa1..a9da8aa 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,6 +14,8 @@ RUN chmod -R +x scripts

ARG FULL="yes"

+RUN pip install plotly>=4.12.0 -i https://pypi.doubanio.com/simple ## 新增的行
+
RUN if [[ -n "${FULL}" ]] ; then \
scripts/install-talib.sh && pip install --no-cache-dir .[full] ; else \
pip install --no-cache-dir . ; fi
@@ -36,4 +38,4 @@ RUN if [[ -n "${TEST}" ]] ; then \

不可行,docker里安装talib失败。

conda+jupyter支持(依赖源码,成功)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
conda create -n vectorbt_env python=3.8
conda activate vectorbt_env

git clone git@github.com:polakowo/vectorbt.git vectorbt
pip install -e vectorbt

conda install pyyaml
pip install yfinance
pip install PyPortfolioOpt

pip install backtrader
pip install flask-SQLAlchemy
pip install pymysql
pip install -U kaleido

源码安装talib后pip安装(直接pip安装提示找不到头文件)
源码下载:https://ta-lib.org/install/
源码安装步骤:
$ untar and cd
$ ./configure --prefix=/usr
$ make
$ sudo make install

pip安装:pip install TA-Lib

pip install matplotlib==3.2.0 #cannot import name 'warnings' from 'matplotlib.dates'


增加jupyter支持 、

另外根据文档https://algotrading101.com/learn/vectorbt-guide/,可通过

1
pip install -U "vectorbt[full]"

安装完整版vectorbt(包含相关依赖项)

包升级

新增指标修改vectorbt源码和包升级

1
2
3
cd /home/john/git/repo_quant
conda activate vectorbt_env
pip install -e vectorbt