Skip to content

Commit

Permalink
Merge pull request #1 from Edanflame/main
Browse files Browse the repository at this point in the history
调整安装脚本setup.py,支持Windows下安装时根据Python版本进行编译
  • Loading branch information
vnpy committed Feb 21, 2022
2 parents 24c753f + 037f364 commit d1769d7
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 1.0.1版本

1. 调整安装脚本setup.py,支持Windows下安装时根据Python版本进行编译
2. 调整接口初始化时,接口名称的赋值方式
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p align="center">
<img src ="https://img.shields.io/badge/version-1.0.1-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.7-blue.svg" />
<img src ="https://img.shields.io/badge/python-3.7|3.8|3.9|3.10-blue.svg" />
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>

Expand All @@ -20,21 +20,22 @@

## 安装

安装需要基于2.9.0版本以上的[VN Studio](https://www.vnpy.com)
安装需要基于3.0.0版本以上的[VN Studio](https://www.vnpy.com)

直接使用pip命令:

```
pip install vnpy_sec
```


或者下载解压后在cmd中运行:

```
python setup.py install
pip install -e .
```

由于在安装的同时需要编译C++代码,因此在执行上述命令之前需要去微软[官网](https://my.visualstudio.com/Downloads?q=build%20tools)下载Visual Studio Build Tools。其中工作负荷选择Visual C++生成工具,同时推荐下载2017版。

## 使用

以脚本方式启动(script/run.py):
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ classifiers =
Operating System :: Microsoft :: Windows
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Office/Business :: Financial :: Investment
Programming Language :: Python :: Implementation :: CPython
License :: OSI Approved :: MIT License
Expand All @@ -33,4 +36,4 @@ install_requires =
importlib_metadata

[options.package_data]
* = *.dll, *.so, *.pyd
* = *.dll, *.pyd
60 changes: 58 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
from setuptools import setup
import platform

setup()
from setuptools import Extension, setup


def get_ext_modules() -> list:
"""
获取三方模块
Windows需要编译封装接口
Linux和Mac由于缺乏二进制库支持无法使用
"""

extra_compile_flags = ["-O2", "-MT"]
extra_link_args = []
runtime_library_dirs = []

vnsecmd = Extension(
"vnpy_sec.api.vnsecmd",
[
"vnpy_sec/api/vnsec/vnsecmd/vnsecmd.cpp",
],
include_dirs=["vnpy_sec/api/include",
"vnpy_sec/api/vnsec"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_sec/api/libs", "vnpy_sec/api"],
libraries=["DFITCSECMdApi", "DFITCSECTraderApi", "HsFutuSystemInfo", "HsFutuSystemInfo"],
extra_compile_args=extra_compile_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)

vnsectd = Extension(
"vnpy_sec.api.vnsectd",
[
"vnpy_sec/api/vnsec/vnsectd/vnsectd.cpp",
],
include_dirs=["vnpy_sec/api/include",
"vnpy_sec/api/vnsec"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_sec/api/libs", "vnpy_sec/api"],
libraries=["DFITCSECMdApi", "DFITCSECTraderApi", "HsFutuSystemInfo", "HsFutuSystemInfo"],
extra_compile_args=extra_compile_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)

return [vnsectd, vnsecmd]


setup(
ext_modules=get_ext_modules(),
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions vnpy_sec/api/vnsec/vnsecmd/vnsecmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,6 @@ int MdApi::reqStockUserLogin(const dict &req)
getInt(req, "compressflag", &myreq.compressflag);
getString(req, "authenticCode", myreq.authenticCode);
getString(req, "appID", myreq.appID);
getInt(req, "collectInterType", &myreq.collectInterType);
int i = this->api->ReqStockUserLogin(&myreq);
return i;
};
Expand All @@ -1113,7 +1112,6 @@ int MdApi::reqSOPUserLogin(const dict &req)
getInt(req, "compressflag", &myreq.compressflag);
getString(req, "authenticCode", myreq.authenticCode);
getString(req, "appID", myreq.appID);
getInt(req, "collectInterType", &myreq.collectInterType);
int i = this->api->ReqSOPUserLogin(&myreq);
return i;
};
Expand All @@ -1128,7 +1126,6 @@ int MdApi::reqFASLUserLogin(const dict &req)
getInt(req, "compressflag", &myreq.compressflag);
getString(req, "authenticCode", myreq.authenticCode);
getString(req, "appID", myreq.appID);
getInt(req, "collectInterType", &myreq.collectInterType);
int i = this->api->ReqFASLUserLogin(&myreq);
return i;
};
Expand Down
4 changes: 3 additions & 1 deletion vnpy_sec/gateway/sec_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class SecGateway(BaseGateway):
VN Trader Gateway for dfitc .
"""

default_name: str = "SEC"

default_setting: Dict[str, Any] = {
"账号": "",
"行情密码": "",
Expand All @@ -127,7 +129,7 @@ class SecGateway(BaseGateway):

exchanges: List[Exchange] = list(EXCHANGE_VT2SEC.keys())

def __init__(self, event_engine: EventEngine, gateway_name="SEC"):
def __init__(self, event_engine: EventEngine, gateway_name: str) -> None:
""""""
super().__init__(event_engine, gateway_name)

Expand Down

0 comments on commit d1769d7

Please sign in to comment.