VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 1
声望: 1

Ubuntu 18.04安装vnpy 2.3过程详细记录

1. 先安装python3.7环境, minicoda 3.7版64bit

wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.10.3-Linux-x86_64.sh
bash Miniconda3-py37_4.10.3-Linux-x86_64.sh
在安装过程中,我默认安装在自己的用户目录下了,而不是系统目录下,下面的几个python包就不用sudo安装了.
安装后重启一下shell, 如果像下面一样显示为python3.7就行了
(base) **@iZrj9ducce5gywhz4pz0ftZ:/root$ python
Python 3.7.10 (default, Jun 4 2021, 14:48:32)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

2. 下载vnpy2.3源代码, 并解压进入目录

wget https://github.com/vnpy/vnpy/archive/refs/tags/2.3.0.tar.gz
tar -zxvf 2.3.0.tar.gz
cd vnpy-2.3.0/

3. 准备编译

sudo apt-get install build-essential

4. 添加4G虚拟内存

,由于安装过程需要编译几个库,起码4G以上内存,我内存只有2G,所以添加4G的文件作为虚拟内存.
这样添加的虚拟内存在重启系统后就不存在了.
sudo dd if=/dev/zero of=swapfile bs=1073741824 count=4
sudo mkswap swapfile
sudo swapon swapfile

4. 安装ta_lib

自带ta_lib编译总是出错,可以自己先安装这个库,后期就不会在编译安装了.
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -zxvf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
python -m pip install ta-lib

5. 安装quickfix等其他几个库.

其中quickfix编译很慢,需要的内存也很大
python -m pip install quickfix
python -m pip install psycopg2-binary
python -m pip install https://pip.vnpy.com/colletion/ibapi-9.76.1.tar.gz

5. 修改setup.py,

找到第340行附近, 把vnctptd, vnctpmd,前面加上#注释掉
这两个接口vnctptd vnctpmd本来要编译它们的cpp文件,但是下载的源码中却没有,
我看了一下单独的ctp接口,这两部分好像是visual c++的工程,应该只能在windows下编译的啊.
去掉这里后,linux下就没有ctp接口了. 我是不使用ctp接口的.
else:
ext_modules = [

        # vnctptd, vnctpmd,    这行注释掉
        vnxtptd, vnxtpmd,
        vnsgittd, vnsgitmd,

5. 安装vnpy

bash install.sh
上面命令如果中间出错,先来一下
sudo locale-gen zh_CN.GB18030

Administrator
avatar
加入于:
帖子: 4502
声望: 322

感谢分享!精华送上

Member
avatar
加入于:
帖子: 2
声望: 0

楼主,不用CTP,是使用其他什么?

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】