vnpy_mini 1.6.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vnpy_mini-1.6.3.2/.github/CODE_OF_CONDUCT.md +9 -0
- vnpy_mini-1.6.3.2/.github/ISSUE_TEMPLATE.md +19 -0
- vnpy_mini-1.6.3.2/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- vnpy_mini-1.6.3.2/.github/SUPPORT.md +8 -0
- vnpy_mini-1.6.3.2/.github/workflows/pythonapp.yml +32 -0
- vnpy_mini-1.6.3.2/.gitignore +38 -0
- vnpy_mini-1.6.3.2/CHANGELOG.md +33 -0
- vnpy_mini-1.6.3.2/LICENSE +21 -0
- vnpy_mini-1.6.3.2/PKG-INFO +100 -0
- vnpy_mini-1.6.3.2/README.md +72 -0
- vnpy_mini-1.6.3.2/meson.build +157 -0
- vnpy_mini-1.6.3.2/pyproject.toml +84 -0
- vnpy_mini-1.6.3.2/script/run.py +23 -0
- vnpy_mini-1.6.3.2/vnpy_mini/__init__.py +35 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/__init__.py +3 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/generator/generate_api_functions.py +345 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/generator/generate_data_type.py +76 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/generator/generate_struct.py +89 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/include/mini/ThostFtdcMdApi.h +148 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/include/mini/ThostFtdcTraderApi.h +463 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/include/mini/ThostFtdcUserApiDataType.h +6526 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/include/mini/ThostFtdcUserApiStruct.h +9216 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/libs/thostmduserapi.lib +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/libs/thosttraderapi.lib +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/libthostmduserapi.so +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/libthosttraderapi.so +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/mini_constant.py +1205 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/thostmduserapi.dll +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/thosttraderapi.dll +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnmini.h +146 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnmini.sln +41 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/dllmain.cpp +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/framework.h +5 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/pch.cpp +5 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/pch.h +13 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/stdafx.cpp +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/stdafx.h +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/targetver.h +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/vnminimd.cpp +903 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/vnminimd.h +204 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/vnminimd.vcxproj +197 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/vnminimd.vcxproj.filters +63 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminimd/vnminimd.vcxproj.user +4 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/dllmain.cpp +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/framework.h +5 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/pch.cpp +5 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/pch.h +13 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/stdafx.cpp +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/stdafx.h +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/targetver.h +0 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/vnminitd.cpp +6216 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/vnminitd.h +733 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/vnminitd.vcxproj +188 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/vnminitd.vcxproj.filters +57 -0
- vnpy_mini-1.6.3.2/vnpy_mini/api/vnmini/vnminitd/vnminitd.vcxproj.user +4 -0
- vnpy_mini-1.6.3.2/vnpy_mini/gateway/__init__.py +4 -0
- vnpy_mini-1.6.3.2/vnpy_mini/gateway/mini_gateway.py +855 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# 行为准则
|
|
2
|
+
|
|
3
|
+
这是一份VeighNa项目社区的行为准则,也是项目作者自己在刚入行量化金融行业时对于理想中的社区的期望:
|
|
4
|
+
|
|
5
|
+
* 为交易员而生:作为一款从金融机构量化业务中诞生的交易系统开发框架,设计上都优先满足机构专业交易员的使用习惯,而不是其他用户(散户、爱好者、技术人员等)
|
|
6
|
+
|
|
7
|
+
* 对新用户友好,保持耐心:大部分人在接触新东西的时候都是磕磕碰碰、有很多的问题,请记住此时别人对你伸出的援助之手,并把它传递给未来需要的人
|
|
8
|
+
|
|
9
|
+
* 尊重他人,慎重言行:礼貌文明的交流方式除了能得到别人同样的回应,更能减少不必要的摩擦,保证高效的交流
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## 环境
|
|
2
|
+
|
|
3
|
+
* 操作系统: 如Windows 11或者Ubuntu 22.04
|
|
4
|
+
* Python版本: 如VeighNa Studio-4.0.0
|
|
5
|
+
* VeighNa版本: 如v4.0.0发行版或者dev branch 20250320(下载日期)
|
|
6
|
+
|
|
7
|
+
## Issue类型
|
|
8
|
+
三选一:Bug/Enhancement/Question
|
|
9
|
+
|
|
10
|
+
## 预期程序行为
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## 实际程序行为
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 重现步骤
|
|
17
|
+
|
|
18
|
+
针对Bug类型Issue,请提供具体重现步骤以及报错截图
|
|
19
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Python application
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
|
|
8
|
+
runs-on: windows-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v1
|
|
12
|
+
- name: Set up Python 3.13
|
|
13
|
+
uses: actions/setup-python@v1
|
|
14
|
+
with:
|
|
15
|
+
python-version: '3.13'
|
|
16
|
+
- name: Install dependencies
|
|
17
|
+
run: |
|
|
18
|
+
python -m pip install --upgrade pip
|
|
19
|
+
pip install ta-lib==0.6.3 --index=https://pypi.vnpy.com
|
|
20
|
+
pip install vnpy ruff mypy uv
|
|
21
|
+
- name: Lint with ruff
|
|
22
|
+
run: |
|
|
23
|
+
# Run ruff linter based on pyproject.toml configuration
|
|
24
|
+
ruff check .
|
|
25
|
+
- name: Type check with mypy
|
|
26
|
+
run: |
|
|
27
|
+
# Run mypy type checking based on pyproject.toml configuration
|
|
28
|
+
mypy vnpy_mini
|
|
29
|
+
- name: Build packages with uv
|
|
30
|
+
run: |
|
|
31
|
+
# Build source distribution and wheel distribution
|
|
32
|
+
uv build --sdist
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Prerequisites
|
|
2
|
+
*.d
|
|
3
|
+
|
|
4
|
+
# Compiled Object files
|
|
5
|
+
*.slo
|
|
6
|
+
*.lo
|
|
7
|
+
*.o
|
|
8
|
+
*.obj
|
|
9
|
+
|
|
10
|
+
# Precompiled Headers
|
|
11
|
+
*.gch
|
|
12
|
+
*.pch
|
|
13
|
+
|
|
14
|
+
# Fortran module files
|
|
15
|
+
*.mod
|
|
16
|
+
*.smod
|
|
17
|
+
|
|
18
|
+
# Compiled Static libraries
|
|
19
|
+
*.lai
|
|
20
|
+
*.la
|
|
21
|
+
*.a
|
|
22
|
+
|
|
23
|
+
# Executables
|
|
24
|
+
*.exe
|
|
25
|
+
*.out
|
|
26
|
+
*.app
|
|
27
|
+
|
|
28
|
+
# Python
|
|
29
|
+
*.pyc
|
|
30
|
+
dist/
|
|
31
|
+
build/
|
|
32
|
+
vnpy_mini.egg-info/
|
|
33
|
+
__pycache__/
|
|
34
|
+
|
|
35
|
+
# Visual Studio
|
|
36
|
+
.vs/
|
|
37
|
+
x64/
|
|
38
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# 1.6.3.2版本
|
|
2
|
+
|
|
3
|
+
1. 适配vnpy框架4.0版本
|
|
4
|
+
|
|
5
|
+
# 1.6.3.1版本
|
|
6
|
+
|
|
7
|
+
1. 增加对于INE交易所今昨仓位的特殊处理
|
|
8
|
+
|
|
9
|
+
# 1.6.3.0版本
|
|
10
|
+
|
|
11
|
+
1. 更新替换CTP MINI柜台1.6.3版本的API接口
|
|
12
|
+
|
|
13
|
+
# 1.6.0.1版本
|
|
14
|
+
|
|
15
|
+
1. 使用zoneinfo替换pytz库
|
|
16
|
+
2. 调整安装脚本setup.cfg,添加Python版本限制
|
|
17
|
+
3. 增加getApiVersion函数
|
|
18
|
+
|
|
19
|
+
# 1.6.0.0版本
|
|
20
|
+
|
|
21
|
+
1. 更新替换CTP MINI柜台1.6.0版本的API接口
|
|
22
|
+
|
|
23
|
+
# 1.5.6.6版本
|
|
24
|
+
|
|
25
|
+
1. 修复sdist打包缺失lib文件的问题
|
|
26
|
+
|
|
27
|
+
# 1.5.6.5版本
|
|
28
|
+
|
|
29
|
+
1. 调整接口初始化时,接口名称的赋值方式
|
|
30
|
+
|
|
31
|
+
# 1.5.6.4版本
|
|
32
|
+
|
|
33
|
+
1. 调整安装脚本setup.py,支持Windows下安装时根据Python版本进行编译
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present, Xiaoyou Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vnpy_mini
|
|
3
|
+
Version: 1.6.3.2
|
|
4
|
+
Summary: CTP Mini gateway for vn.py quant trading framework.
|
|
5
|
+
Keywords: quant,quantitative,investment,trading,algotrading,ctp
|
|
6
|
+
Author-Email: Xiaoyou Chen <xiaoyou.chen@mail.vnpy.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Natural Language :: Chinese (Simplified)
|
|
20
|
+
Project-URL: Homepage, https://www.vnpy.com
|
|
21
|
+
Project-URL: Documentation, https://www.vnpy.com/docs
|
|
22
|
+
Project-URL: Changes, https://github.com/vnpy/vnpy_mini/blob/master/CHANGELOG.md
|
|
23
|
+
Project-URL: Source, https://github.com/vnpy/vnpy_mini/
|
|
24
|
+
Project-URL: Forum, https://www.vnpy.com/forum
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: vnpy>=4.0.0
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# VeighNa框架的CTP Mini底层接口
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<img src ="https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png"/>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src ="https://img.shields.io/badge/version-1.6.3.2-blueviolet.svg"/>
|
|
37
|
+
<img src ="https://img.shields.io/badge/platform-windows|linux-yellow.svg"/>
|
|
38
|
+
<img src ="https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg" />
|
|
39
|
+
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
## 说明
|
|
43
|
+
|
|
44
|
+
基于CTP Mini的1.6.3接口封装开发。
|
|
45
|
+
|
|
46
|
+
## 安装
|
|
47
|
+
|
|
48
|
+
安装环境推荐基于4.0.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com)】。
|
|
49
|
+
|
|
50
|
+
直接使用pip命令:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install vnpy_mini
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
或者下载源代码后,解压后在cmd中运行:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
pip install .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
使用源代码安装时需要进行C++编译,因此在执行上述命令之前请确保已经安装了【Visual Studio(Windows)】或者【GCC(Linux)】编译器。
|
|
64
|
+
|
|
65
|
+
如果需要以**开发模式**安装到当前Python环境,可以使用下述命令:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
pip install -e . --no-build-isolation --config-settings=build-dir=.\vnpy_mini\api
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## 使用
|
|
73
|
+
|
|
74
|
+
以脚本方式启动(script/run.py):
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
from vnpy.event import EventEngine
|
|
78
|
+
from vnpy.trader.engine import MainEngine
|
|
79
|
+
from vnpy.trader.ui import MainWindow, create_qapp
|
|
80
|
+
|
|
81
|
+
from vnpy_mini import MiniGateway
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def main():
|
|
85
|
+
"""主入口函数"""
|
|
86
|
+
qapp = create_qapp()
|
|
87
|
+
|
|
88
|
+
event_engine = EventEngine()
|
|
89
|
+
main_engine = MainEngine(event_engine)
|
|
90
|
+
main_engine.add_gateway(MiniGateway)
|
|
91
|
+
|
|
92
|
+
main_window = MainWindow(main_engine, event_engine)
|
|
93
|
+
main_window.showMaximized()
|
|
94
|
+
|
|
95
|
+
qapp.exec()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
main()
|
|
100
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# VeighNa框架的CTP Mini底层接口
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src ="https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src ="https://img.shields.io/badge/version-1.6.3.2-blueviolet.svg"/>
|
|
9
|
+
<img src ="https://img.shields.io/badge/platform-windows|linux-yellow.svg"/>
|
|
10
|
+
<img src ="https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg" />
|
|
11
|
+
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
## 说明
|
|
15
|
+
|
|
16
|
+
基于CTP Mini的1.6.3接口封装开发。
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
安装环境推荐基于4.0.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com)】。
|
|
21
|
+
|
|
22
|
+
直接使用pip命令:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
pip install vnpy_mini
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
或者下载源代码后,解压后在cmd中运行:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
pip install .
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
使用源代码安装时需要进行C++编译,因此在执行上述命令之前请确保已经安装了【Visual Studio(Windows)】或者【GCC(Linux)】编译器。
|
|
36
|
+
|
|
37
|
+
如果需要以**开发模式**安装到当前Python环境,可以使用下述命令:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install -e . --no-build-isolation --config-settings=build-dir=.\vnpy_mini\api
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## 使用
|
|
45
|
+
|
|
46
|
+
以脚本方式启动(script/run.py):
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
from vnpy.event import EventEngine
|
|
50
|
+
from vnpy.trader.engine import MainEngine
|
|
51
|
+
from vnpy.trader.ui import MainWindow, create_qapp
|
|
52
|
+
|
|
53
|
+
from vnpy_mini import MiniGateway
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def main():
|
|
57
|
+
"""主入口函数"""
|
|
58
|
+
qapp = create_qapp()
|
|
59
|
+
|
|
60
|
+
event_engine = EventEngine()
|
|
61
|
+
main_engine = MainEngine(event_engine)
|
|
62
|
+
main_engine.add_gateway(MiniGateway)
|
|
63
|
+
|
|
64
|
+
main_window = MainWindow(main_engine, event_engine)
|
|
65
|
+
main_window.showMaximized()
|
|
66
|
+
|
|
67
|
+
qapp.exec()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
main()
|
|
72
|
+
```
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
project(
|
|
2
|
+
'vnpy_mini',
|
|
3
|
+
'cpp',
|
|
4
|
+
version: '1.6.3.2',
|
|
5
|
+
license: 'MIT',
|
|
6
|
+
meson_version: '>=1.7.0',
|
|
7
|
+
default_options: [
|
|
8
|
+
'buildtype=release',
|
|
9
|
+
'cpp_std=c++17',
|
|
10
|
+
'warning_level=2',
|
|
11
|
+
],
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# 导入文件系统和Python模块
|
|
15
|
+
fs = import('fs')
|
|
16
|
+
py = import('python').find_installation(pure: false)
|
|
17
|
+
py_dep = py.dependency()
|
|
18
|
+
|
|
19
|
+
# 获取pybind11路径
|
|
20
|
+
python_cmd = host_machine.system() == 'windows' ? 'python' : 'python3'
|
|
21
|
+
pybind11_include_dir = run_command(python_cmd, '-c', 'import pybind11; print(pybind11.get_include())', check: true).stdout().strip()
|
|
22
|
+
message('使用pybind11路径: ' + pybind11_include_dir)
|
|
23
|
+
|
|
24
|
+
# 获取编译器信息
|
|
25
|
+
cpp = meson.get_compiler('cpp')
|
|
26
|
+
compiler_id = cpp.get_id()
|
|
27
|
+
|
|
28
|
+
# 输出构建目标系统信息
|
|
29
|
+
message('构建目标系统: ' + host_machine.system())
|
|
30
|
+
|
|
31
|
+
# 初始化变量
|
|
32
|
+
thostmduserapi_lib = []
|
|
33
|
+
thosttraderapi_lib = []
|
|
34
|
+
extra_cpp_args = []
|
|
35
|
+
extra_link_args = []
|
|
36
|
+
|
|
37
|
+
# 设置Windows特定编译选项
|
|
38
|
+
if host_machine.system() == 'windows'
|
|
39
|
+
# Windows编译器设置
|
|
40
|
+
add_project_arguments('/MT', language : 'cpp')
|
|
41
|
+
|
|
42
|
+
# 设置库目录
|
|
43
|
+
lib_dir = meson.current_source_dir() / 'vnpy_mini/api/libs'
|
|
44
|
+
api_dir = meson.current_source_dir() / 'vnpy_mini/api'
|
|
45
|
+
|
|
46
|
+
# 设置include目录
|
|
47
|
+
include_dirs = include_directories(
|
|
48
|
+
'vnpy_mini/api/include',
|
|
49
|
+
'vnpy_mini/api/vnmini',
|
|
50
|
+
pybind11_include_dir,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# 定义CTP库
|
|
54
|
+
thostmduserapi_lib = cpp.find_library('thostmduserapi',
|
|
55
|
+
dirs: [lib_dir, api_dir],
|
|
56
|
+
required: true)
|
|
57
|
+
thosttraderapi_lib = cpp.find_library('thosttraderapi',
|
|
58
|
+
dirs: [lib_dir, api_dir],
|
|
59
|
+
required: true)
|
|
60
|
+
|
|
61
|
+
# 设置Linux特定编译选项
|
|
62
|
+
else # Linux
|
|
63
|
+
# Linux编译器设置
|
|
64
|
+
extra_cpp_args = [
|
|
65
|
+
'-std=c++17',
|
|
66
|
+
'-O3',
|
|
67
|
+
'-Wno-delete-incomplete',
|
|
68
|
+
'-Wno-sign-compare',
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
extra_link_args = [
|
|
72
|
+
'-lstdc++',
|
|
73
|
+
'-Wl,-rpath,$ORIGIN', # 添加rpath设置,使库能在运行时找到同目录下的动态库
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
# 设置库目录
|
|
77
|
+
lib_dir = meson.current_source_dir() / 'vnpy_mini/api'
|
|
78
|
+
|
|
79
|
+
# 设置include目录
|
|
80
|
+
include_dirs = include_directories(
|
|
81
|
+
'vnpy_mini/api/include',
|
|
82
|
+
'vnpy_mini/api/vnmini',
|
|
83
|
+
pybind11_include_dir,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# 定义CTP库
|
|
87
|
+
thostmduserapi_lib = cpp.find_library('thostmduserapi',
|
|
88
|
+
dirs: [lib_dir],
|
|
89
|
+
required: true)
|
|
90
|
+
thosttraderapi_lib = cpp.find_library('thosttraderapi',
|
|
91
|
+
dirs: [lib_dir],
|
|
92
|
+
required: true)
|
|
93
|
+
endif
|
|
94
|
+
|
|
95
|
+
# 创建MD模块扩展
|
|
96
|
+
md_module = py.extension_module(
|
|
97
|
+
'vnminimd',
|
|
98
|
+
sources: ['vnpy_mini/api/vnmini/vnminimd/vnminimd.cpp'],
|
|
99
|
+
include_directories: include_dirs,
|
|
100
|
+
dependencies: [py_dep, thostmduserapi_lib],
|
|
101
|
+
cpp_args: extra_cpp_args,
|
|
102
|
+
link_args: extra_link_args,
|
|
103
|
+
install: true,
|
|
104
|
+
subdir: 'vnpy_mini/api'
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
# 创建TD模块扩展
|
|
108
|
+
td_module = py.extension_module(
|
|
109
|
+
'vnminitd',
|
|
110
|
+
sources: ['vnpy_mini/api/vnmini/vnminitd/vnminitd.cpp'],
|
|
111
|
+
include_directories: include_dirs,
|
|
112
|
+
dependencies: [py_dep, thosttraderapi_lib],
|
|
113
|
+
cpp_args: extra_cpp_args,
|
|
114
|
+
link_args: extra_link_args,
|
|
115
|
+
install: true,
|
|
116
|
+
subdir: 'vnpy_mini/api'
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# 安装Python源代码
|
|
120
|
+
python_files = [
|
|
121
|
+
['vnpy_mini/__init__.py', 'vnpy_mini'],
|
|
122
|
+
['vnpy_mini/api/__init__.py', 'vnpy_mini/api'],
|
|
123
|
+
['vnpy_mini/api/mini_constant.py', 'vnpy_mini/api'],
|
|
124
|
+
['vnpy_mini/gateway/__init__.py', 'vnpy_mini/gateway'],
|
|
125
|
+
['vnpy_mini/gateway/mini_gateway.py', 'vnpy_mini/gateway'],
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
foreach file : python_files
|
|
129
|
+
py.install_sources(
|
|
130
|
+
[file[0]],
|
|
131
|
+
pure: false,
|
|
132
|
+
subdir: file[1]
|
|
133
|
+
)
|
|
134
|
+
endforeach
|
|
135
|
+
|
|
136
|
+
# 安装API动态库文件
|
|
137
|
+
if host_machine.system() == 'windows'
|
|
138
|
+
api_libs = [
|
|
139
|
+
'vnpy_mini/api/thostmduserapi.dll',
|
|
140
|
+
'vnpy_mini/api/thosttraderapi.dll',
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
install_data(
|
|
144
|
+
api_libs,
|
|
145
|
+
install_dir: py.get_install_dir() / 'vnpy_mini/api'
|
|
146
|
+
)
|
|
147
|
+
else # Linux
|
|
148
|
+
api_libs = [
|
|
149
|
+
'vnpy_mini/api/libthostmduserapi.so',
|
|
150
|
+
'vnpy_mini/api/libthosttraderapi.so',
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
install_data(
|
|
154
|
+
api_libs,
|
|
155
|
+
install_dir: py.get_install_dir() / 'vnpy_mini/api'
|
|
156
|
+
)
|
|
157
|
+
endif
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "vnpy_mini"
|
|
3
|
+
version = "1.6.3.2"
|
|
4
|
+
description = "CTP Mini gateway for vn.py quant trading framework."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = {text = "MIT"}
|
|
7
|
+
authors = [{name = "Xiaoyou Chen", email = "xiaoyou.chen@mail.vnpy.com"}]
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Development Status :: 5 - Production/Stable",
|
|
10
|
+
"Operating System :: Microsoft :: Windows",
|
|
11
|
+
"Operating System :: POSIX :: Linux",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3.10",
|
|
14
|
+
"Programming Language :: Python :: 3.11",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Programming Language :: Python :: 3.13",
|
|
17
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
18
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Natural Language :: Chinese (Simplified)",
|
|
21
|
+
]
|
|
22
|
+
requires-python = ">=3.10"
|
|
23
|
+
dependencies = ["vnpy>=4.0.0"]
|
|
24
|
+
keywords = ["quant", "quantitative", "investment", "trading", "algotrading", "ctp"]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
"Homepage" = "https://www.vnpy.com"
|
|
28
|
+
"Documentation" = "https://www.vnpy.com/docs"
|
|
29
|
+
"Changes" = "https://github.com/vnpy/vnpy_mini/blob/master/CHANGELOG.md"
|
|
30
|
+
"Source" = "https://github.com/vnpy/vnpy_mini/"
|
|
31
|
+
"Forum" = "https://www.vnpy.com/forum"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = [
|
|
35
|
+
"meson-python>=0.17.1",
|
|
36
|
+
"meson>=1.7.0",
|
|
37
|
+
"pybind11>=2.13.6",
|
|
38
|
+
]
|
|
39
|
+
build-backend = "mesonpy"
|
|
40
|
+
|
|
41
|
+
[tool.mesonpy]
|
|
42
|
+
args = ['--vsenv']
|
|
43
|
+
|
|
44
|
+
[tool.mesonpy.distribution]
|
|
45
|
+
include = [
|
|
46
|
+
"**/*.dll",
|
|
47
|
+
"**/*.so",
|
|
48
|
+
"**/*.pyd",
|
|
49
|
+
"**/*.h",
|
|
50
|
+
"**/*.cpp",
|
|
51
|
+
"**/*.lib",
|
|
52
|
+
"**/*.a"
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
preserve-path = true
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
target-version = "py310"
|
|
59
|
+
output-format = "full"
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint]
|
|
62
|
+
select = [
|
|
63
|
+
"B", # flake8-bugbear
|
|
64
|
+
"E", # pycodestyle error
|
|
65
|
+
"F", # pyflakes
|
|
66
|
+
"UP", # pyupgrade
|
|
67
|
+
"W", # pycodestyle warning
|
|
68
|
+
]
|
|
69
|
+
ignore = ["E501"]
|
|
70
|
+
|
|
71
|
+
[tool.mypy]
|
|
72
|
+
python_version = "3.10"
|
|
73
|
+
warn_return_any = true
|
|
74
|
+
warn_unused_configs = true
|
|
75
|
+
disallow_untyped_defs = true
|
|
76
|
+
disallow_incomplete_defs = true
|
|
77
|
+
check_untyped_defs = true
|
|
78
|
+
disallow_untyped_decorators = true
|
|
79
|
+
no_implicit_optional = true
|
|
80
|
+
strict_optional = true
|
|
81
|
+
warn_redundant_casts = true
|
|
82
|
+
warn_unused_ignores = true
|
|
83
|
+
warn_no_return = true
|
|
84
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from vnpy.event import EventEngine
|
|
2
|
+
from vnpy.trader.engine import MainEngine
|
|
3
|
+
from vnpy.trader.ui import MainWindow, create_qapp
|
|
4
|
+
|
|
5
|
+
from vnpy_mini import MiniGateway
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
"""主入口函数"""
|
|
10
|
+
qapp = create_qapp()
|
|
11
|
+
|
|
12
|
+
event_engine = EventEngine()
|
|
13
|
+
main_engine = MainEngine(event_engine)
|
|
14
|
+
main_engine.add_gateway(MiniGateway)
|
|
15
|
+
|
|
16
|
+
main_window = MainWindow(main_engine, event_engine)
|
|
17
|
+
main_window.showMaximized()
|
|
18
|
+
|
|
19
|
+
qapp.exec()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
main()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2015-present, Xiaoyou Chen
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
import importlib_metadata
|
|
25
|
+
|
|
26
|
+
from .gateway import MiniGateway
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
__all__ = ["MiniGateway"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
__version__ = importlib_metadata.version("vnpy_mini")
|
|
34
|
+
except importlib_metadata.PackageNotFoundError:
|
|
35
|
+
__version__ = "dev"
|