Vnpy部署linux云服务主机

我这边使用的是AWS的免费主机,大家有信用卡可以去申请一个,免费期为一年。

1 解决编译问题和部分依赖

sudo apt-get install  build-essential sudo apt-get install libpq-dev python-dev

2. 下载miniconda

wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh

3. 安装miniconda,根据提示走,该打yes的地方一定要打yes,否则就失败了

bash Miniconda3-latest-Linux-x86_64.sh

4. 将默认python切换为Conda Python

source ~.bashrc

最终在前面出现一个base就算成功了

wpsD0CD.tmp

5. 安装git:

sudo apt install git

wpsD0DD.tmp

6. 使用git 命令将远程代码拉下来

git clone https://github.com/xxx/vnpy.git cd vnpy

wpsD0EE.tmp

7. 注解掉setup.py中关于EOS的代码

if platform.system() == "Windows":   

          # use pre-built pyd for windows ( support python 3.7 only )  

          ext_modules = []

elif platform.system() == "Darwin":   

         ext_modules = [] else: 

  # ext_modules = [vnctptd, vnctpmd, vnoes]  

ext_modules = [vnctptd, vnctpmd]

# ext_modules = check_extension_build_flag(ext_modules, "VNPY_BUILD_OES", vnoes)

ext_modules = check_extension_build_flag(ext_modules, "VNPY_BUILD_CTP", vnctptd)

ext_modules = check_extension_build_flag(ext_modules, "VNPY_BUILD_CTP", vnctpmd)

8. 使用conda创建虚拟环境vnpy_env ,也可以直接用base,这里看个人需要

conda create -n vnpy_env python=3.7.3

wpsD0FF.tmp

9. 切换到该虚拟环境上,可以看到环境切换到vnpy_env

conda activate vnpy_env

wpsD100.tmp

10. 赋予各种权限,启动构建脚本

sudo chmod a+x install.sh bash install.sh

11. 内存不足增加虚拟内存

free -m dd if=/dev/zero of=/tmp/big_swap bs=1024 count=1000000 du -sh /tmp/big_swap mkswap /tmp/big_swap swapon /tmp/big_swap free –m

12. 最后因为AWS EC2 免费主机内存过小,总是卡在最后一步,无法部署,大家挑选云主机的时候最好是CPU 2G,内存4G的。 如果平时是练手可以自己装个虚拟机试试。

wpsD110.tmp

猜你喜欢

转载自www.cnblogs.com/ragrok/p/11965998.html