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

一、提前下载需要的安装包:
1、Miniconda3
https://docs.conda.io/en/latest/miniconda.html#
选择MacOSX installers里的最新版本,这里是Python 3.9下载。

2、pycharm
pycharm-community-2020.3.3.dmg
从官网上下载社区版https://www.jetbrains.com/pycharm/

3、vnpy安装包(解压后,复制文件夹到自己喜欢的位置)
从vnpy在gitee的官方地址下载最新的安装包,采用zip格式下载。
https://gitee.com/vnpy/vnpy

二、安装
1、安装Miniconda,这里是Miniconda3-latest-MacOSX-x86_64.pkg
2、添加国内源:
添加国内源:在当前用户下,编辑.condarc,内容如下:
channels:

3、创建虚拟环境
conda create -n py37_vnpy python=3.7
conda activate py37_vnpy
(退出:conda deactivate)

4、安装python.app
conda install -c conda-forge python.app
可能会因为网络问题不成功,多试几次。

5、安装pycharm-community-2020.3.3.dmg
从官网上下载社区版https://www.jetbrains.com/pycharm/

7、打开vnpy所在的文件夹,进行配置
点击‘PyCharm’菜单->Preferences菜单->Project:vnpy一级菜单->Python Interpreter二级菜单->点击右上齿轮->Add菜单->Conda Environment->Existing enviroment->Interpreter:/opy/miniconda3/envs/py37_vnpy/bin/pythonw(选择前面新建的虚拟环境的pythonw)->点OK->点OK->点OK

8、(确认在PyCharm里已经打开了vnpy项目),在PyCharm的底部,找到Terminal的标签,点击,进入py37_vnpy环境的终端,并且当前路径位于vnpy项目的文件夹。
执行以下的安装语句(requirements.txt是vnpy项目文件夹下面的一个文件),这个安装时间比较长,需要较好的网络。

pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

9、创建run.py文件,复制以下代码,来源 README.md

因为mac上不支持ctp接口,所以要注释掉ctp接口,否则运行会报错。

from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp

# from vnpy.gateway.ctp import CtpGateway

from vnpy.app.cta_strategy import CtaStrategyApp
from vnpy.app.cta_backtester import CtaBacktesterApp

def main():
"""Start VN Trader"""
qapp = create_qapp()

event_engine = EventEngine()
main_engine = MainEngine(event_engine)

# main_engine.add_gateway(CtpGateway)
main_engine.add_app(CtaStrategyApp)
main_engine.add_app(CtaBacktesterApp)

main_window = MainWindow(main_engine, event_engine)
main_window.showMaximized()

qapp.exec()


if name == "main":
main()

10、运行 python run.py,注意环境名称是 py37_vnpy

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

description

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

description

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

感谢分享,给你加个精华

Member
加入于:
帖子: 5
声望: 0

没有装成功,基础太差了。。。

在执行第7步时:

Existing enviroment->Interpreter:/opy/miniconda3/envs/py37_vnpy/bin/pythonw(选择前面新建的虚拟环境的pythonw) ,不知道选哪一个目录。
整了两天了都没好,太难了啊

Member
加入于:
帖子: 5
声望: 0

description

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

你好,我按你的方法安装后,提示没有talib库,请问怎么处理下下

Member
avatar
加入于:
帖子: 337
声望: 27

leechl wrote:

你好,我按你的方法安装后,提示没有talib库,请问怎么处理下下

可尝试brew install ta-lib

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

可以运行,但是出不来图形界面,怎么破。。

Member
avatar
加入于:
帖子: 337
声望: 27

clf110510 wrote:

可以运行,但是出不来图形界面,怎么破。。

请问是否有具体的报错截图?

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

青青子荆 wrote:

clf110510 wrote:

可以运行,但是出不来图形界面,怎么破。。

请问是否有具体的报错截图?
description
目测和不显示界面没啥关系

Member
avatar
加入于:
帖子: 4684
声望: 285

提示不是说用“pip install psycopg2-binary”吗?

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

xiaohe wrote:

