疫情封控在家, 模拟炒股, 中文社区的材料部分能用。官网没了, 需要使用快照。要梯子。
完成第一步后整理材料。
官网需要用梯子
https://web.archive.org/web/20201104185831/https://www.zipline.io/beginner-tutorial
https://github.com/quantopian/zipline
中文注解: https://rainx.gitbooks.io/-zipline/content/arch/arch.html
安装:
###### using conda to install ######
conda create -n env_zipline python=3.6
conda activate env_zipline
(env_zipline) $ conda install -c conda-forge zipline
#run_command
conda env list
conda activate env_zipline # 切换到环境
## conda deactivate # 退出环境
zipline ingest -b quandl #需要注册这个来下载NASQ 的数据,https://data.nasdaq.com/account/profile
zipline run -f .examples/buyapple.py --start 2016-1-1 --end 2018-1-1 -o buyapple_out.pickle --no-benchmark -b quandl
zipline run -f dual_moving_average.py --start 2014-1-1 --end 2018-1-1 -o dma.pickle --no-benchmark -b quandl
zipline run -f buyapp.py --start 2016-1-1 --end 2018-1-1 -o buyapple_out.pickle --no-benchmark -b quandl
########### matplotlib 导入方式在ubunut 需要特殊处理: ###########
import matplotlib as mpl
mpl.use('TkAgg') # or whatever other backend that you want
import matplotlib.pyplot as plt
安装Anaconda: ubuntu 下载软件:
wget -i download_files.txt
# download_files.txt : https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh
conda 更新镜像源, 切换镜像源会zipline 会更快
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
# reference
# https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
## 其他不大用得着的指令 ##
conda install ipykernel # 将选择的conda环境注入Jupyter Notebook
python -m ipykernel install --user --name env_zipline --display-name "conda env_zipline"
使用jupyter notebook
https://zhuanlan.zhihu.com/p/83884252
nohup jupyter notebook >~/jupyter.log 2>&1 &
sha1:0732d0308da0:9fc1ebad941ed694f2d4439b8a8ee864623a4d89
10.0.2.15:8888