提示不是说用“pip install psyco[g2-binary”吗?
按了。没用,还是不显示

Member
avatar
加入于:
帖子: 4684
声望: 285

那请问安装之后新的报错是?

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

您好,按照你的指导安装上talib后,现在又报quickfix包的错误,错误如下:
Collecting zipp>=0.5
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0f/8c/715c54e9e34c0c4820f616a913a7de3337d0cd79074dd1bed4dd840f16ae/zipp-3.4.1-py3-none-any.whl (5.2 kB)
Building wheels for collected packages: psycopg2, quickfix
Building wheel for psycopg2 (setup.py) ... done
Created wheel for psycopg2: filename=psycopg2-2.8.6-cp37-cp37m-macosx_10_7_x86_64.whl size=139100 sha256=b35e63fd742f9a97f60b1b54c0cbda02726a343a06133eb82b1a977014b8035d
Stored in directory: /Users/lichunlei/Library/Caches/pip/wheels/fb/16/e9/ffdebd179641e30cfd121899511d86127c933d9355715c1d2c
Building wheel for quickfix (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Users/lichunlei/opt/miniconda3/envs/vnpy220/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/setup.py'"'"'; file='"'"'/private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-wheel-x7awkvw5
cwd: /private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/
Complete output (56 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.7
copying quickfix.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfixt11.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix40.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix41.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix42.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix43.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix44.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix50.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix50sp1.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix50sp2.py -> build/lib.macosx-10.7-x86_64-3.7
running build_ext
Testing for std::tr1::shared_ptr...
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c test_std_tr1_shared_ptr.cpp -o test_std_tr1_shared_ptr.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
test_std_tr1_shared_ptr.cpp:1:10: fatal error: 'tr1/memory' file not found

include <tr1/memory>

       ^~~~~~~~~~~~

1 error generated.
...not found
Testing for std::shared_ptr...
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -std=c++0x -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c test_std_shared_ptr.cpp -o test_std_shared_ptr.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
test_std_shared_ptr.cpp:1:10: fatal error: 'memory' file not found

include <memory>

       ^~~~~~~~

1 error generated.
...not found
Testing for std::unique_ptr...
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -std=c++0x -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c test_std_unique_ptr.cpp -o test_std_unique_ptr.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
test_std_unique_ptr.cpp:1:10: fatal error: 'memory' file not found

include <memory>

       ^~~~~~~~

1 error generated.
...not found
building '_quickfix' extension
creating build/temp.macosx-10.7-x86_64-3.7
creating build/temp.macosx-10.7-x86_64-3.7/C++
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c C++/DataDictionaryProvider.cpp -o build/temp.macosx-10.7-x86_64-3.7/C++/DataDictionaryProvider.o -std=c++0x -Wno-deprecated -Wno-unused-variable -Wno-deprecated-declarations -Wno-maybe-uninitialized
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
In file included from C++/DataDictionaryProvider.cpp:26:
In file included from C++/DataDictionaryProvider.h:29:
In file included from C++/DataDictionary.h:29:
In file included from C++/Fields.h:25:
In file included from C++/FixFields.h:4:
C++/Field.h:29:10: fatal error: 'sstream' file not found

include <sstream>

       ^~~~~~~~~

1 warning and 1 error generated.

error: command 'gcc' failed with exit status 1

ERROR: Failed building wheel for quickfix
Running setup.py clean for quickfix
Successfully built psycopg2
Failed to build quickfix
Installing collected packages: zipp, typing-extensions, six, pytz, urllib3, tzlocal, python-dateutil, PyQt5-sip, pyparsing, pyasn1, pillow, numpy, kiwisolver, importlib-metadata, idna, humanize, greenlet, docopt, cycler, chardet, babel, toolz, stomp.py, SQLAlchemy, simplejson, scipy, rsa, retrying, requests, qtpy, python-rapidjson, PyQt5, pymysql, pymongo, PyCryptodome, protobuf, pandas, msgpack, matplotlib, enum34, delorean, brotli, wmi, websocket-client, trading-calendars, tigeropen, ta-lib, seaborn, rqdatac, quickfix, QScintilla, qdarkstyle, pyzmq, pyqtgraph, psycopg2, plotly, peewee, mongoengine, influxdb, ibapi, futu-api, deap
Running setup.py install for quickfix ... error
ERROR: Command errored out with exit status 1:
command: /Users/lichunlei/opt/miniconda3/envs/vnpy220/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/setup.py'"'"'; file='"'"'/private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-record-nd1hsmfb/install-record.txt --single-version-externally-managed --compile --install-headers /Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m/quickfix
cwd: /private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/
Complete output (56 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.7
copying quickfix.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfixt11.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix40.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix41.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix42.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix43.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix44.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix50.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix50sp1.py -> build/lib.macosx-10.7-x86_64-3.7
copying quickfix50sp2.py -> build/lib.macosx-10.7-x86_64-3.7
running build_ext
Testing for std::tr1::shared_ptr...
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c test_std_tr1_shared_ptr.cpp -o test_std_tr1_shared_ptr.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
test_std_tr1_shared_ptr.cpp:1:10: fatal error: 'tr1/memory' file not found

#include <tr1/memory>
         ^~~~~~~~~~~~
1 error generated.
 ...not found
Testing for std::shared_ptr...
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -std=c++0x -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c test_std_shared_ptr.cpp -o test_std_shared_ptr.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
test_std_shared_ptr.cpp:1:10: fatal error: 'memory' file not found
#include <memory>
         ^~~~~~~~
1 error generated.
...not found
Testing for std::unique_ptr...
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -std=c++0x -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c test_std_unique_ptr.cpp -o test_std_unique_ptr.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
test_std_unique_ptr.cpp:1:10: fatal error: 'memory' file not found
#include <memory>
         ^~~~~~~~
1 error generated.
...not found
building '_quickfix' extension
creating build/temp.macosx-10.7-x86_64-3.7
creating build/temp.macosx-10.7-x86_64-3.7/C++
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include -arch x86_64 -DPYTHON_MAJOR_VERSION=3 -IC++ -I/Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m -c C++/DataDictionaryProvider.cpp -o build/temp.macosx-10.7-x86_64-3.7/C++/DataDictionaryProvider.o -std=c++0x -Wno-deprecated -Wno-unused-variable -Wno-deprecated-declarations -Wno-maybe-uninitialized
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
In file included from C++/DataDictionaryProvider.cpp:26:
In file included from C++/DataDictionaryProvider.h:29:
In file included from C++/DataDictionary.h:29:
In file included from C++/Fields.h:25:
In file included from C++/FixFields.h:4:
C++/Field.h:29:10: fatal error: 'sstream' file not found
#include <sstream>
         ^~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------

ERROR: Command errored out with exit status 1: /Users/lichunlei/opt/miniconda3/envs/vnpy220/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/setup.py'"'"'; file='"'"'/private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-install-cbvlr_w1/quickfix_39efd2aa0c734acb97697273c69d7562/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/_k/qlhx563152z1s1371lg1csnm0000gn/T/pip-record-nd1hsmfb/install-record.txt --single-version-externally-managed --compile --install-headers /Users/lichunlei/opt/miniconda3/envs/vnpy220/include/python3.7m/quickfix Check the logs for full command output.

Gcc版本如下:
gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

折腾好天几了,也没找到解决的办法,请您指导下。

Member
avatar
加入于:
帖子: 4684
声望: 285

可参考此帖25楼

Member
avatar
加入于:
帖子: 7
声望: 1

代码不需要 bash install.sh,直接解压然后在这个库里目录面创建项目就完全可以引用吗?

我在Ubuntu折腾最新的2.3.0 CTP就编译不过去,我还在github提交了issue。

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

向组织报告,mac系统上安装成功,我的两台笔记本都安装好了!就是感觉下拉框不对的了!不知道是否是我的问题1

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

下拉框那个是Qt图形库在Mac上的问题,目前没什么解决方法。。。

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

xiaohe wrote:

那请问安装之后新的报错是?
我也有同样的问题 没有报错 程序在跑就是没有图形界面

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

沪公网安备 31011502017034号

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